If I have this code (which is from their docs)
$query = DB::query(Database::SELECT, 'SELECT * FROM users WHERE username = :user');
$query->param(':user', 'john');
$query->execute();
How would I access the actual data returned from this?
I am looking for an associate array containing $array['username'] and whatever other columns are on the users table.
I have tried:
#1
echo $query->execute();
#2
$row = $query->execute();
echo $row['username'];
#3
$query->fetch();
None of which work. What am I missing?
Database_Resultobject is a wrapper for database row list. Usually it is used with foreach:If you are expecting only one row (its your question as I understand), use
current():Note that
Database_Resultcan be used as a simple array, socurrent(),foreach(),count()and other array functions are available.PS. Here is a link for kohana 2.3 docs, using DB Queries is the same.