note 47422 added to function.pg-fetch-object

From: Date: Tue, 16 Nov 2004 02:13:49 +0000
Subject: note 47422 added to function.pg-fetch-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-80572@lists.php.net to get a copy of this message
If you're wanting to use objects for your results, but are put off because you can't seem to apply a function to each field of the result (like stripslashes for example), try this code: <?php // Code to connect, do query etc etc... $row = pg_fetch_object($result); $vars = get_object_vars($row); foreach ( $vars as $key => $var ) { $row->{$key} = stripslashes($var); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.pg-fetch-object.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47422 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47422&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47422&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80572) next »