note 18110 added to function.odbc-fetch-row

From: Date: Thu, 10 Jan 2002 20:26:24 +0000
Subject: note 18110 added to function.odbc-fetch-row
Groups: php.notes 
Request: Send a blank email to php-notes+get-24638@lists.php.net to get a copy of this message
I made a slight modification to mchelen2@hknet.com's script. I was running into problems with rows that had either combination of ' or ". The add slashes will correct this problem. class fetch_object { function fetch( $re ) { if( !$re ) return null; $no_f = odbc_num_fields( $re ); if( odbc_fetch_row( $re ) ) { for( $i = 1; $i <= $no_f; $i++ ) { $fn = odbc_field_name( $re, $i ); $f_re = odbc_result( $re, $i ); $ff = "\$this->$fn = \"" . addslashes( $f_re ) . "\";"; eval( $ff ); } } else return null; } } function odbc_fetch_object( $result ) { $good = new fetch_object; $good->fetch( $result ); return $good; } Hope that helps -Andrew -- http://www.php.net/manual/en/function.odbc-fetch-row.php http://master.php.net/manage/user-notes.php?action=edit+18110 http://master.php.net/manage/user-notes.php?action=delete+18110 http://master.php.net/manage/user-notes.php?action=reject+18110

« previous php.notes (#24638) next »