note 92380 added to function.odbc-longreadlen

From: Date: Wed, 22 Jul 2009 09:06:25 +0000
Subject: note 92380 added to function.odbc-longreadlen
Groups: php.notes 
Request: Send a blank email to php-notes+get-158570@lists.php.net to get a copy of this message
I've tried to use a suggestion in the first comment but that didn't actually worked as I would expect... I wanted to get all data no matter how big it is, but strange things happened and I finally found this solution (works fine at least for MS SQL 2000 for at least few MB of binary data): <?php // connection $link = odbc_connect($odbc_source_name, $user, $pass); // query (note - one row in this example) $sql = 'SELECT image_data_column FROM some_table WHERE record_id=1'; // run $result = odbc_exec ($link, $sql) if (!$result) { trigger_error ('[sql] exec: '.$sql, E_USER_ERROR); } // fetch settings odbc_binmode ($result, ODBC_BINMODE_PASSTHRU); odbc_longreadlen ($result, 0); // get contents ob_start(); // you would probably need to move this inside if you expect more rows while (odbc_fetch_row($result)) { odbc_result($result, 1); // this actually echos all of the contents of the image_data_column } odbc_free_result($result); $contents = ob_get_clean(); ?> ---- Server IP: 209.41.74.194 Probable Submitter: 83.15.121.158 ---- Manual Page -- http://www.php.net/manual/en/function.odbc-longreadlen.php Edit -- https://master.php.net/note/edit/92380 Del: integrated -- https://master.php.net/note/delete/92380/integrated Del: useless -- https://master.php.net/note/delete/92380/useless Del: bad code -- https://master.php.net/note/delete/92380/bad+code Del: spam -- https://master.php.net/note/delete/92380/spam Del: non-english -- https://master.php.net/note/delete/92380/non-english Del: in docs -- https://master.php.net/note/delete/92380/in+docs Del: other reasons-- https://master.php.net/note/delete/92380 Reject -- https://master.php.net/note/reject/92380 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158570) next »