Back to Installer class

Method parseQueries

public mixed
parseQueries
(\SimpleXMLElement $element)
Backward compatible method to parse through a queries element of the installation manifest file and take appropriate action.
Parameters
  • \SimpleXMLElement $element The XML node to process
Returns
  • mixed Number of queries processed or False on error
Since
  • 3.1
Class: Installer
Project: Joomla

Method parseQueries - Source code

/**
 * Backward compatible method to parse through a queries element of the
 * installation manifest file and take appropriate action.
 *
 * @param   \SimpleXMLElement  $element  The XML node to process
 *
 * @return  mixed  Number of queries processed or False on error
 *
 * @since   3.1
 */
public function parseQueries(\SimpleXMLElement $element)
{
    // Get the database connector object
    $db =& $this->_db;
    if (!$element || !\count($element->children())) {
        // Either the tag does not exist or has no children therefore we return zero files processed.
        return 0;
    }
    // Get the array of query nodes to process
    $queries = $element->children();
    if (\count($queries) === 0) {
        // No queries to process
        return 0;
    }
    $update_count = 0;
    // Process each query in the $queries array (children of $tagName).
    foreach ($queries as $query) {
        try {
            $db->setQuery($query)->execute();
        } catch (ExecutionFailureException $e) {
            Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $e->getMessage()), Log::WARNING, 'jerror');
            return false;
        }
        $update_count++;
    }
    return $update_count;
}