Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
需要对 Joomla 2.5 中的 MySQL 数据库进行一些操作。
使用的优缺点是什么:
JDatabase 或
从 PHP 直接进行 SQL 操作(使用 php 函数:mysql_connect、mysql_select_db、mysql_query、mysql_fetch_row)
使用 JDatabase 是毫无疑问的赢家,因为您必须以某种方式找到所有表的前缀。
使用 JDatabase,您#__可以自动访问此 Joomla 安装的前缀。(请记住,您可能在一个数据库上安装了各种 Joomla)。
#__
您必须做各种变通方法才能以其他方式找到它,或者您必须创建没有前缀的表,这对于 Joomla 代码也是一个坏主意。
我不同意 wiscWeb。这不是意见不同的问题。到目前为止,我见过的所有扩展都使用 JDatabase 类或扩展该类以实现自己的功能。(我已经看到了数百个扩展)