Tell me, please, how to formulate a where in a SQL query so that only those rows are selected from the database with the value of 'section' equal to JURI (in the code *) is selected?

$db = JFactory::getDbo(); $query = $db->getQuery(TRUE); $section = JURI::base(TRUE); $query->select($db->quoteName(array('service', 'price', 'section'))); $query->from($db->quoteName('#__servicelist_')); $query->where('state = 1'); *$query->where($section->'section');* $query->order('service ASC'); $query->setlimit($params->get('section')); $db->setQuery($query); $result = $db->loadObjectList(); 
  • SELECT * FROM X3table WHERE section = 'JURI' you have already tried? - Vladimir Martyanov
  • Yes, I tried ... Writes: JURI object is not defined - Anton

2 answers 2

Two examples like this:

 $query->where($db->quoteName('section') . ' LIKE '. $db->quote('JURI')); 

or so:

 $query->where($db->quoteName('section') . '=' . $db->quote('JURI')); 
  • Denis, thank you! - Anton
  • @Anton, somehow came across this, not at all. - Denis Bubnov
  • and I am suffering with the output of data in the module ... if the problem is familiar, can I have another question? - Anton
  • @Anton, yes, let's remember, can - Denis Bubnov
  • after adding $ query-> where ($ db-> quoteName ('section'). '='. $ db-> quote ('JURI')); in helper, I got an error in default.php: Invalid argument supplied for foreach () and no data is output - Anton
 $query->where($db->quoteName('section') . '=' . $db->quote('JURI'));