Re: Fast/Easy way to extract a column from multi-dimensional array? [message #176839 is a reply to message #176831] |
Sat, 28 January 2012 08:49 |
Arno Welzel
Messages: 317 Registered: October 2011
Karma:
|
Senior Member |
|
|
John Drako, 2012-01-27 21:08:
> I'm looking for a way to get all the values from the column of a two
> dimensional array.
>
> For example, I have a query on a mysql database that returns 10 rows
> from the database, I would like to quickly (read low cpu load) extract
> all the IDs from all the rows returned to reuse in another query.
>
> So let's say I use:
>
> $arr = mysqli_fetch_all($result, MYSQLI_ASSOC);
>
> and $arr looks like:
>
> RecordID, name, last name, title
> RecordID, name, last name, title
> RecordID, name, last name, title
> RecordID, name, last name, title
> RecordID, name, last name, title
> RecordID, name, last name, title
> etc...
>
> I need to get all the 'RecordID' from the results to reuse in other
> queries.
[...]
> The site is very busy and CPU cycles count. I'm trying to avoid left
> joining three gigantic tables.
You always query *all* records with every request?
And do you already use some kind of byte code cache (XCache etc.)? This
also helps a lot to reduce the CPU load and the scripts can be executed
3-4 times faster, since the interpretation will only be done once and
further requests get served by the cached byte code.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
|
|
|