// Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select all articles for users who have a username which starts with 'a'. // Order it by the created date. // Note by putting 'a' as a second parameter will generate `#__content` AS `a` $query ->select($db->quoteName(array('a.*', 'b.username', 'b.name'))) ->from($db->quoteName('#__content', 'a')) ->join('INNER', $db->quoteName('#__users', 'b') . ' ON (' . $db->quoteName('a.created_by') . ' = ' . $db->quoteName('b.id') . ')') ->where($db->quoteName('b.username') . ' LIKE \'a%\'') ->order($db->quoteName('a.created') . ' DESC'); // echo sql query so you can see it and debug it ;) echo $db->replacePrefix( (string) $query ); // Reset the query using our newly populated query object. $db->setQuery($query); // Get array with information of the query $rows = $db->loadAssocList();
Вашият коментар