-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Add a table_name parameter to WHERE conditions #11
Comments
Well I'm curious....if you are specifying another table in your where statement, how are you writing your joins? I guess you would need to escape that as well if you're writing it in the join...not sure how, but I think I could scan for a |
Oh just normal join with $db = new mytable;
$db->join("table2", "mytable.key = table2.key");
$db->join("table3", "mytable.key = table3.key");
$db->eq("table2.field", "data1");
$db->eq("table3.field", "data2");
$db->order("table3.date");
$db->find(); so if using where.. $db = new mytable;
$db->join("table2", "mytable.key = table2.key");
$db->join("table3", "mytable.key = table3.key");
$db->where("table2.field = data1 and table3.field = data2");
$db->order("table3.date");
$db->find(); Then have to escape and blah blah the data. .. Something like that. The point is, it is much easier to read and understand now, so it really is nice.. Leave the where for the really complicated with multiple groups ( ) and such. Ha ha .. |
I believe this PR addresses what you're after. Check the new version! #16 |
Sorry, just now managing to have a look, seems to be working great, thank you! ^_^ |
I love the where conditions because it makes the query code so much easier to read. A single authorisation check joins 3 tables with conditions on two fields, sort order, blah blah.. Such a pain to read (and debug).
I wanted to
->eq("other_table.field", "value")
but it becomesmytable.other_table.field
in SQL .. So I have to write the->where()
by hand.. ha ha..So if
->eq()
and friends can either have an optional third param being the table name, or become smart enough not to insert the table name automatically when it has already been specified.. that would eliminate another big use of->where()
and->pdo->quote()
...Yes, I am a spoiled brat. 🤣
The text was updated successfully, but these errors were encountered: