tim*_*mkl 2 php arrays cakephp
我目前正在通过IBM关于CakePHP的教程
有一次,我遇到了这段代码:
<?php
class Dealer extends AppModel {
var $name = 'Dealer';
var $hasMany = array (
'Product' => array(
'className' => 'Product',
'conditions'=>, // is this allowed?
'order'=>, // same thing here
'foreignKey'=>'dealer_id'
)
);
}
?>
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到以下错误消息:"解析错误:语法错误,意外','在第7行的/Applications/MAMP/htdocs/cakephp/app/models/product.php"
我是PHP的n00b所以我的问题是:是否允许使用没有指定值的键创建数组?有没有人玩这个啧啧,知道是什么?
分配值null而不是留下任何东西.该手册说
如果测试已设置为NULL的变量,则isset()将返回FALSE
<?php
class Dealer extends AppModel
{
var $name = 'Dealer';
var $hasMany = array ('Product' => array(
'className' => 'Product',
'conditions'=> null,
'order'=> null,
'foreignKey'=>'dealer_id')
);
}
?>
Run Code Online (Sandbox Code Playgroud)
这很好用.