english/libraries/joomla/database/database/mysqliimporter.php
/**
	 * Merges the incoming structure definition with the existing structure.
	 *
	 * @return  void
	 *
	 * @note    Currently supports XML format only.
	 * @since   11.1
	 * @throws  Exception on error.
	 * @todo    IF it is not in XML format, convert it first.
	 */
Merges the incoming structure definition with the existing structure.
@return  void

@note    Currently supports XML format only.
@since   11.1
@throws  Exception on error.
@todo    IF it is not in XML format, convert it first.
Merges the incoming structure definition with the existing structure . @return void @note Currently supports XML format only . @since 11 . 1 @throws Exception on error . @todo IF it is not in XML format convert it first .
protected function mergeStructure()
	{
		$prefix	= $this->db->getPrefix();
		$tables	= $this->db->getTableList();
		$result	= true;
		if ($this->from instanceof SimpleXMLElement) {
			$xml = $this->from;
		}
		else {
			$xml = new SimpleXMLElement($this->from);
		}
		$xmlTables	= $xml->xpath('database/table_structure');
		foreach ($xmlTables as $table)
		{
			$tableName = (string) $table['name'];
			$tableName = preg_replace('|^#__|', $prefix, $tableName);
			if (in_array($tableName, $tables)) {
				if ($queries = $this->getAlterTableSQL($xml->database->table_structure)) {
					foreach ($queries as $query)
					{
						$this->db->setQuery((string) $query);
						if (!$this->db->query()) {
							$this->addLog('Fail: '.$this->db->getQuery());
							throw new Exception($this->db->getErrorMsg());
						}
						else {
							$this->addLog('Pass: '.$this->db->getQuery());
						}
					}
				}
			}
			else {
				$sql = $this->xmlToCreate($table);
				$this->db->setQuery((string) $sql);
				if (!$this->db->query()) {
					$this->addLog('Fail: '.$this->db->getQuery());
					throw new Exception($this->db->getErrorMsg());
				}
				else {
					$this->addLog('Pass: '.$this->db->getQuery());
				}
			}
		}
	}
protected function mergeStructure ( ) { $ prefix = $ this -> db -> getPrefix ( ) ; $ tables = $ this -> db -> getTableList ( ) ; $ result = true ; if ( $ this -> from instanceof SimpleXMLElement ) { $ xml = $ this -> from ; } else { $ xml = new SimpleXMLElement ( $ this -> from ) ; } $ xmlTables = $ xml -> xpath ( 'database/table_structure' ) ; foreach ( $ xmlTables as $ table ) { $ tableName = ( string ) $ table [ 'name' ] ; $ tableName = preg_replace ( '|^#__|' , $ prefix , $ tableName ) ; if ( in_array ( $ tableName , $ tables ) ) { if ( $ queries = $ this -> getAlterTableSQL ( $ xml -> database -> table_structure ) ) { foreach ( $ queries as $ query ) { $ this -> db -> setQuery ( ( string ) $ query ) ; if ( ! $ this -> db -> query ( ) ) { $ this -> addLog ( 'Fail: ' . $ this -> db -> getQuery ( ) ) ; throw new Exception ( $ this -> db -> getErrorMsg ( ) ) ; } else { $ this -> addLog ( 'Pass: ' . $ this -> db -> getQuery ( ) ) ; } } } } else { $ sql = $ this -> xmlToCreate ( $ table ) ; $ this -> db -> setQuery ( ( string ) $ sql ) ; if ( ! $ this -> db -> query ( ) ) { $ this -> addLog ( 'Fail: ' . $ this -> db -> getQuery ( ) ) ; throw new Exception ( $ this -> db -> getErrorMsg ( ) ) ; } else { $ this -> addLog ( 'Pass: ' . $ this -> db -> getQuery ( ) ) ; } } } }
Merges the incoming structure definition with the existing structure.
Merges the incoming structure definition with the existing structure .
// Currently only support XML format anyway. // Initialise variables. // Get all the table definitions. // Convert the magic prefix into the real table name. // The table already exists. Now check if there is any difference. // Run the queries to upgrade the data structure. // This is a new table.