Hi,
i have two models with a BELONGS_TO relation.
both have a name column.
now if i do something like this:
$activities_c=new CDbCriteria;
$activities_c->with=array(
'macroarea_er',
);
$activities_c->order='name ASC';
it gives me an error saying that name column is ambiguous.
This is correct..the question is..how can i specify which name column it has to use?
Thansk,
Riccardo
Page 1 of 1
orber by ambiguous column name
#2
Posted 16 March 2010 - 11:13 AM
Add the table name before the column name, e.g.
$activities_c=new CDbCriteria; $activities_c->with=array( 'macroarea_er', ); $activities_c->order='macroarea_er.name ASC';
#3
Posted 16 March 2010 - 11:33 AM
The other table is called activities, but if i do like this:
$activities_c->order='activities.name ASC';
it gives me this error:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'activity.name' in 'order clause'
while if i do like you suggest:
$activities_c->order='macroarea_er.name ASC';
it works but i nedd the first one to work...
Riccardo
$activities_c->order='activities.name ASC';
it gives me this error:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'activity.name' in 'order clause'
while if i do like you suggest:
$activities_c->order='macroarea_er.name ASC';
it works but i nedd the first one to work...
Riccardo
Matt Kelliher, on 16 March 2010 - 11:13 AM, said:
Add the table name before the column name, e.g.
$activities_c=new CDbCriteria; $activities_c->with=array( 'macroarea_er', ); $activities_c->order='macroarea_er.name ASC';
#4
Posted 16 March 2010 - 11:45 AM
use t.name for the main table
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";
python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]
ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}
You say Tomato, I say Tomato.
Share this topic:
Page 1 of 1

Help













