We help IT Professionals succeed at work.

Joomla - creating extension, why sql statement doesn't work

Last Modified: 2009-09-19
I'm learning to create Joomla module. I'm following example in a book and after entering the codes, the sql statement just doesn't work. Any sql statement doesn't work. Does anyone has create any module or component and encounter the same problem?

Here is an easy example...this is the file...don't worry, it's easy to understand. I just want to know why any sql statement whether in this file or other files doesn't work. Perhaps please tell me why the below file sql statement doesn't work...thanks


//no direct access
defined('_JEXEC') or die('Restricted access');

$db =& JFactory::getDBO();
//Find all empty strings in metakey and metadesc and
//make sure the article is published (state=1)
$where = "(metakey = '' or metadesc = '') and state = 1 ";
$query = "SELECT id, title, metakey, metadesc"
      . " FROM #_content WHERE "
      . $where . " ORDER BY title ASC";
$db->setQuery( $query, 0);

<table class="adminlist">
      <td class="title">
            <strong><?php echo JText::_( 'Article' ); ?></strong>
      <td class="title">
            <strong><?php echo JText::_( 'Empty Description'); ?></strong>
      <td class="title">
            <strong><?php echo JText::_('Empty Keys'); ?></strong>

      //Make sure some rows match query
      if ($rows = $db->loadObjectList()) {
            foreach ($rows as $row) {
                  //Create url to allow user to click & jump to edit article
                  $url = "index.php?option=com_content&task=edit&".
                        "&id=" . $row->id;
                  //Check meta fields for record and set Yes/No value
                  if ($row->metadesc == "") $metad = JText::_("Yes");
                        else $metad = JText::_("No");
                  if ($row->metakey =="") $metak = JText::_("Yes");
                        else $metak = JText::_("No");
                  echo "<tr>";
                  //Place article title inside link
                  echo "<td><a href='". $url. "'>".
                        $row->title . "</a></td>";
                  //Display status of empty meta column
                  echo "<td>" . $metad . "</td>";
                  echo "<td>" . $metak . "</td>";
                  echo "</tr>";
      } else {
            //No articles with missing metadata found
            echo '<tr><td>None</td>';
            echo '<td>n/a</td>';
            echo '<td>n/a</td></tr>';


Watch Question

What Joomla version are you using ? 1.0 or 1.5 ?


I'm using 1.5

This one is on us!
(Get your first solution completely free - no credit card required)


let me check:)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.