Skip to Content

Welcome!

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.

This question has been flagged
As a moderator, you can either validate or reject this answer.
Accept Reject
24 Views

$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)

Avatar
Discard

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!