Money Lending Example Contact



Im new here. want to try creating an app using agile
so im trying this new sample Money Lending

im stuck with contact.php

$app = new MyApp();

when creating this i have an error

when i change



$contact = new Contact($app->db);
$ref = $contact->addCondition('user_id', $_SESSION['user_id']);

it will not showing the user_id

but if i write it like this

$app->layout->add('CRUD')->setModel(new Contact($app->db))->addCondition('user_id', $_SESSION['user_id']);

the user_id is showing

  1. what is the function of ref? is it the same as addCondition?
  2. why the 2nd code and 3rd code have different result?


Hi, most likely in Model User the reference to Contact is not defined, that’s why version 1 fails.

Ref() traverses to another model, like from User to Contact. User->ref(‘Contact’) returns a Contact Model with, depending on how the reference is defined, some conditions.

Hope this helps you a bit, am on mobile, hard to type code here :slight_smile: