About Store Forum Documentation Contact



Post Reply 
SQL::getRowsCols
Author Message
yvanvds Offline
Member

Post: #1
SQL::getRowsCols
Another small suggestion :-)

In the SQL::getRowsCols function, esenthel always requires a where clause. This is not always needed because you might want to retrieve all values in a particular column. For example something like this:

PHP Code:
SQL.getRowsCols("accounts"SMemc<Str>().New() = "accountName"); 

.. wont work because there's an empty condition. I can solve this by using tricks like:

PHP Code:
SQL.getRowsCols("accounts""ID > -1"Memc<Str>().New() = "accountName"); 

or perhaps:

PHP Code:
SQL.getRowsCols("accounts""accountName LIKE '_'"Memc<Str>().New() = "accountName"); 

but both are non optimal because they have to check every line and see if it fits the condition. (Or are there optimisations at DB level I'm not aware of?)

I think there would be a speed benefit if you drop the entire where clause when the condition is an empty string.

Regards,

yvan
10-16-2014 04:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: SQL::getRowsCols
Thank you for your suggestion smile

I've just commited these 2 changes related to your request:
Quote:-added new SQL.getAllRowsCols method
-SQL.getRows,getRowsCols and getRowsNum can now have specified "condition=S" which will ignore the condition
You can now specify "S" for the condition, or use *all* named method.

I think you can also specify "true" string as the condition to make it always work, however I haven't tested it.

BTW. If you're doing things like Memc<Str>().New() = "accountName"
then you actually pass a "Str" object, and not "Memc" object.
This is because you're using operator "=" which returns Str.
This works fine because Memp is smart enough to accept single objects, in this case Str parameter as well.
So you can just pass "accountName" without using the Memc.. thing.
If you however wish to pass Memc, for example to include multiple elements, you can do it that way:
Memc<Str>().add("first").add("second")
10-17-2014 02:50 AM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #3
RE: SQL::getRowsCols
Thanks once again! Great support as usual smile
10-20-2014 07:15 PM
Find all posts by this user Quote this message in a reply
Post Reply