Skip to content

Instantly share code, notes, and snippets.

@zoghal
Created June 16, 2013 20:48
Show Gist options
  • Save zoghal/5793384 to your computer and use it in GitHub Desktop.
Save zoghal/5793384 to your computer and use it in GitHub Desktop.
sample tree eroor
$page = new Page(){
$page->create();
$page->save(array('parent_id' => 10 , 'title' => 'hello'));
<?php
class Page extends AppModel{
public $actsAs = array(
'Tree'
);
public $hasOne = array( 'Category' );
public function beforeFind($queryData) {
$queryData['conditions'][$this->escapeField('model')] = 'Page'
return $queryData;
}
}
CREATE TABLE `pages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`site_id` int(11) DEFAULT NULL,
`type` varchar(255) COLLATE utf8_persian_ci NOT NULL,
`model` varchar(255) COLLATE utf8_persian_ci NOT NULL,
`lang` varchar(5) COLLATE utf8_persian_ci NOT NULL,
`name` varchar(255) COLLATE utf8_persian_ci NOT NULL,
`alias` varchar(255) COLLATE utf8_persian_ci NOT NULL,
`home` tinyint(1) NOT NULL DEFAULT '0',
`status` tinyint(1) NOT NULL DEFAULT '1',
`content_count` int(11) DEFAULT '0',
`service_count` int(11) DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`modifed` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `fk_objects_sites_1` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment