0

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?

1

JDatabaseDriver::quoteName() is for quoting SQL identifiers. Use JDatabaseDriver:quote() to quote and escape strings.

$query->where($db->quoteName('element') . ' = ' . $db->quote('com_componentname'));
| improve this answer | |
  • unbelivable - thank you... did you know also why it had not worked like so: $query->where('element = com_componentname') ? it throws the same error... – Proximate Jul 9 at 10:01
  • 1
    Because com_componentname must be quoted. – Sharky Jul 9 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.