I have this query, that does not work :
$criteria = new CDbCriteria;
$criteria->select='*' ;
$criteria->condition='status=:status and sex=LOWER(:sexOpt)';
$criteria->order='nick ASC';
$criteria->limit='25';
$criteria->params=array(':status'=>'1' , ':sexOpt'=>strtolower($this->sexText));
// echo strtolower($this->sexText);
$results = User::model()->with('profile')->findAll($criteria);
If status=1 it means its an active user, the sexText just gives a string representation of what a proper input for the database should be ex. ‘Male’ or ‘Female’.
Now if i try
$criteria->condition='status=:status';
It returns all users that are registered, and have status=1, as expected.
If I try :
$criteria->condition='status=:status and sex="male"';
It does not work, same with ’ sex=male ’ but thats expected since the database field is a STRING.
I have tryed all sorts of combinations, but i cant seem to get a match…
I am upgrading from a project where i use doctrine, and the one with Doctrine, on same database/tables and field names, it works (its also similar syntax too).
$uDB = Doctrine_Query::create()
->select('u.*, p.*')
->from('User u, u.Profile p')
->where('u.estado = 1 and u.sex = ?', $sex)
->orderby("u.nick ASC")
->limit(25);
Any ideas?
Thanks in advance.
PS: is there a way to have similar intregration on framework using Doctrine instead of Yii AR implementation? The models are quite similar (not the same) in terms of validation rules, etc. Having a more powerful and documented DB specific framework just for that purpose would save me quite a bit of time figuring out stuff. If not, what would be the best class to extend from, for a similar User::model()->exampleFunction()
User::model()->exampleFunction()
class User extends CActiveRecord
{
public function exampleFunction(){ return 'Hello!'; }
}
class User extends SomeAlternativeModelTypeOtherThanForm
{
public function exampleFunction(){ return 'Hello!'; }
}
So i could still call Doctrine stuff, but use the same model access logic (calling it Form or ActiveRecord when it isnt, seems wierd) so i can retain same access code.
I ask this because I dont know if i can do this safely (without breaking some obscure thing I might need later):
User::model()->exampleFunction()
class User extends Doctrine_Record
{
public function exampleFunction(){ return 'Hello!'; }
}