Mustafa_s
Member
Hi guys,
I'm new to databases and queries, I'm trying to learn how to display some results depending on a WHERE clause. My database structure is as follows. Basically put I'm telling it to get the comment that matches a variable:
When I run the following code I get the first result of comment "XXXXXXXXX", which works good but how can I get the last result instead? I've been hitting my head against the wall for the past 3 hours trying different combinations with no luck.
Any help or guidance is appreciated.
I'm new to databases and queries, I'm trying to learn how to display some results depending on a WHERE clause. My database structure is as follows. Basically put I'm telling it to get the comment that matches a variable:
When I run the following code I get the first result of comment "XXXXXXXXX", which works good but how can I get the last result instead? I've been hitting my head against the wall for the past 3 hours trying different combinations with no luck.
Code:
$id = '{rowid}';
$db = JFactory::getDbo();
$query = $db->getQuery( true );
$query->select('comment')->from('oyhvg_fabrik_comments')->where('row_id = ' . $db->quote($id));
$db->setQuery($query);
$comment = $db->loadresult();
return $comment;
Any help or guidance is appreciated.