функция поиска cakePHP - PullRequest
       10

функция поиска cakePHP

1 голос
/ 20 января 2012

в функции поиска у меня есть этот кусок кода

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,
            );
        }

, и когда я выполняю запрос, у меня появляется эта ошибка

Предупреждение (512): Ошибка SQL: 1054: Неизвестный столбец ClientCode.client_component_code в разделе where

это модель ClientCode

<?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');

Я не понимаю, почему ... ПОЖАЛУЙСТА, ПОМОГИТЕ.Спасибо!

1 Ответ

1 голос
/ 08 февраля 2012

Вы используете вмещаемое?Похоже, вы пытаетесь выполнить условие для несвязанной таблицы.

...