put sql_handle_data() into dbal and let DBMS who support this overwrite it. David: would be nice if you could have a look at it later. ;)

git-svn-id: file:///svn/phpbb/trunk@9285 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-01-21 17:04:17 +00:00
parent 9f060eba6e
commit 578beb75ef
3 changed files with 20 additions and 15 deletions

View file

@ -357,8 +357,20 @@ abstract class phpbb_dbal
* @param mixed $data The data to insert/update in an array (key == column, value == value) * @param mixed $data The data to insert/update in an array (key == column, value == value)
* @param string $where An optional where-statement * @param string $where An optional where-statement
* @access public * @access public
* @todo implement correctly by using types and only overwrite if DB supports prepared statements
*/ */
abstract public function sql_handle_data($type, $table, $data, $where = ''); public function sql_handle_data($type, $table, $data, $where = '')
{
if ($type === 'UPDATE')
{
$where = ($where) ? ' WHERE ' . $where : '';
$this->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', $data) . $where);
}
else
{
$this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $data));
}
}
/** /**
* DB-specific base query method. Called by {@link phpbb_dbal::sql_query() sql_query()}. * DB-specific base query method. Called by {@link phpbb_dbal::sql_query() sql_query()}.
@ -1080,7 +1092,10 @@ abstract class phpbb_dbal
if (!$this->return_on_error) if (!$this->return_on_error)
{ {
$message = 'SQL ERROR [ ' . $this->sql_layer . ' ]<br /><br />' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; $sql_message = $this->sql_error_returned['message'];
$sql_code = $this->sql_error_returned['code'];
$message = 'SQL ERROR [ ' . $this->sql_layer . ' ]' . (($sql_message) ? '<br /><br />' . $sql_message : '') . (($sql_code) ? ' [' . $sql_code . ']' : '');
// Show complete SQL error and path to administrators only // Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled // Additionally show complete error on installation or if extended debug mode is enabled

View file

@ -71,6 +71,7 @@ class phpbb_dbal_mysql extends phpbb_dbal
$this->user = $user; $this->user = $user;
$this->server = $server . (($port) ? ':' . $port : ''); $this->server = $server . (($port) ? ':' . $port : '');
$this->dbname = $database; $this->dbname = $database;
$this->port = $port;
$this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $password, $new_link) : @mysql_connect($this->server, $this->user, $password, $new_link); $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $password, $new_link) : @mysql_connect($this->server, $this->user, $password, $new_link);
@ -262,20 +263,10 @@ class phpbb_dbal_mysql extends phpbb_dbal
/** /**
* Handle data by using prepared statements. See {@link phpbb_dbal::sql_handle_data() sql_handle_data()} for details. * Handle data by using prepared statements. See {@link phpbb_dbal::sql_handle_data() sql_handle_data()} for details.
* @todo implement correctly by using types. ;)
*/
public function sql_handle_data($type, $table, $data, $where = '') public function sql_handle_data($type, $table, $data, $where = '')
{ {
if ($type === 'UPDATE')
{
$where = ($where) ? ' WHERE ' . $where : '';
$this->sql_query('UPDATE ' . $table . ' SET ' . $db->sql_build_array('UPDATE', $data) . $where);
}
else
{
$this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $data));
}
} }
*/
/** /**
* Build DB-specific query bits. See {@link phpbb_dbal::_sql_custom_build() _sql_custom_build()} for details. * Build DB-specific query bits. See {@link phpbb_dbal::_sql_custom_build() _sql_custom_build()} for details.

View file

@ -258,8 +258,6 @@ class phpbb_dbal_mysqli extends phpbb_dbal
/** /**
* Handle data by using prepared statements. See {@link phpbb_dbal::sql_handle_data() sql_handle_data()} for details. * Handle data by using prepared statements. See {@link phpbb_dbal::sql_handle_data() sql_handle_data()} for details.
* @todo implement correctly by using types. ;)
*/
public function sql_handle_data($type, $table, $data, $where = '') public function sql_handle_data($type, $table, $data, $where = '')
{ {
if ($type === 'INSERT') if ($type === 'INSERT')
@ -293,6 +291,7 @@ class phpbb_dbal_mysqli extends phpbb_dbal
mysqli_stmt_close($stmt); mysqli_stmt_close($stmt);
} }
*/
/** /**
* Build DB-specific query bits. See {@link phpbb_dbal::_sql_custom_build() _sql_custom_build()} for details. * Build DB-specific query bits. See {@link phpbb_dbal::_sql_custom_build() _sql_custom_build()} for details.