|  | 
  geert van bommel - 2009-03-24 12:04:03I downloaded your class yesterday and I like it very much.  Today you've changed the class to add ability to use mysql functions.  Can you also provide an example use of this?
  Sandeep.C.R - 2009-03-25 04:22:42 - In reply to message 1 from geert van bommelGlad to know you liked the class.
 will explain the thing about using mysql functions with class.
 
 normaly if you give as
 
 $db->user(10)->joined_date='2009-10-10', it will expand to something like
 
 "update `user` set `joined_date`='2009-10-10' where `id`=10";
 
 But what if you want to use the NOW() mysql function to insert the current
 date in the column,we cannot give as  $db->user(10)->joined_date='NOW()'
 because it expands to
 "update `user` set `joined_date`='NOW()' where `id`=10";
 and the string 'NOW()' will get inserted instead of date.we should not put quotes around mysql functions.so instead of giving
 
 $db->user(10)->joined_date='NOW()';
 
 give as
 
 $db->user(10)->joined_date=(object)'NOW()';
 
 casting it to an object makes the class treat it specially and creates the query correctly,with out the quotes around the NOW().Same can be used while
 inserting,selecting ex
 
 $db->user=array('name'=>'User_1','joined_date'=>(object)"NOW()");
 or while selecting
 
 $name=$db->user->joined_date((object)"NOW()")->name;
 
 
 
  Sandeep.C.R - 2009-03-25 04:32:44 - In reply to message 1 from geert van bommelThere was a bug in the mysql functions section.Please download the updated class file.
 Thank You.
 Sandeep
 
  geert van bommel - 2009-03-25 19:11:27 - In reply to message 3 from Sandeep.C.Rsmart thinking.  I forgot about the special mysql functions.  I thought you meant to be able to add 'sql parts' in case the notation is not flexible enough like for group by, having, distinct,.... or so.
 Am I also right when I think you can't use order by on multiple columns?
 eg. $crdb->user->name('rlike','abc')->order_by()->no->desc_order_by()->key
 In that case ->order_by('no ASC, key DESC') would be handy.  Just an idea :-)
 
 I love the class, simply because it's light, clear and time-saving !
 
 
 
  Sandeep.C.R - 2009-03-26 07:46:57 - In reply to message 4 from geert van bommelI have added the order by and group by with mulitiple fields,though little different from the way you suggested.
 
 Instead of
 
 $crdb->user->name('rlike','abc')->order_by('no ASC, key DESC')
 
 give as
 
 $crdb->user->name('rlike','abc')->order_by()->fields('no','key DESC',...)
 
 hope this helps.
 
 
 
 
  geert van bommel - 2009-03-26 08:13:00 - In reply to message 5 from Sandeep.C.RWow, thanks for the quick adaption.  I absolutely love this class :-) |