I am working on an active record class that is used to fetch records from a database which can contain joins.
Now, in my tests, I have had some data that has common column names that contain different values, but when I perform a mysql_fetch_assoc
function, it will only return one column of the common name, and can loose the remaining data. So, I am planning on replacing the mysql_fetch_assoc
with two loops, the first to get the column names (using mysql_fetch_column
), and the second to get the data (by having two loops, one nested in the other, that will fetch all the data, then put it together into an array that is returned) which would contain the column name and its parent table reference (or if the JOIN
has the AS
syntax).
But I am getting concerned that this might not be efficient, and might cost quite a lot of processing time, so could someone clarify the efficiency of both methods, or if there is a function like mysql_fetch_assoc
that would prepend the table reference of the column?
Additional
Although this is using the mysql library for PHP, I am considering extending the library in the future to by PDO driven, but I would be using a similar method to above (by using getColumnMeta
)