1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-19 04:41:25 +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

@@ -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;
}
}