note 18110 deleted from function.odbc-fetch-row by danbrown

From: Date: Fri, 25 Jun 2010 13:35:33 +0000
Subject: note 18110 deleted from function.odbc-fetch-row by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170418@lists.php.net to get a copy of this message
Note Submitter: andrew at majiclab dot ab dot ca ---- 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

« previous php.notes (#170418) next »