Project

General

Profile

Bug #47090 ยป 47090_wip.diff

Work in Progress - Xavier Perseguers, 2013-04-10 09:13

View differences:

Classes/Database/DatabaseConnection.php
switch ($hType) {
case 'native':
$this->lastQuery = $this->INSERTquery($table, $fields_values, $no_quote_fields);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
if (is_string($this->lastQuery)) {
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$sqlResult = $link->query($this->lastQuery);
} else {
$sqlResult = mysql_query($this->lastQuery[0], $this->handlerInstance[$this->lastHandlerKey]['link']);
$sqlResult = $link->query($this->lastQuery[0]);
$new_id = $this->sql_insert_id();
$where = $this->cache_autoIncFields[$table] . '=' . $new_id;
foreach ($this->lastQuery[1] as $field => $content) {
mysql_query('UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where), $this->handlerInstance[$this->lastHandlerKey]['link']);
$link->query('UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where));
}
}
break;
......
public function exec_INSERTmultipleRows($table, array $fields, array $rows, $no_quote_fields = FALSE) {
if ((string) $this->handlerCfg[$this->lastHandlerKey]['type'] === 'native') {
$this->lastHandlerKey = $this->handler_getFromTableList($table);
mysql_query(
parent::INSERTmultipleRows($table, $fields, $rows, $no_quote_fields),
$this->handlerInstance[$this->lastHandlerKey]['link']
);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$link->query(parent::INSERTmultipleRows($table, $fields, $rows, $no_quote_fields));
}
foreach ($rows as $row) {
$fields_values = array();
......
switch ($hType) {
case 'native':
$this->lastQuery = $this->UPDATEquery($table, $where, $fields_values, $no_quote_fields);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
if (is_string($this->lastQuery)) {
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$sqlResult = $link->query($this->lastQuery);
} else {
$sqlResult = mysql_query($this->lastQuery[0], $this->handlerInstance[$this->lastHandlerKey]['link']);
$sqlResult = $link->query($this->lastQuery[0]);
foreach ($this->lastQuery[1] as $field => $content) {
mysql_query('UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where), $this->handlerInstance[$this->lastHandlerKey]['link']);
$link->query('UPDATE ' . $this->quoteFromTables($table) . ' SET ' . $this->quoteFromTables($field) . '=' . $this->fullQuoteStr($content, $table) . ' WHERE ' . $this->quoteWhereClause($where));
}
}
break;
......
switch ($hType) {
case 'native':
$this->lastQuery = $this->DELETEquery($table, $where);
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$sqlResult = $link->query($this->lastQuery);
break;
case 'adodb':
$this->lastQuery = $this->DELETEquery($table, $where);
......
list($select_fields, $from_table, $where_clause, $groupBy, $orderBy) = $this->compileSelectParameters($remappedParameters);
}
$this->lastQuery = $this->SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$this->resourceIdToTableNameMap[(string) $sqlResult] = $ORIG_tableName;
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$sqlResult = $link->query($this->lastQuery);
$this->resourceIdToTableNameMap[serialize($sqlResult)] = $ORIG_tableName;
break;
case 'adodb':
if ($limit != '') {
......
switch ($hType) {
case 'native':
$this->lastQuery = $this->TRUNCATEquery($table);
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$sqlResult = $link->query($this->lastQuery);
break;
case 'adodb':
$this->lastQuery = $this->TRUNCATEquery($table);
......
* Executes a prepared query.
*
* @param string $query The query to execute
* @param array $queryComponents The components of the query to execute
* @return pointer MySQL result pointer / DBAL object
* @param array $precompiledParts The components of the query to execute
* @return object MySQL result pointer / DBAL object
* @access protected This method may only be called by t3lib_db_PreparedStatement
*/
public function exec_PREPAREDquery($query, array $precompiledParts) {
......
switch ($precompiledParts['handler']) {
case 'native':
$this->lastQuery = $query;
$sqlResult = mysql_query($this->lastQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
$this->resourceIdToTableNameMap[(string) $sqlResult] = $precompiledParts['ORIG_tableName'];
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$sqlResult = $link->query($this->lastQuery);
$this->resourceIdToTableNameMap[serialize($sqlResult)] = $precompiledParts['ORIG_tableName'];
break;
case 'adodb':
$limit = $precompiledParts['LIMIT'];
......
switch ((string) $this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
if ($this->handlerInstance[$this->lastHandlerKey]['link']) {
$str = mysql_real_escape_string($str, $this->handlerInstance[$this->lastHandlerKey]['link']);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$str = $link->real_escape_string($str);
} else {
// link may be null when unit testing DBAL
$str = str_replace('\'', '\\\'', $str);
......
public function sql_error() {
switch ($this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$output = mysql_error($this->handlerInstance[$this->lastHandlerKey]['link']);
$output = $this->handlerInstance[$this->lastHandlerKey]['link']->error;
break;
case 'adodb':
$output = $this->handlerInstance[$this->lastHandlerKey]->ErrorMsg();
......
public function sql_errno() {
switch ($this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$output = mysql_errno($this->handlerInstance[$this->lastHandlerKey]['link']);
$output = $this->handlerInstance[$this->lastHandlerKey]['link']->errno();
break;
case 'adodb':
$output = $this->handlerInstance[$this->lastHandlerKey]->ErrorNo();
......
$output = 0;
switch ($handlerType) {
case 'native':
$output = mysql_num_rows($res);
$output = $res->num_rows;
break;
case 'adodb':
$output = method_exists($res, 'RecordCount') ? $res->RecordCount() : 0;
......
*/
public function sql_fetch_assoc($res) {
$output = FALSE;
$handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : (is_resource($res) ? 'native' : FALSE);
$handlerType = $res instanceof \mysqli_result ? 'native' : $res->TYPO3_DBAL_handlerType;
switch ($handlerType) {
case 'native':
$output = mysql_fetch_assoc($res);
$tableList = $this->resourceIdToTableNameMap[(string) $res];
$output = $res->fetch_assoc();
$tableList = $this->resourceIdToTableNameMap[serialize($res)];
// Reading list of tables from SELECT query:
break;
case 'adodb':
......
$handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
switch ($handlerType) {
case 'native':
$output = mysql_fetch_row($res);
$output = $res->sql_fetch_row();
break;
case 'adodb':
// Check if method exists for the current $res object.
......
if ($res === FALSE) {
return FALSE;
}
$handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
$handlerType = $res instanceof \mysqli_result ? 'native' : $res->TYPO3_DBAL_handlerType;
$output = TRUE;
switch ($handlerType) {
case 'native':
$output = mysql_free_result($res);
$output = $res->free();
break;
case 'adodb':
if (method_exists($res, 'Close')) {
......
$output = 0;
switch ($this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$output = mysql_insert_id($this->handlerInstance[$this->lastHandlerKey]['link']);
$output = $this->handlerInstance[$this->lastHandlerKey]['link']->insert_id;
break;
case 'adodb':
$output = $this->handlerInstance[$this->lastHandlerKey]->last_insert_id;
......
public function sql_affected_rows() {
switch ($this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$output = mysql_affected_rows();
$output = $this->handlerCfg[$this->lastHandlerKey]['link']->affected_rows;
break;
case 'adodb':
$output = $this->handlerInstance[$this->lastHandlerKey]->Affected_Rows();
......
*/
public function sql_data_seek($res, $seek) {
$output = TRUE;
$handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
$handlerType = $res instanceof \mysqli_result ? 'native' : $res->TYPO3_DBAL_handlerType;
switch ($handlerType) {
case 'native':
$output = mysql_data_seek($res, $seek);
$output = $res->data_seek($seek);
break;
case 'adodb':
$output = $res->Move($seek);
......
}
$handlerType = 'adodb';
} else {
$handlerType = is_object($res) ? $res->TYPO3_DBAL_handlerType : 'native';
$handlerType = $res instanceof \mysqli_result ? 'native' : $res->TYPO3_DBAL_handlerType;
}
$output = '';
switch ($handlerType) {
case 'native':
$output = mysql_field_type($res, $pointer);
$output = parent::sql_field_type($res, $pointer);
break;
case 'adodb':
if (is_string($pointer)) {
......
}
switch ($this->handlerCfg['_DEFAULT']['type']) {
case 'native':
$sqlResult = mysql_query($query, $this->handlerInstance['_DEFAULT']['link']);
$link = $this->handlerInstance['_DEFAULT']['link'];
$sqlResult = $link->query($query);
break;
case 'adodb':
$sqlResult = $this->handlerInstance['_DEFAULT']->Execute($query);
......
$dbArr = array();
switch ($this->handlerCfg['_DEFAULT']['type']) {
case 'native':
$db_list = mysql_list_dbs($this->link);
while ($row = mysql_fetch_object($db_list)) {
if ($this->sql_select_db($row->Database)) {
$dbArr[] = $row->Database;
}
}
$dbArr = parent::admin_get_dbs();
break;
case 'adodb':
// check needed for install tool - otherwise it will just die because the call to
......
// Getting real list of tables:
switch ($this->handlerCfg['_DEFAULT']['type']) {
case 'native':
$tables_result = mysql_query('SHOW TABLE STATUS FROM `' . TYPO3_db . '`', $this->handlerInstance['_DEFAULT']['link']);
$link = $this->handlerInstance['_DEFAULT']['link'];
$tables_result = $link->query('SHOW TABLE STATUS FROM `' . TYPO3_db . '`');
if (!$this->sql_error()) {
while ($theTable = $this->sql_fetch_assoc($tables_result)) {
$whichTables[$theTable['Name']] = $theTable;
......
$this->lastHandlerKey = $this->handler_getFromTableList($tableName);
switch ((string) $this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$columns_res = mysql_query('SHOW columns FROM ' . $tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);
while ($fieldRow = mysql_fetch_assoc($columns_res)) {
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$columns_res = $link->query('SHOW columns FROM ' . $tableName);
while ($fieldRow = $columns_res->fetch_assoc()) {
$output[$fieldRow['Field']] = $fieldRow;
}
break;
......
$this->lastHandlerKey = $this->handler_getFromTableList($tableName);
switch ((string) $this->handlerCfg[$this->lastHandlerKey]['type']) {
case 'native':
$keyRes = mysql_query('SHOW keys FROM ' . $tableName, $this->handlerInstance[$this->lastHandlerKey]['link']);
while ($keyRow = mysql_fetch_assoc($keyRes)) {
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
$keyRes = $link->query('SHOW keys FROM ' . $tableName);
while ($keyRow = $keyRes->fetch_assoc()) {
$output[] = $keyRow;
}
break;
......
case 'native':
// Compiling query:
$compiledQuery = $this->SQLparser->compileSQL($this->lastParsedAndMappedQueryArray);
$link = $this->handlerInstance[$this->lastHandlerKey]['link'];
if (in_array($this->lastParsedAndMappedQueryArray['type'], array('INSERT', 'DROPTABLE'))) {
return mysql_query($compiledQuery, $this->handlerInstance[$this->lastHandlerKey]['link']);
return $link->query($compiledQuery);
}
return mysql_query($compiledQuery[0], $this->handlerInstance[$this->lastHandlerKey]['link']);
return $link->query($compiledQuery[0]);
break;
case 'adodb':
// Compiling query:
......
}
switch ($handlerType) {
case 'native':
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']) {
$link = mysql_connect($cfgArray['config']['host'] . (isset($cfgArray['config']['port']) ? ':' . $cfgArray['config']['port'] : ''), $cfgArray['config']['username'], $cfgArray['config']['password'], TRUE);
} else {
$link = mysql_pconnect($cfgArray['config']['host'] . (isset($cfgArray['config']['port']) ? ':' . $cfgArray['config']['port'] : ''), $cfgArray['config']['username'], $cfgArray['config']['password']);
}
$link = parent::sql_pconnect($cfgArray['config']['host'] . (isset($cfgArray['config']['port']) ? ':' . $cfgArray['config']['port'] : ''), $cfgArray['config']['username'], $cfgArray['config']['password']);
// Set handler instance:
$this->handlerInstance[$handlerKey] = array('handlerType' => 'native', 'link' => $link);
// If link succeeded:
......
$this->link = $link;
}
// Select database as well:
if (mysql_select_db($cfgArray['config']['database'], $link)) {
if (parent::sql_select_db($cfgArray['config']['database'])) {
$output = TRUE;
}
$setDBinit = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, str_replace('\' . LF . \'', LF, $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']), TRUE);
foreach ($setDBinit as $v) {
if (mysql_query($v, $link) === FALSE) {
if ($this->link->query($v) === FALSE) {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('Could not initialize DB connection with query "' . $v . '".', 'Core', 3);
}
}
} else {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('Could not connect to MySQL server ' . $cfgArray['config']['host'] . ' with user ' . $cfgArray['config']['username'] . '.', 'Core', 4);
}
break;
case 'adodb':
    (1-1/1)