aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r--phpBB/includes/db/db2.php31
-rw-r--r--phpBB/includes/db/firebird.php31
-rw-r--r--phpBB/includes/db/mssql.php15
-rw-r--r--phpBB/includes/db/mssql_odbc.php31
-rw-r--r--phpBB/includes/db/mysql.php15
-rw-r--r--phpBB/includes/db/mysqli.php35
-rw-r--r--phpBB/includes/db/oracle.php33
-rw-r--r--phpBB/includes/db/postgres.php35
-rw-r--r--phpBB/includes/db/sqlite.php15
9 files changed, 241 insertions, 0 deletions
diff --git a/phpBB/includes/db/db2.php b/phpBB/includes/db/db2.php
index 40909050c9..ecabc1c2e1 100644
--- a/phpBB/includes/db/db2.php
+++ b/phpBB/includes/db/db2.php
@@ -351,6 +351,37 @@ class dbal_db2 extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type == 'INSERT')
+ {
+ $stmt = db2_prepare($this->db_connect_id, "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES (" . substr(str_repeat('?, ', sizeof($data)) ,0, -1) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key)
+ {
+ $set[] = "$key = ?";
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = db2_prepare($this->db_connect_id, $query);
+ }
+
+ // get the stmt onto the top of the function arguments
+ array_unshift($data, $stmt);
+
+ call_user_func_array('db2_execute', $data);
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index afb649a4f4..48eb22046e 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -352,6 +352,37 @@ class dbal_firebird extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type == 'INSERT')
+ {
+ $stmt = ibase_prepare($this->db_connect_id, "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES (" . substr(str_repeat('?, ', sizeof($data)) ,0, -1) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key)
+ {
+ $set[] = "$key = ?";
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = ibase_prepare($this->db_connect_id, $query);
+ }
+
+ // get the stmt onto the top of the function arguments
+ array_unshift($data, $stmt);
+
+ call_user_func_array('ibase_execute', $data);
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index bf6190c79c..a6c8d26a4d 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -303,6 +303,21 @@ class dbal_mssql extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'UPDATE')
+ {
+ $this->sql_query('INSERT INTO ' . $table . ' ' .
+ $this->sql_build_array('INSERT', $data));
+ }
+ else
+ {
+ $this->sql_query('UPDATE ' . $table . '
+ SET ' . $db->sql_build_array('UPDATE', $data) .
+ $where);
+ }
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index de96939035..f79cd55af4 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -313,6 +313,37 @@ class dbal_mssql_odbc extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'INSERT')
+ {
+ $stmt = odbc_prepare($this->db_connect_id, "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES (" . substr(str_repeat('?, ', sizeof($data)) ,0, -1) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key)
+ {
+ $set[] = "$key = ?";
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = odbc_prepare($this->db_connect_id, $query);
+ }
+
+ // get the stmt onto the top of the function arguments
+ array_unshift($data, $stmt);
+
+ call_user_func_array('odbc_execute', $data);
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index 1014fe6780..1e32b8178a 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -284,6 +284,21 @@ class dbal_mysql extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'UPDATE')
+ {
+ $this->sql_query('INSERT INTO ' . $table . ' ' .
+ $this->sql_build_array('INSERT', $data));
+ }
+ else
+ {
+ $this->sql_query('UPDATE ' . $table . '
+ SET ' . $db->sql_build_array('UPDATE', $data) .
+ $where);
+ }
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index ffe39d63bf..48ea8d3c53 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -269,6 +269,41 @@ class dbal_mysqli extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'INSERT')
+ {
+ $stmt = mysqli_prepare($this->db_connect_id, "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES (" . substr(str_repeat('?, ', sizeof($data)) ,0, -1) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key)
+ {
+ $set[] = "$key = ?";
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = mysqli_prepare($this->db_connect_id, $query);
+ }
+
+ // get the stmt onto the top of the function arguments
+ array_unshift($data, $stmt);
+
+ call_user_func_array('mysqli_stmt_bind_param', $data);
+ mysqli_stmt_execute($stmt);
+
+ mysqli_stmt_close($stmt);
+ }
+
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index fc7d177377..09648d9841 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -514,6 +514,39 @@ class dbal_oracle extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'INSERT')
+ {
+ $stmt = oci_parse($this->db_connect_id, "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES (:" . implode(', :', array_keys($data)) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key)
+ {
+ $set[] = "$key = :$key";
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = oci_parse($this->db_connect_id, $query);
+ }
+
+ foreach ($data as $column => $value)
+ {
+ oci_bind_by_name($stmt, ":$column", $data[$column], -1);
+ }
+
+ oci_execute($stmt);
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index 0cce581558..f4237999ff 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -334,6 +334,41 @@ class dbal_postgres extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ // for now, stmtname is an empty string, it might change to something more unique in the future
+ if ($type === 'INSERT')
+ {
+ $stmt = pg_prepare($this->dbms_type, '', "INSERT INTO $table (". implode(', ', array_keys($data)) . ") VALUES ($" . implode(', $', range(1, sizeof($data))) . ')');
+ }
+ else
+ {
+ $query = "UPDATE $table SET ";
+
+ $set = array();
+ foreach (array_keys($data) as $key_id => $key)
+ {
+ $set[] = $key . ' = $' . $key_id;
+ }
+ $query .= implode(', ', $set);
+
+ if ($where !== '')
+ {
+ $query .= $where;
+ }
+
+ $stmt = pg_prepare($this->db_connect_id, '', $query);
+ }
+
+ // add the stmtname to the top
+ array_unshift($data, '');
+
+ // add the connection resource
+ array_unshift($data, $this->db_connect_id);
+
+ call_user_func_array('pg_execute', $data);
+ }
+
/**
* Build LIKE expression
* @access private
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 580a9fb1fb..64621496c4 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -258,6 +258,21 @@ class dbal_sqlite extends dbal
}
}
+ function sql_handle_data($type, $table, $data, $where = '')
+ {
+ if ($type === 'UPDATE')
+ {
+ $this->sql_query('INSERT INTO ' . $table . ' ' .
+ $this->sql_build_array('INSERT', $data));
+ }
+ else
+ {
+ $this->sql_query('UPDATE ' . $table . '
+ SET ' . $db->sql_build_array('UPDATE', $data) .
+ $where);
+ }
+ }
+
/**
* return sql error array
* @access private