Skip to content

Instantly share code, notes, and snippets.

@stevepiercy
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevepiercy/bc425f40f27f8c58c9e1 to your computer and use it in GitHub Desktop.
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
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