english/libraries/joomla/installer/installer.php
/**
	 * Method to extract the name of a discreet installation sql file from the installation manifest file.
	 *
	 * @param   object  $element	The XML node to process
	 *
	 * @return  mixed  Number of queries processed or False on error
	 * @since   11.1
	 */
Method to extract the name of a discreet installation sql file from the installation manifest file.
@param   object  $element    The XML node to process

@return  mixed  Number of queries processed or False on error
@since   11.1
Method to extract the name of a discreet installation sql file from the installation manifest file . @param object $element The XML node to process @return mixed Number of queries processed or False on error @since 11 . 1
public function parseSQLFiles($element)
	{
		if ( ! $element || ! count($element->children())) {
			return 0;
		}
		$queries = array();
		$db = & $this->_db;
		$dbDriver = strtolower($db->name);
		if ($dbDriver == 'mysqli') {
			$dbDriver = 'mysql';
		}
		$dbCharset = ($db->hasUTF()) ? 'utf8' : '';
		$sqlfile = '';
		foreach ($element->children() as $file)
		{
			$fCharset = (strtolower($file->attributes()->charset) == 'utf8') ? 'utf8' : '';
			$fDriver  = strtolower($file->attributes()->driver);
			if ($fDriver == 'mysqli') {
				$fDriver = 'mysql';
			}
			if ($fCharset == $dbCharset && $fDriver == $dbDriver) {
				$sqlfile = $this->getPath('extension_root') . '/' . $file;
				if (!file_exists($sqlfile)) {
					JError::raiseWarning(1,JText::sprintf('JLIB_INSTALLER_ERROR_SQL_FILENOTFOUND', $sqlfile));
					return false;
				}
				$buffer = file_get_contents($sqlfile);
				if ($buffer === false) {
					JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_SQL_READBUFFER'));
					return false;
				}
				jimport('joomla.installer.helper');
				$queries = JInstallerHelper::splitSql($buffer);
				if (count($queries) == 0) {
					return 0;
				}
				foreach ($queries as $query)
				{
					$query = trim($query);
					if ($query != '' && $query{0} != '#') {
						$db->setQuery($query);
						if (!$db->query()) {
							JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
							return false;
						}
					}
				}
			}
		}
		return (int) count($queries);
	}
public function parseSQLFiles ( $ element ) { if ( ! $ element || ! count ( $ element -> children ( ) ) ) { return 0 ; } $ queries = array ( ) ; $ db = & $ this -> _db ; $ dbDriver = strtolower ( $ db -> name ) ; if ( $ dbDriver == 'mysqli' ) { $ dbDriver = 'mysql' ; } $ dbCharset = ( $ db -> hasUTF ( ) ) ? 'utf8' : '' ; $ sqlfile = '' ; foreach ( $ element -> children ( ) as $ file ) { $ fCharset = ( strtolower ( $ file -> attributes ( ) -> charset ) == 'utf8' ) ? 'utf8' : '' ; $ fDriver = strtolower ( $ file -> attributes ( ) -> driver ) ; if ( $ fDriver == 'mysqli' ) { $ fDriver = 'mysql' ; } if ( $ fCharset == $ dbCharset && $ fDriver == $ dbDriver ) { $ sqlfile = $ this -> getPath ( 'extension_root' ) . '/' . $ file ; if ( ! file_exists ( $ sqlfile ) ) { JError :: raiseWarning ( 1 , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_SQL_FILENOTFOUND' , $ sqlfile ) ) ; return false ; } $ buffer = file_get_contents ( $ sqlfile ) ; if ( $ buffer === false ) { JError :: raiseWarning ( 1 , JText :: _ ( 'JLIB_INSTALLER_ERROR_SQL_READBUFFER' ) ) ; return false ; } jimport ( 'joomla.installer.helper' ) ; $ queries = JInstallerHelper :: splitSql ( $ buffer ) ; if ( count ( $ queries ) == 0 ) { return 0 ; } foreach ( $ queries as $ query ) { $ query = trim ( $ query ) ; if ( $ query != '' && $ query { 0 } != '#' ) { $ db -> setQuery ( $ query ) ; if ( ! $ db -> query ( ) ) { JError :: raiseWarning ( 1 , JText :: sprintf ( 'JLIB_INSTALLER_ERROR_SQL_ERROR' , $ db -> stderr ( true ) ) ) ; return false ; } } } } } return ( int ) count ( $ queries ) ; }
Method to extract the name of a discreet installation sql file from the installation manifest file.
Method to extract the name of a discreet installation sql file from the installation manifest file .
// The tag does not exist. // Initialise variables. // Get the name of the sql file to process // Check that sql files exists before reading. Otherwise raise error for rollback // Graceful exit and rollback if read not successful // Create an array of queries from the sql file // No queries to process // Process each query in the $queries array (split out of sql file).