09-22-2016, 01:11 AM
We are creating a wiki to better document using userspice.
That said, one thing to note...there is no obligation to use our database class. If you add your own (as long as you don't call it DB), it will work just fine (even if it is on the same page) with ours.
That said.
In the example above...
Note that you don't HAVE to assign a variable like $query in front of it. I tend to do it to make things a little more readable. Essentially, $db->query gives you the opportunity to run ANY query in mysql.
So....what do you do with that query? You have options. That entire query is now called $query.
You can get ALL the information back by
Or just the first response if you do
I think what you're asking though is how do you get the info inside back. It's super easy.
It is a good idea to test your results by doing
dump($x); //gives you the full list of everything you got back.
Then if you have a column named 'name', just do
$x->name;
To echo it you would do something like this.
Welcome to our website, <?=$x->name?>. It's great to have you.
That said, one thing to note...there is no obligation to use our database class. If you add your own (as long as you don't call it DB), it will work just fine (even if it is on the same page) with ours.
That said.
In the example above...
Code:
$query = $db->query(“SELECT * FROM camps WHERE director_id = ?”, array($director_id));
So....what do you do with that query? You have options. That entire query is now called $query.
You can get ALL the information back by
Code:
$x = $query->results();
Or just the first response if you do
Code:
$x = $query->first();
I think what you're asking though is how do you get the info inside back. It's super easy.
It is a good idea to test your results by doing
dump($x); //gives you the full list of everything you got back.
Then if you have a column named 'name', just do
$x->name;
To echo it you would do something like this.
Welcome to our website, <?=$x->name?>. It's great to have you.