[eluser]Unknown[/eluser]
Hi,
I'm using CI 1.7.2 and Doctrine 1.2.3. I've made a controler and a model. I want that table is nestedSet.
When I run controler index and want to save first root record i get an error that root_id isn't set (if i remove root_id from model setUp definition i get that lft isn't set).
In Doctrin manual is definition that nestedSet change root_id, lft, rgt and level by himself.
Does anybody know what i've made wrong?
Here is the code of controler and model.
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cat_test extends Controller
{
/**
* The constructor
* @access public
* @return void
*/
public function __construct()
{
parent::Controller();
// $this->lang->load('categories');
}
public function index()
{
$category = new Category();
$category->category_id = 1;
$category->title = 'Root Category 1';
$category->alias = 'cat1';
$category->lng = 'sl';
$category->active = '1';
$category->save();
$treeObject = Doctrine_Core::getTable('Category')->getTree();
$treeObject->createRoot($category);
}
// --------------------------------------------------------------------
}
// end Category Controler
Code:
class CategoryTest extends Doctrine_Record
{
/**
* Set Doctrine 1.2.3 definition
*/
public function setTableDefinition()
{
$this->setTableName('category_test');
$this->hasColumn('category_id', 'integer', 4);
$this->hasColumn('lng', 'string', 5);
$this->hasColumn('title', 'string', 255);
$this->hasColumn('alias', 'string', 255);
$this->hasColumn('active', 'binary');
}
public function setUp()
{
parent::setUp();
$nestedset0 = new Doctrine_Template_NestedSet(array(
'hasManyRoots' => true));
$this->actAs($nestedset0);
}
// --------------------------------------------------------------------
}
// end Category model