I have a simple CodeIgniter Active record query to select an ID:
$q = $this -> db
-> select('id')
-> where('email', $email)
-> limit(1)
-> get('users');
How can I assign the above ID to a variable (eg. $id)
For example,
echo "ID is" . $id;
Thanks.
Thats quite simple. For example, here is a random code of mine:
This will return the “row” you selected as an array so you can access it like:
I also would strongly advise, not to chain the query like you do. Always have them separately like in my code, which is clearly a lot easier to read.
Please also note that if you specify the table name in from(), you call the get() function without a parameter.
If you did not understand, feel free to ask 🙂