CakePHP problems by not getting the _schema
my model in cakephp:
<?php
App::uses('AppModel', 'Model');
/**
* Product Model
*
* @property Image $Image
* @property Client $Client
*/
class Product extends AppModel {
/**
* Display field
*
* @var string
*/
public $displayField = 'title';
}
?>
My controller in cakephp:
$this->Product->recursive = -1;
var_dump($this->Product->_schema);
var_dump gives me null
I do the same with another table in BBDD and get results.
Results another table in BBDD:
Array
(
[id] => Array
(
[type] => integer
[null] =>
[default] =>
[length] => 11
[key] => primary
[collate] =>
[comment] =>
)
[type] => Array
(
[type] => integer
[null] =>
[default] =>
[length] => 11
[collate] =>
[comment] =>
)
[title] => Array
(
[type] => string
[null] =>
[default] =>
[length] => 255
[collate] => utf8_general_ci
[comment] =>
[charset] => utf8
)
[description] => Array
(
[type] => text
[null] =>
[default] =>
[length] =>
[collate] => utf8_general_ci
[comment] =>
[charset] => utf8
)
[date] => Array
(
[type] => date
[null] =>
[default] =>
[length] =>
[collate] =>
[comment] =>
)
[urlvideo] => Array
(
[type] => string
[null] =>
[default] =>
[length] => 255
[collate] => utf8_general_ci
[comment] =>
[charset] => utf8
)
[image] => Array
(
[type] => string
[null] =>
[default] =>
[length] => 255
[collate] => utf8_general_ci
[comment] =>
[charset] => utf8
)
[created] => Array
(
[type] => datetime
[null] =>
[default] =>
[length] =>
[collate] =>
[comment] =>
)
[modified] => Array
(
[type] => datetime
[null] =>
[default] =>
[length] =>
[collate] =>
[comment] =>
)
)
thanks
PD:
my table:
CREATE TABLE `products` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(150) NOT NULL,
`description` text,
`characteristics` text,
`urlvideo` varchar(255) DEFAULT NULL,
`pdf` varchar(255) NOT NULL,
`type` int(11) NOT NULL,
`created` datetime NOT NULL,
`modified` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
->_schema stores a cached copy of the schema of a model. If you haven’t run any queries on the model, it will be empty.
Try calling:
(which fetches the schema, caches it in Model->_schema, and then returns the data)