Page 1 of 1

String Manipulation before putting the data into mySQL

PostPosted: Thu Jul 15, 2010 12:36 am
by chichi
Hello, I would like to make a String Manipulation with PHP before putting the data into mySQL, is there an action before to use function for this? let me know.

I will use some of these functions of php:
nl2br()
strtolower()
etc.

chichi

Re: String Manipulation before putting the data into mySQL

PostPosted: Tue Jul 20, 2010 9:59 am
by shannah
What do you mean by string manipulation? PHP is a full-fledged programming language that allows you to manipulate strings any any way you can imagine. E.g. check out this page for a list of PHP's string functions:

http://php.net/manual/en/ref.strings.php

Re: String Manipulation before putting the data into mySQL

PostPosted: Wed Jul 21, 2010 7:37 am
by chichi
Thanks for the info, i have done string manipulations before but dont know how to use (call/trigger) them in xataface befor saving the string to the database. :P

Re: String Manipulation before putting the data into mySQL

PostPosted: Wed Jul 21, 2010 10:28 am
by shannah
You can make these transformations in the beforeSave() trigger (or beforeInsert() or beforeUpdate()).

In the delegate class for your table:

Code: Select all
function beforeSave(&$record){
    $record->setValue('myfield', strtolower($record->val('myfield')));
}

Re: String Manipulation before putting the data into mySQL

PostPosted: Thu Jul 22, 2010 2:59 am
by chichi
Knowing this, I see how much I can do with this awsome framework. Its so powerful and has more possibilities than I thought. Thanks for your help.