1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-20 21:31:44 +02:00

Abstract DELETE, INSERT and INSERT+UPDATE

This commit is contained in:
Jakub Vrana
2013-07-05 09:04:06 -07:00
parent 5557adf289
commit 1f7fa44923
12 changed files with 155 additions and 90 deletions

View File

@@ -116,6 +116,8 @@ if (is_string($connection) || !$adminer->login($_GET["username"], get_session("p
exit;
}
$driver = new Min_Driver($connection);
$token = $_SESSION["token"]; ///< @var string CSRF protection
if ($auth && $_POST["token"]) {
$_POST["token"] = $token; // reset token after explicit login

View File

@@ -58,6 +58,7 @@ if (function_exists("set_magic_quotes_runtime")) { // removed in PHP 6
include "../adminer/include/lang.inc.php";
include "../adminer/lang/$LANG.inc.php";
include "../adminer/include/pdo.inc.php";
include "../adminer/include/driver.inc.php";
include "../adminer/drivers/sqlite.inc.php";
include "../adminer/drivers/pgsql.inc.php";
include "../adminer/drivers/oracle.inc.php";

View File

@@ -0,0 +1,43 @@
<?php
/*abstract*/ class Min_SQL {
var $_conn;
/** Create object for performing database operations
* @param Min_DB
*/
function Min_SQL($connection) {
$this->_conn = $connection;
}
/** Delete data from table
* @param string
* @param string " WHERE ..."
* @param int 0 or 1
* @return bool
*/
function delete($table, $queryWhere, $limit = 0) {
$query = "FROM " . table($table);
return queries("DELETE" . ($limit ? limit1($query, $queryWhere) : " $query$queryWhere"));
}
/** Insert data into table
* @param string
* @param array
* @return bool
*/
function insert($table, $set) {
return queries("INSERT INTO " . table($table) . ($set ? " (" . implode(", ", array_keys($set)) . ")\nVALUES (" . implode(", ", $set) . ")" : "DEFAULT VALUES"));
}
/** Insert or update data in table
* @param string
* @param array
* @param array columns in keys
* @return bool
*/
/*abstract*/ function insertUpdate($table, $set, $primary) {
return false;
}
}