简体   繁体   English

Joomla:JDatabase与来自PHP的直接SQL操作

[英]Joomla: JDatabase vs direct SQL manipulation from PHP

Need to do some manipulation to MySQL db in Joomla 2.5. 需要对Joomla 2.5中的MySQL数据库进行一些操作。

What are pros and cons for using : 什么是使用的利弊:

  • JDatabase or JDatabase或

  • direct SQL manipulation from PHP (with php functions: mysql_connect, mysql_select_db, mysql_query, mysql_fetch_row) 通过PHP直接进行SQL操作(具有php函数:mysql_connect,mysql_select_db,mysql_query,mysql_fetch_row)

Using the JDatabase is the hands down winner, since you have to find the prefix of all the tables somehow. 使用JDatabase无疑是成功的选择,因为您必须以某种方式找到所有表的前缀。

With JDatabase, you use #__ to automatically access the prefix of this Joomla installation. 使用JDatabase,您可以使用#__自动访问此Joomla安装的前缀。 (Remember that you may have various Joomla installations on one database). (请记住,您可能在一个数据库上安装了各种Joomla)。

You would have to do various work-arounds to find that in other ways, or you would have to create tables without a prefix which is also a bad idea with Joomla code. 您将不得不采取各种变通方法来以其他方式找到它,或者您必须创建不带前缀的表,这对于Joomla代码而言也是一个坏主意。

I disagree with wiscWeb. 我不同意wiscWeb。 This is not a matter of different opinions. 这不是不同意见的问题。 All extensions I have ever seen to the moment, use the JDatabase class or extend that class for their own functions. 到目前为止,我见过的所有扩展都使用JDatabase类或将该类扩展为自己的功能。 (and I have seen hundreds of extensions) (我已经看到了数百个扩展名)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM