MySQL functions

How would you go about using MySQL functions? I’m trying to work with a table that uses AES_ENCRYPT in encrypt a password field. And of course AES_DECRYPT for viewing the field.

Thanks for any help.

Have you looked at the basic CDbCommand class. You can do any kind of custom MySQL this way:




$connection = Yii::app()->db; //or whatever you called the db component in your main.php config file

//or: $connection=new CDbConnection($dsn,$username,$password); //for something custom


$command = $connection->createCommand('select * from table where param=:myparam');

$command->bindParam(':myparam',$myparamvalue);

$results = $command->queryAll(); //or ->execute(); if no results expected



If that’s what you’re looking for, check the Yii Definitive Guide section on Database Access Objects