RE: [PHP] Can I modify a MySQL object?
| From: | admin at buskirkgraphics dot com | Date: | Thu, 24 Mar 2011 02:30:06 +0000 |
| Subject: | RE: [PHP] Can I modify a MySQL object? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312029@lists.php.net to get a copy of this message | ||
Depends on where you want to manipulate.
In mysql you can
$query = 'select first_name as FNAME from tablename';
In this result you changed the column name from first_name to FNAME for the
result only.
In this example we can change the data returned in a particular field by
using an if statement.
$query = 'select IF(first_name='John','Big Bad John',first_name) FROM
tablename;
If the first_name field contains john we convert the name else just return
the name in the row.
Is that what you wanted?
Richard L. Buskirk
Senior Software Engineer/Systems Administrator
You can't grow your business with systems that are on life support...
-----Original Message-----
From: Brian Dunning [mailto:brian@briandunning.com]
Sent: Wednesday, March 23, 2011 8:07 PM
To: PHP-General List
Subject: [PHP] Can I modify a MySQL object?
Let's say I do a query:
$result = mysql_query("select * from tablename");
Is there some way I can manually update the contents of certain
columns/records in $result? I don't want to actually update MySQL, just the
results that I'm holding in memory for this script. Can I do it without
converting it to a regular array?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php