跳至内容

欢迎!

This community is for professionals and enthusiasts of our products and services.
Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

此问题已终结
作为版主,您可以批准或拒绝该答案。
接受 拒绝
25 查看

$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query

->select($db->quoteName(array('custom_field_1')))

->from($db->quoteName('#__package_detail'))

->where($db->quoteName('name') .'='. $db->quote($package))

->order('ordering ASC');

$db->setQuery($query);

$expresult = $db->loadResult();


When you write sql query. You will always see quoteName from it right.

But, do you know what is the function of quoteName?

Below list can let you easily to understand it

quoteName = table name / column name

quote = variable (string)

int = number


So, when you target is table / column name, you should use quoteName

when you target is variable like string ($name), you should use quote

when you target is integer, you should use int


Below are the example:

$db->quoteName('name')

$db->quote('$name')

$db->int(2)

形象
丢弃

您的回复

请大家尽量给个实质性的回答。如果您想回答这个问题或发表评论,只需 使用评论工具。请记住,您可以随时修改您的答案。 - 不用重复回答同样的问题。另外,请不要忘记投票 - 它确实有助于选择最好的问题和答案!