Проблемы CakePHP, не получив _schema - PullRequest
2 голосов
/ 26 января 2012

Проблемы CakePHP из-за отсутствия _schema

моей модели в 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 дает мне ноль

Я делаю то же самое с другой таблицей в 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 Ответ

3 голосов
/ 07 февраля 2012

-> _ схема хранит кэшированную копию схемы модели. Если вы не выполняли никаких запросов к модели, она будет пустой.

Попробуйте позвонить:

$this->Model->schema()

(который выбирает схему, кэширует ее в Model -> _ схема, а затем возвращает данные)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...