1
我有這一段代碼CakePHP的搜索功能
foreach($words as $word) {
$search = '%'.$word.'%';
$query['conditions'][]['or'] = array(
'ProductComponent.codice LIKE' => $search,
'ProductComponent.nome'.__('_it', true).' LIKE' => $search,
'ComponentType.nome'.__('_it', true).' LIKE' => $search,
'Material.nome'.__('_it', true).' LIKE' => $search,
'Finish.nome'.__('_it', true).' LIKE' => $search,
'ClientCode.client_component_code LIKE' => $search,
);
}
,當我執行查詢我有此錯誤
Warning (512): SQL Error: 1054: Unknown column 'ClientCode.client_component_code' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
這是表
CREATE TABLE IF NOT EXISTS `client_codes` (
`id` int(10) NOT NULL auto_increment,
`user_id` int(10) NOT NULL,
`product_component_id` int(10) NOT NULL,
`client_component_code` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=225 ;
這是客戶端代碼型號
<?php
class ClientCode extends AppModel {
var $name = 'ClientCode';
var $belongsTo = array('ProductComponent', 'User');
}
?>
而這些都是ProductComponent模型
<?php
class ProductComponent extends AppModel {
var $name = 'ProductComponent';
var $belongsTo = array('ComponentType', 'Material', 'Finish','Line');
var $hasMany = array(
'Part',
'RelatedComponent',
'LineRelatedComponent' => array(
'className' => 'RelatedComponent',
'conditions' => array('NOT' => array('LineRelatedComponent.line_id' => NULL)),
),
'GenericRelatedComponent' => array(
'className' => 'RelatedComponent',
'conditions' => array('GenericRelatedComponent.line_id' => NULL),
),
'CustomPriceList',
'PriceList',
'ClientCode'
);
var $hasAndBelongsToMany = array('Upload');
的,我不明白爲什麼...請幫助的關係。謝謝!
你的數據庫中是否有'ClientCode.client_component_code'列? –
只有最後一個條件不起作用,其他工作正常 –
是的Marek我在我的數據庫 –