note 22863 added to function.odbc-fetch-into
| From: | scott at abcoa dot com | Date: | Tue, 02 Jul 2002 15:41:00 +0000 |
| Subject: | note 22863 added to function.odbc-fetch-into | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32507@lists.php.net to get a copy of this message | ||
Using odbc_fetch_into() is becoming tiresome when it had to be changed in php version 4.0.5, 4.0.6
and 4.2.x. Also, using define() function no longer work well with 4.2.x, so define() is not
reliable for odbc_fetch_into(). Time on the job to keep up with the changes is ill-advised. Turned
out the better solution is to use odbc_fetch_array and not have to deal with the hassle of updating
the database, web pages, etc. It is worth the time in the long run.
--clip-- (old script)
define(CUSTOMER_ID,0);
define(CUSTOMER_NAME,1);
//$rows = 1;
if (odbc_fetch_row($result))
{
//odbc_fetch_into($result,1,&$user_detail); //php 4.0.5
//odbc_fetch_into($result,$row,$user_detail); //php 4.0.6
odbc_fetch_into($result,$user_detail,1); //php 4.2.x
echo $user_detail[CUSTOMER_ID];
} else {
echo "Failed!";
}
--clip--
//#########################################
--clip-- (new script)
if (odbc_fetch_row($result))
{
while($user_detail = odbc_fetch_array($result) ) {
echo $user_detail[CUSTOMER_ID];
}
} else {
echo "Failed!";
}
--clip--
This is pretty useful when we keep adding columns to the database table. If you combine two tables
and have two columns with the same column name, then you'll need to have two seperate array,
like $user_detail1 and $user_detail2, etc. Whatever you can come up with.
--
http://www.php.net/manual/en/function.odbc-fetch-into.php
http://master.php.net/manage/user-notes.php?action=edit+22863
http://master.php.net/manage/user-notes.php?action=delete+22863
http://master.php.net/manage/user-notes.php?action=reject+22863