You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lucio 7:08 AM https://fatfreeframework.com/3.7/sql-mapper#exists
Return TRUE if a given field is defined
bool exists( string $key )
It does not check if given entry exists, only checks if column exists, isn't it?
To check if entry exists will I have to $db->exec('SELECT EXISTS (SELECT * FROM table WHERE column=value)')?
I'm using hashids generated in PHP and I need to check if it already exists... (edited)
ikkez:rocket: 7:43 AM
it only checks if a fields / column is existing in your mapper
Blue 7:46 AM
load() returns false if nothing fits the filter, but in case you don't want to instanciate a new mapper to load data into it, count($db->exec("SELECT * FROM table WHERE column=value")) would evaluate to 0 if no entry was found (edited)
n0nag0n 7:53 AM
Yeah it's checking if the key exists, not if it exists and is not empty
Lucio 7:58 AM @ikkez cleared. thank you 😉 @blue the thing is load() won't return at first find, it will scan the whole table I think. I'll also try findone().
So you're not in favor of EXISTS keyword? I've read somewhere it's faster...
Thank you the suggestions.
8:00 @n0nag0n Got it!
Blue 8:03 AM
I haven't used it a whole lot but in my mind, EXISTS isn't really appropriate to just find if there is a row that fits a certain criteria
8:04
It's more about joined tables, finding only the customers that have placed an order, that sort of thing
ikkez:rocket: 8:04 AM
to be more clear at this point, I think we could separate the datamapper and active record pattern within the mapper and create a repository / cellection model for find and single exist queries
n0nag0n 8:04 AM
I've been thinking about creating a collection when find() is used.
Blue 8:05 AM
I would love this. I don't like having a class with methods that return more of itself. I find it weird.
The text was updated successfully, but these errors were encountered:
Context conversation from Slack:
Lucio 7:08 AM
https://fatfreeframework.com/3.7/sql-mapper#exists
Return TRUE if a given field is defined
bool exists( string $key )
It does not check if given entry exists, only checks if column exists, isn't it?
To check if entry exists will I have to $db->exec('SELECT EXISTS (SELECT * FROM table WHERE column=value)')?
I'm using hashids generated in PHP and I need to check if it already exists... (edited)
ikkez:rocket: 7:43 AM
it only checks if a fields / column is existing in your mapper
Blue 7:46 AM
load() returns false if nothing fits the filter, but in case you don't want to instanciate a new mapper to load data into it, count($db->exec("SELECT * FROM table WHERE column=value")) would evaluate to 0 if no entry was found (edited)
n0nag0n 7:53 AM
Yeah it's checking if the key exists, not if it exists and is not empty
Lucio 7:58 AM
@ikkez cleared. thank you 😉
@blue the thing is load() won't return at first find, it will scan the whole table I think. I'll also try findone().
So you're not in favor of EXISTS keyword? I've read somewhere it's faster...
Thank you the suggestions.
8:00
@n0nag0n Got it!
Blue 8:03 AM
I haven't used it a whole lot but in my mind, EXISTS isn't really appropriate to just find if there is a row that fits a certain criteria
8:04
It's more about joined tables, finding only the customers that have placed an order, that sort of thing
ikkez:rocket: 8:04 AM
to be more clear at this point, I think we could separate the datamapper and active record pattern within the mapper and create a repository / cellection model for find and single exist queries
n0nag0n 8:04 AM
I've been thinking about creating a collection when find() is used.
Blue 8:05 AM
I would love this. I don't like having a class with methods that return more of itself. I find it weird.
The text was updated successfully, but these errors were encountered: