can any one help me to use the mysql inbuilt function in cakePHP?????
A:
There is an example of how to use CONCAT in the book. I imagine you would be able to extend the syntax to use the other MySql functions as required.
Leo
2010-07-15 09:19:28
How can i add a virtual field on the fly ie., for a specific find only???
RSK
2010-07-15 09:30:18
The use of virtual fields is documented in the manual: http://book.cakephp.org/view/1608/Virtual-fields. They only appeared with version 1.3, however.I would probably opt for the $this->Model->query($yoursql);construct in this case - that's what it's there for.
Leo
2010-07-15 10:21:40
+3
A:
If you don't want to use
$this->Model->query($yoursql);
Then there's still another way for some mysql functions such as concat
,date_format
$this->Model->find($findtype,array('fields'=>array('concat (column1,column2,...) as con','date_format(...) as mydate'),'conditions'=>...));
SpawnCxy
2010-07-15 10:04:56
@SpawnCxy : why this statement `$competition = $this->Competition->find('first', 'fields' => array('(fee1+fee2) AS total','id','title' )));` results `$competition=array(0=>array('total' => 8),'Competition' => array('id' => 1,'title' => 'Competition1'));`
RSK
2010-09-01 06:11:38
@RSK,that's right.If you don't like this style,see http://nuts-and-bolts-of-cakephp.com/2008/09/29/dealing-with-calculated-fields-in-cakephps-find/
SpawnCxy
2010-09-01 09:58:11