String Manipulation before putting the data into mySQL

A place for users and developers of the Xataface to discuss and receive support.

String Manipulation before putting the data into mySQL

Postby chichi » Thu Jul 15, 2010 12:36 am

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
chichi
 
Posts: 28
Joined: Fri Jul 09, 2010 3:05 am

Re: String Manipulation before putting the data into mySQL

Postby shannah » Tue Jul 20, 2010 9:59 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: String Manipulation before putting the data into mySQL

Postby chichi » Wed Jul 21, 2010 7:37 am

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
chichi
 
Posts: 28
Joined: Fri Jul 09, 2010 3:05 am

Re: String Manipulation before putting the data into mySQL

Postby shannah » Wed Jul 21, 2010 10:28 am

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')));
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: String Manipulation before putting the data into mySQL

Postby chichi » Thu Jul 22, 2010 2:59 am

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.
chichi
 
Posts: 28
Joined: Fri Jul 09, 2010 3:05 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved