qcubed / orm

QCubed ORM Repository
MIT License
1 stars 7 forks source link

replacing fetch_array with fetch_assoc #7

Open matthiaz opened 6 years ago

matthiaz commented 6 years ago

fetch_array returns an array that contains the results of fetch_row and fetch_assoc making it twice as big than need be. I don't think we have a case where we use both at the same time, so we shouldn't use fetch_array. We should use fetch_assoc and where we can fetch_row.

spekary commented 6 years ago

This appears to be failing. fetch_array may be used for performance reasons. Database result unpacking is a performance bottleneck. fetch_array avoids the step where the database driver has to query for the names of the database fields and then associate those names with the results.

What problem are you trying to solve?

matthiaz commented 6 years ago

Not really solving a problem. Just noticed this when doing something else.

fetch_row would be faster , I know, but that is not what I'm proposing. I'm proposing swapping out fetch_array with fetch_assoc since we're not using the numeric keys anyway (unless I'm mistaken).

according to : http://php.net/manual/en/mysqli-result.fetch-array.php

/ associative array returns both numeric keys and column names/ $row = $result->fetch_array(MYSQLI_BOTH); printf ("%s (%s)\n", $row[0], $row["CountryCode"]);

/ return only column names/ $row = $result->fetch_assoc(MYSQLI_ASSOC); printf ("%s (%s)\n", $row["Name"], $row["CountryCode"]);

2018-05-31 16:27 GMT+02:00 Shannon notifications@github.com:

This appears to be failing. fetch_array may be used for performance reasons. Database result unpacking is a performance bottleneck. fetch_array avoids the step where the database driver has to query for the names of the database fields and then associate those names with the results.

What problem are you trying to solve?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qcubed/orm/pull/7#issuecomment-393548683, or mute the thread https://github.com/notifications/unsubscribe-auth/ADXnE7Zw1CeFR_7ax4EMlDacg2dqzM96ks5t3_3vgaJpZM4UU-bA .

matthiaz commented 6 years ago

@spekary it's failing on hhvm. But I don't understand why. Can you see why this is happening?

spekary commented 6 years ago

Its saying CodeGen is undefined. Its probably a case problem. Maybe it should be Codegen?