I have a table
id h_id t_id
1 3 1
2 3 2
3 3 3
4 4 2
5 4 3
id
is the primary key. I have not created a JTable
for this table. Now I want to delete rows by h_id
. Are there any method like which I can use without writing a sql DELETE query?
$db = JFactory::getDBO();
$row =& $this->getTable('tablename');
$row->delete($pk);
Any better solution will be greatly appreciated.
$db = & JFactory::getDBO();
$query = $db->getQuery(true);
$query->delete($db->nameQuote('tablename'));
$query->where($db->nameQuote('h_id').'='.$db->quote($key));
$db->setQuery($query);
$db->query();