i want create some search system:
this is some example:
i want show some user with 'Usercat.subcat_id' =>
2,'User.shahr_id'=>576

in usercat model i have:

var $belongsTo = array(
                'User' => array(
                        'className' => 'User',
                        'foreignKey' => 'user_id',
                        'conditions' => '',
                        'fields' => '',
                        'order' => ''
                ));

in User model i have:

var $hasMany = array('Usercat');

now i have SearchController,in SearchController i have:

        var $uses = array('Usercat','User');

and in search model i have:

class Search extends AppModel {
        var $name = "Search";
        var $useTable = false;
}

and in index function in SearchController i have:

$res = $this->Usercat->User->find('all', array('conditions' =>
array('Usercat.subcat_id' => 2,'User.shahr_id'=>576)));

when i am test i have this error:

SQL Error: 1054: Unknown column 'Usercat.subcat_id' in 'where
clause' [CORE\cake\libs\model\datasources\dbo_source.php, line 673]

            $out = null;
            if ($error) {
                trigger_error('<span style="color:Red;text-
align:left"><b>' . __('SQL Error:', true) . "</b> {$this->error}</
span>", E_USER_WARNING);

$sql    =       "SELECT `User`.`id`, `User`.`user_group_id`, `User`.`username`,
`User`.`password`, `User`.`email`, `User`.`phone`, `User`.`mobile`,
`User`.`website`, `User`.`active`, `User`.`first_name`,
`User`.`last_name`, `User`.`ostan_id`, `User`.`shahr_id`,
`User`.`views`, `User`.`sex`, `User`.`coname`, `User`.`coadress`,
`User`.`coid`, `User`.`imagecount`, `User`.`videocount`,
`User`.`exdate`, `User`.`created` FROM `users` AS `User`   WHERE
`Usercat`.`subcat_id` = 2 AND `User`.`shahr_id` = 576   "
$error  =       "1054: Unknown column 'Usercat.subcat_id' in 'where clause'"
$out    =       null

Query: SELECT `User`.`id`, `User`.`user_group_id`, `User`.`username`,
`User`.`password`, `User`.`email`, `User`.`phone`, `User`.`mobile`,
`User`.`website`, `User`.`active`, `User`.`first_name`,
`User`.`last_name`, `User`.`ostan_id`, `User`.`shahr_id`,
`User`.`views`, `User`.`sex`, `User`.`coname`, `User`.`coadress`,
`User`.`coid`, `User`.`imagecount`, `User`.`videocount`,
`User`.`exdate`, `User`.`created` FROM `users` AS `User` WHERE
`Usercat`.`subcat_id` = 2 AND `User`.`shahr_id` = 576


1. i want fix this error
2.after i fix this error how can i send data for paginate?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to