Hi,
I am trying to understand the much discussed Cortex plugin.
I am playing around with it a little bit but I am somewhat confused.
I have a model 'User' and a controller, aptly named 'UserController'.
I have found out the possibility to use the fluid mode from the controller, this seems to be working, except that I think I found a bug: when the db table 'users' does not yet exist the program generates an error on the rights_level item. It does not appear to be accepting the underscore, without the underscore in the model it works.
public function index()
{
$user->name="admin";
$user->mail="te...@mail.inv";
$user->website="www.google.com";
$user->rights_level=1;
$user->save();
$user->reset();
$this->f3->set('users',$user->all());
$this->f3->set('view','list.htm');
}
My User model:
class User extends \DB\Cortex {
protected
$fieldConf = array(
'name' => array(
'type' => 'VARCHAR256',
'nullable' => false,
),
'mail' => array(
'type' => 'VARCHAR128'
),
'website' => array(
'type' => 'VARCHAR256'
),
'rights_level' => array(
'type' => 'TINYINT',
'default' => 3,
),
),
$db = 'DB',
$table = 'users',
$fluid = true, // triggers the SQL Fluid Mode, default: false
$primary = 'uid', // name of the primary key (auto-created), default: id
$ttl = 120, // caching time of field schema, default: 60
$rel_ttl = 30; // caching time of all relations, default: 0
public function all()
{
return $this->find();
}
}
This is code I copied from the cortex manual on github.
I do not understand how to set the $db in the model. If I sent it from the controller (as above) the model seems to be using that db and it does not take the one set as $db into account.
I only need to set the $table, that is the only thing it seems to care about.
If I don't send the db-connection in the controller it never gets set. How can I set the DB variable that is being used in the sample code?
This is likely also linked to the fact that I can not user $user::setup() to initialize the table.
edit: removed the edit....