DBAL Behavior

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
Thoul
Registered User
Posts: 810
Joined: Sun Jun 23, 2002 1:25 am
Location: USA
Contact:

DBAL Behavior

Post by Thoul » Sat Oct 12, 2002 3:00 pm

I need to know if there's an existing way to get a certain type of result from the DBAL. I'm trying to get a multiple row (but only one field per row) query result in the form of an one-dimensional array.

I know that using this:

Code: Select all

while ($row = $db->sql_fetchrow($sql))
{
	$voted_in[] = $row;
}
would give me an array like this:
  • $voted_in[0]['vote_id'] = 1
  • $voted_in[1]['vote_id'] = 2
  • $voted_in[2]['vote_id'] = 3
  • and so on...
I need a way to get the same array, but without the extra dimension in the array. The final array would turn out like this:
  • $voted_in[0] = 1
  • $voted_in[1] = 2
  • $voted_in[2] = 3
  • and so on...
Can this be done through the DBAL, and if so, what code would I need to use?

Flipper
Registered User
Posts: 436
Joined: Sun May 19, 2002 6:24 pm
Location: You are might here ->
Contact:

Post by Flipper » Sat Oct 12, 2002 9:30 pm

Try this:

Code: Select all

while ($row = $db->sql_fetchrow($sql)) 
{ 
   $voted_in[] = $row['vote_id']; 
}
Should work....(assuming that the vote_id is the column of data).
~Flipper
_____
Website - #Team.SoC - A Call of Duty clan
No PM/IM Support given :)

Thoul
Registered User
Posts: 810
Joined: Sun Jun 23, 2002 1:25 am
Location: USA
Contact:

Post by Thoul » Sun Oct 13, 2002 12:08 am

It looks like that's going to work perfectly. Thanks for the help! :)

Post Reply

Return to “[2.0.x] MOD Writers Discussion”