PHP Classes

MetabaseQueryAll Function

Recommend this page to a friend!

      Metabase  >  All threads  >  MetabaseQueryAll Function  >  (Un) Subscribe thread alerts  
Subject:MetabaseQueryAll Function
Summary:Accessing columns through associative indexes
Messages:2
Author:Budaum Budaum Budaum
Date:2010-07-29 03:43:05
Update:2010-07-29 04:05:18
 

  1. MetabaseQueryAll Function   Reply   Report abuse  
Picture of Budaum Budaum Budaum Budaum Budaum Budaum - 2010-07-29 03:43:05
Hello.
I'm having problems to access the columns from an executed query with the function MetabaseQueryAll.
Here is the code:
//------------//
$query = "SELECT 1 as num";
MetabaseQueryAll($database, $query, &$all);
//------------//

When I try to access the column num ( $all[0]['num'] ), I can't, I can access it only through $all[0][0].
Is there some way to get the association names instead the column with this class? -> like mysql_fetch_assoc() function
I need to access the results through an associative array.

  2. Re: MetabaseQueryAll Function   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-07-29 04:05:18 - In reply to message 1 from Budaum Budaum Budaum
You can pass an array of types of columns and it will return associative arrays for the result rows. You do not even need to use the AS clause to make the server give a different name to the columns:

$query = "SELECT name from table";
$types = array(
'index_name'=>'text'
);
MetabaseQueryAll($database, $query, $all, $types);