Joomla Asked on September 5, 2021
I don’t understand the world right now. I try to make a simple query from the DB, but it fails with the message that the column is not known. I do not understand why Joomla! tries to see the value I am looking for as a column. This is my query:
$data = new stdClass();
try{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('*')
->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('element') . " = " . $db->quoteName('com_componentname'));
$db->setQuery($query);
$data->params = $db->loadObject();
}catch(Exception $e){
$data->query = $query->dump();
$data->errormsg = $e->getMessage();
}
return $data;
}else{
return false;
}
The response is:
'errormsg' => 'Unknown column 'com_componentname' in 'where clause'',
Why does Joomla! try to find the component name as a column? What I want:
Where componentname in Columns name from table extensions.
Or is there another / better way to load the parameters of a component within a module?
JDatabaseDriver::quoteName()
is for quoting SQL identifiers. Use JDatabaseDriver:quote()
to quote and escape strings.
$query->where($db->quoteName('element') . ' = ' . $db->quote('com_componentname'));
Correct answer by Sharky on September 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP