Last active
August 29, 2015 14:07
-
-
Save stevepiercy/bc425f40f27f8c58c9e1 to your computer and use it in GitHub Desktop.
How to use Lasso ds type to return the found count of a result set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local(d) = ds(::mysqlds,'localhost',::database.table,'username','password') | |
local(sql) = ` | |
SELECT * | |
FROM table | |
WHERE id > 0; | |
` | |
local(rs) = #d->sql(#sql)->results | |
if(#rs->size > 0) => { | |
if (#rs->get(1)->found_count) => {^ | |
'at least 1 record' | |
else | |
'no records' | |
^} | |
} | |
// or for brevity | |
if (#d->sql(#sql)->found) => {^ | |
'at least 1 record' | |
else | |
'no records' | |
^} | |
// now with local | |
local(r) = #d->sql(#sql) | |
if (#r->found) => {^ | |
'at least 1 record' | |
// do stuff with #r | |
else | |
'no records' | |
^} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment