Populating an array with database column

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
FreeBaGeL
Forum Newbie
Posts: 17
Joined: Sun Jun 27, 2004 5:35 pm

Populating an array with database column

Post by FreeBaGeL »

I'm looking to populate an array in php with a column from my database for later use.

More specifically, I'm trying to make an array that will store all the ID's from a table in my database using an ORACLE database.

Here's what I've got so far, not sure why it's not working, but when I print back the values of the array they're all empty:

Code: Select all

$detailsID = OCIParse($connect, 'select DTL_ID from mgargano.events_dtl order by DTL_ID');
@OCIExecute($details, OCI_DEFAULT);

$arrID=array();
$i=0;

  while(OCIFetchInto($detailsID, $arrIDTemp, OCI_ASSOC+OCI_RETURN_NULLS))
  {
    $arrID[$i]=$arrIDTemp['DTL_ID'];
    $i++;
  }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it appears like it'd work.. looking at the documentation for the function... have you checked your error logs, maybe there's something you missed..
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

I'm not familiar with Oracle, but it seems to me you're parsing the statement into $detailsID but executing the $details statement.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

what if:

Code: Select all

$detailsID = OCIParse($connect, 'select DTL_ID from mgargano.events_dtl order by DTL_ID');
@OCIExecute($detailsID, OCI_DEFAULT);
$arrID=array();
while( list($tmp) = oci_fetch_row($detailsID) ) $arrID[] = $tmp;
Post Reply