EFTEC / PdoOne

It is a simple library for PHP that simplify the use of the PDO extension.
https://www.eftec.cl
MIT License
109 stars 19 forks source link

toList($pdoMode), able to specify other PDO::FETCH_x modes? #5

Open wernerzj opened 2 months ago

wernerzj commented 2 months ago

First off, what a great and I argue under-utilized PDO class. I love the simplicity and chaining of the functions for very clean to write and read statements.

However, I'm running into a wall. I see it defaults to PDO::FETCH_ASSOC, but is there a way to expand this to all available PDO modes? I cannot pass a string because it's cast as an integer, which likewise passes this value to rungen().

I wouldn't say this is a bug, but more of a feature request, since PDO::FETCH_ASSOC seems to be the only method I can pull from. I enjoy using PDO::FETCH_OBJ, PDO::FETCH_KEY_PAIR, etc.

Lastly, I notice some issues with some of my statements when I assign my query a value, but when it ends with toList(), the query won't run and says there is syntax error, even without passing a specified $pdoMode, to the method.

Also, is there any why when assigning the result for it to not include all extraneous elements of the entire $pdoOne object (just the resultant query: array, obj, key_pair, etc.)?

Anyways, great work and I appreciate all the work you've put into this class. Simple, optimized, effective and much less code to ultimately write.

jorgecc commented 2 months ago

OK, I added an update: https://github.com/EFTEC/PdoOne?tab=readme-ov-file#5-run-a-query-with-a-different-mode

wernerzj commented 2 months ago

Thanks so much for taking the time to add this feature!

Does this mean I can break in and out of the mode, or is this settings accessed during run time? Also, it appears to leverage raw queries, which is probably fine for the few one-offs, but if so it appears I won't be able to method-chain with this particular method of switching modes, correct?

Anyways, I really appreciate all of your time and thanks again!

wernerzj commented 1 month ago

Sorry to bother you again, I'm not sure if the latest version works correctly. I keep getting this error, which leads to premature failure in executing the code:

Typed property eftec\PdoOne::$messageContainer must not be accessed before initialization

This appears to happen upon creating the database object, regardless of other factors.