如何删除 Joomla 表格中的一行?

发布于 2024-12-20 06:26:24 字数 367 浏览 4 评论 0原文

我有一个表

id h_id t_id
 1   3   1
 2   3   2
 3   3   3
 4   4   2
 5   4   3

id 是主键。我还没有为此表创建JTable。现在我想按 h_id 删除行。有没有类似的方法可以使用而无需编写 sql DELETE 查询?

$db = JFactory::getDBO();
$row =& $this->getTable('tablename');
$row->delete($pk);

任何更好的解决方案将不胜感激。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戒ㄋ 2024-12-27 06:26:24
         $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(); 
         $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(); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文