From 578beb75ef0b63680ffd9fdb216df87d4cf098d5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 21 Jan 2009 17:04:17 +0000 Subject: [PATCH] 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 --- phpBB/includes/db/dbal.php | 19 +++++++++++++++++-- phpBB/includes/db/mysql.php | 13 ++----------- phpBB/includes/db/mysqli.php | 3 +-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index e3588a9cd5..5e8e0c9fdd 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -357,8 +357,20 @@ abstract class phpbb_dbal * @param mixed $data The data to insert/update in an array (key == column, value == value) * @param string $where An optional where-statement * @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()}. @@ -1080,7 +1092,10 @@ abstract class phpbb_dbal if (!$this->return_on_error) { - $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

' . $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) ? '

' . $sql_message : '') . (($sql_code) ? ' [' . $sql_code . ']' : ''); // Show complete SQL error and path to administrators only // Additionally show complete error on installation or if extended debug mode is enabled diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 97a7c2a4ea..ac0384d523 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -71,6 +71,7 @@ class phpbb_dbal_mysql extends phpbb_dbal $this->user = $user; $this->server = $server . (($port) ? ':' . $port : ''); $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); @@ -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. - * @todo implement correctly by using types. ;) - */ 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. diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index acd789b086..386efdbff0 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -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. - * @todo implement correctly by using types. ;) - */ public function sql_handle_data($type, $table, $data, $where = '') { if ($type === 'INSERT') @@ -293,6 +291,7 @@ class phpbb_dbal_mysqli extends phpbb_dbal mysqli_stmt_close($stmt); } +*/ /** * Build DB-specific query bits. See {@link phpbb_dbal::_sql_custom_build() _sql_custom_build()} for details.