I am trying to perform relational query to the database and in where clause I have one ambiguous column, so I am using table.ambiguouscolumn_name in where clause, but its giving me error like table.ambiguouscolumn_name is not defined.
For example
$usermodel = new user;
$criteria = new CDbCriteria;
$criteria->select = array("UserId", "FullName","CreatedDate","Status");
$criteria->condition = "user.CustomerId=:CustomerId";
$parameters[":CustomerId"] = $this->customerid;
$pages=new CPagination($usermodel->count($criteria));
Exception I am getting is -
Quote
CDbException
Description
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.CustomerId' in 'where clause'
Description
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.CustomerId' in 'where clause'
I went through the debug logs, its generating query like -
Quote
Querying SQL: SELECT COUNT(*) FROM `user` `t` WHERE
user.CustomerId=:CustomerId. Bind with parameter :CustomerId='1'
user.CustomerId=:CustomerId. Bind with parameter :CustomerId='1'
Query says its creating alias for the table as t but in my where clause its user.CustomerId, so its giving exception.
I hope there must be some simple solution to this.
Thanks!

Sign In
Register
Help


MultiQuote