gpt4 book ai didi

php - CakePHP 没有获得 _schema 的问题

转载 作者:行者123 更新时间:2023-12-04 06:00:05 25 4
gpt4 key购买 nike

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 中的 Controller :
$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 ;

最佳答案

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

尝试调用:

$this->Model->schema()

(它获取模式,将其缓存在 Model->_schema 中,然后返回数据)

关于php - CakePHP 没有获得 _schema 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9017824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com