没有得到_schema的CakePHP问题

时间:2012-01-26 12:00:09

标签: php cakephp

没有获得_schema

的CakePHP问题

我的模型在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';


}
?>

我的控制器在cakephp中:

$this->Product->recursive = -1;
var_dump($this->Product->_schema);

var_dump给我null

我对BBDD中的另一个表做同样的事情并获得结果。

结果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] => 
        )

)

感谢

PD:

我的桌子:

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 ;

1 个答案:

答案 0 :(得分:3)

- &gt; _schema存储模型架构的缓存副本。如果您尚未对模型运行任何查询,则它将为空。

尝试致电:

$this->Model->schema()

(获取架构,将其缓存在Model-&gt; _schema中,然后返回数据)