This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/core/database.class.php

787 lines
18 KiB
PHP
Raw Normal View History

<?php
/** @privatesection */
2009-07-19 07:38:13 +00:00
// Querylet {{{
class Querylet {
/** @var string */
public $sql;
/** @var array */
public $variables;
2009-01-04 19:18:37 +00:00
/**
* @param string $sql
* @param array $variables
*/
2014-03-22 09:00:59 +00:00
public function __construct($sql, $variables=array()) {
$this->sql = $sql;
$this->variables = $variables;
}
/**
* @param \Querylet $querylet
*/
public function append($querylet) {
assert(!is_null($querylet));
$this->sql .= $querylet->sql;
$this->variables = array_merge($this->variables, $querylet->variables);
}
/**
* @param string $sql
*/
public function append_sql($sql) {
$this->sql .= $sql;
}
/**
* @param mixed $var
*/
public function add_variable($var) {
$this->variables[] = $var;
}
}
class TagQuerylet {
2014-04-29 00:37:31 +00:00
/** @var string */
public $tag;
/** @var bool */
public $positive;
2014-04-29 00:37:31 +00:00
/**
* @param string $tag
* @param bool $positive
*/
2014-03-22 09:00:59 +00:00
public function __construct($tag, $positive) {
$this->tag = $tag;
$this->positive = $positive;
}
}
class ImgQuerylet {
2014-04-29 00:37:31 +00:00
/** @var \Querylet */
public $qlet;
/** @var bool */
public $positive;
2014-04-29 00:37:31 +00:00
/**
* @param \Querylet $qlet
* @param bool $positive
*/
2014-03-22 09:00:59 +00:00
public function __construct($qlet, $positive) {
$this->qlet = $qlet;
$this->positive = $positive;
}
}
// }}}
2009-01-19 18:18:23 +00:00
// {{{ db engines
class DBEngine {
/** @var null|string */
public $name = null;
2009-01-22 12:05:55 +00:00
2014-04-29 00:37:31 +00:00
/**
* @param \PDO $db
*/
public function init($db) {}
2009-01-22 13:53:30 +00:00
/**
* @param string $scoreql
* @return string
*/
2009-12-30 08:54:04 +00:00
public function scoreql_to_sql($scoreql) {
return $scoreql;
}
/**
* @param string $name
* @param string $data
* @return string
*/
2009-01-22 12:05:55 +00:00
public function create_table_sql($name, $data) {
2012-01-11 20:57:00 +00:00
return 'CREATE TABLE '.$name.' ('.$data.')';
2009-01-22 12:05:55 +00:00
}
}
class MySQL extends DBEngine {
/** @var string */
public $name = "mysql";
2014-04-29 00:37:31 +00:00
/**
* @param \PDO $db
*/
2009-01-22 12:05:55 +00:00
public function init($db) {
2012-06-26 22:46:38 +00:00
$db->exec("SET NAMES utf8;");
}
2009-01-22 12:05:55 +00:00
/**
* @param string $data
* @return string
*/
2009-12-30 08:54:04 +00:00
public function scoreql_to_sql($data) {
$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY auto_increment", $data);
2012-07-28 10:57:22 +00:00
$data = str_replace("SCORE_INET", "VARCHAR(45)", $data);
$data = str_replace("SCORE_BOOL_Y", "'Y'", $data);
$data = str_replace("SCORE_BOOL_N", "'N'", $data);
2009-01-22 12:14:38 +00:00
$data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data);
2009-07-15 22:29:14 +00:00
$data = str_replace("SCORE_DATETIME", "DATETIME", $data);
2009-01-22 12:12:15 +00:00
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
$data = str_replace("SCORE_STRNORM", "", $data);
$data = str_replace("SCORE_ILIKE", "LIKE", $data);
2009-12-30 08:54:04 +00:00
return $data;
}
/**
* @param string $name
* @param string $data
* @return string
*/
2009-12-30 08:54:04 +00:00
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
2011-07-14 09:12:39 +00:00
$ctes = "ENGINE=InnoDB DEFAULT CHARSET='utf8'";
2012-01-11 20:57:00 +00:00
return 'CREATE TABLE '.$name.' ('.$data.') '.$ctes;
2009-01-22 12:05:55 +00:00
}
}
class PostgreSQL extends DBEngine {
/** @var string */
public $name = "pgsql";
2014-04-29 00:37:31 +00:00
/**
* @param \PDO $db
*/
2012-01-31 12:16:19 +00:00
public function init($db) {
2012-06-26 22:46:38 +00:00
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
2012-01-31 12:16:19 +00:00
}
/**
* @param string $data
* @return string
*/
2009-12-30 08:54:04 +00:00
public function scoreql_to_sql($data) {
$data = str_replace("SCORE_AIPK", "SERIAL PRIMARY KEY", $data);
$data = str_replace("SCORE_INET", "INET", $data);
$data = str_replace("SCORE_BOOL_Y", "'t'", $data);
$data = str_replace("SCORE_BOOL_N", "'f'", $data);
2009-01-22 12:14:38 +00:00
$data = str_replace("SCORE_BOOL", "BOOL", $data);
2009-07-15 22:29:14 +00:00
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
2012-07-28 11:07:46 +00:00
$data = str_replace("SCORE_NOW", "current_timestamp", $data);
$data = str_replace("SCORE_STRNORM", "lower", $data);
$data = str_replace("SCORE_ILIKE", "ILIKE", $data);
2009-12-30 08:54:04 +00:00
return $data;
}
/**
* @param string $name
* @param string $data
* @return string
*/
2009-12-30 08:54:04 +00:00
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
2012-01-11 20:57:00 +00:00
return 'CREATE TABLE '.$name.' ('.$data.')';
2009-01-22 13:53:30 +00:00
}
}
// shimmie functions for export to sqlite
function _unix_timestamp($date) { return strtotime($date); }
function _now() { return date("Y-m-d h:i:s"); }
function _floor($a) { return floor($a); }
function _log($a, $b=null) {
if(is_null($b)) return log($a);
else return log($a, $b);
}
function _isnull($a) { return is_null($a); }
function _md5($a) { return md5($a); }
function _concat($a, $b) { return $a . $b; }
function _lower($a) { return strtolower($a); }
2009-01-22 13:53:30 +00:00
class SQLite extends DBEngine {
/** @var string */
public $name = "sqlite";
2009-01-22 13:53:30 +00:00
2014-04-29 00:37:31 +00:00
/**
* @param \PDO $db
*/
2009-01-22 15:08:37 +00:00
public function init($db) {
ini_set('sqlite.assoc_case', 0);
2012-06-26 22:46:38 +00:00
$db->exec("PRAGMA foreign_keys = ON;");
$db->sqliteCreateFunction('UNIX_TIMESTAMP', '_unix_timestamp', 1);
$db->sqliteCreateFunction('now', '_now', 0);
$db->sqliteCreateFunction('floor', '_floor', 1);
$db->sqliteCreateFunction('log', '_log');
$db->sqliteCreateFunction('isnull', '_isnull', 1);
$db->sqliteCreateFunction('md5', '_md5', 1);
$db->sqliteCreateFunction('concat', '_concat', 2);
$db->sqliteCreateFunction('lower', '_lower', 1);
2009-01-22 15:08:37 +00:00
}
/**
* @param string $data
* @return string
*/
2012-06-26 23:08:51 +00:00
public function scoreql_to_sql($data) {
2009-01-22 13:53:30 +00:00
$data = str_replace("SCORE_AIPK", "INTEGER PRIMARY KEY", $data);
$data = str_replace("SCORE_INET", "VARCHAR(45)", $data);
2009-01-22 13:53:30 +00:00
$data = str_replace("SCORE_BOOL_Y", "'Y'", $data);
$data = str_replace("SCORE_BOOL_N", "'N'", $data);
2009-01-22 15:08:37 +00:00
$data = str_replace("SCORE_BOOL", "CHAR(1)", $data);
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
$data = str_replace("SCORE_STRNORM", "lower", $data);
$data = str_replace("SCORE_ILIKE", "LIKE", $data);
return $data;
2012-06-26 23:08:51 +00:00
}
/**
* @param string $name
* @param string $data
* @return string
*/
2012-06-26 23:08:51 +00:00
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
2009-01-22 15:08:37 +00:00
$cols = array();
$extras = "";
foreach(explode(",", $data) as $bit) {
$matches = array();
2009-01-22 15:51:50 +00:00
if(preg_match("/INDEX\s*\((.*)\)/", $bit, $matches)) {
2009-01-22 15:08:37 +00:00
$col = $matches[1];
2012-06-26 22:46:38 +00:00
$extras .= "CREATE INDEX {$name}_{$col} on {$name}({$col});";
2009-01-22 15:08:37 +00:00
}
else {
$cols[] = $bit;
}
}
$cols_redone = implode(", ", $cols);
2012-06-26 22:46:38 +00:00
return "CREATE TABLE $name ($cols_redone); $extras";
}
}
2009-01-19 18:18:23 +00:00
// }}}
// {{{ cache engines
interface CacheEngine {
2009-01-20 10:47:20 +00:00
public function get($key);
2009-01-20 11:54:43 +00:00
public function set($key, $val, $time=0);
2009-01-20 10:47:20 +00:00
public function delete($key);
2009-01-20 11:54:43 +00:00
public function get_hits();
public function get_misses();
2009-01-20 10:47:20 +00:00
}
class NoCache implements CacheEngine {
public function get($key) {return false;}
2009-01-20 11:54:43 +00:00
public function set($key, $val, $time=0) {}
2009-01-20 10:47:20 +00:00
public function delete($key) {}
2009-01-20 11:54:43 +00:00
public function get_hits() {return 0;}
public function get_misses() {return 0;}
2009-01-19 18:18:23 +00:00
}
2010-02-01 16:17:00 +00:00
class MemcacheCache implements CacheEngine {
/** @var \Memcache|null */
public $memcache=null;
/** @var int */
private $hits=0;
/** @var int */
private $misses=0;
2009-01-20 11:54:43 +00:00
/**
* @param string $args
*/
2009-01-20 10:47:20 +00:00
public function __construct($args) {
2010-07-30 20:28:31 +00:00
$hp = explode(":", $args);
2010-05-15 13:53:37 +00:00
if(class_exists("Memcache")) {
$this->memcache = new Memcache;
@$this->memcache->pconnect($hp[0], $hp[1]);
}
else {
print "no memcache"; exit;
}
2009-01-19 18:18:23 +00:00
}
/**
* @param string $key
* @return array|bool|string
*/
2009-01-20 10:47:20 +00:00
public function get($key) {
2009-01-19 18:18:23 +00:00
assert(!is_null($key));
2014-11-26 13:07:30 +00:00
$val = $this->memcache->get($key);
2013-07-05 21:19:12 +00:00
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
2014-11-26 13:07:30 +00:00
$hit = $val === false ? "miss" : "hit";
file_put_contents("data/cache.log", "Cache $hit: $key\n", FILE_APPEND);
2013-07-05 21:19:12 +00:00
}
if($val !== false) {
2009-01-20 10:47:20 +00:00
$this->hits++;
2009-01-19 18:18:23 +00:00
return $val;
}
else {
2009-01-20 10:47:20 +00:00
$this->misses++;
2009-01-19 18:18:23 +00:00
return false;
}
}
/**
* @param string $key
* @param mixed $val
* @param int $time
*/
2009-01-20 10:47:20 +00:00
public function set($key, $val, $time=0) {
2009-01-19 18:18:23 +00:00
assert(!is_null($key));
2009-01-20 10:47:20 +00:00
$this->memcache->set($key, $val, false, $time);
2009-01-19 18:18:23 +00:00
}
/**
* @param string $key
*/
2009-01-20 10:47:20 +00:00
public function delete($key) {
2009-01-19 18:18:23 +00:00
assert(!is_null($key));
2009-01-20 10:47:20 +00:00
$this->memcache->delete($key);
2009-01-19 18:18:23 +00:00
}
2009-01-20 11:54:43 +00:00
/**
* @return int
*/
2009-01-20 11:54:43 +00:00
public function get_hits() {return $this->hits;}
/**
* @return int
*/
2009-01-20 11:54:43 +00:00
public function get_misses() {return $this->misses;}
2009-01-19 18:18:23 +00:00
}
class APCCache implements CacheEngine {
var $hits=0, $misses=0;
public function __construct($args) {
// $args is not used, but is passed in when APC cache is created.
}
public function get($key) {
assert(!is_null($key));
$val = apc_fetch($key);
if($val) {
$this->hits++;
return $val;
}
else {
$this->misses++;
return false;
}
}
public function set($key, $val, $time=0) {
assert(!is_null($key));
apc_store($key, $val, $time);
}
public function delete($key) {
assert(!is_null($key));
apc_delete($key);
}
public function get_hits() {return $this->hits;}
public function get_misses() {return $this->misses;}
}
2009-01-19 18:18:23 +00:00
// }}}
/** @publicsection */
2009-07-19 07:38:13 +00:00
/**
2009-01-03 20:32:57 +00:00
* A class for controlled database access
*/
class Database {
2009-07-19 07:38:13 +00:00
/**
* The PDO database connection object, for anyone who wants direct access.
* @var null|PDO
2009-07-19 07:38:13 +00:00
*/
private $db = null;
public $dbtime = 0.0;
2009-07-19 07:38:13 +00:00
/**
* Meta info about the database engine.
* @var DBEngine|null
2009-07-19 07:38:13 +00:00
*/
private $engine = null;
2009-07-19 07:38:13 +00:00
/**
* The currently active cache engine.
* @var CacheEngine|null
2009-07-19 07:38:13 +00:00
*/
public $cache = null;
/**
* A boolean flag to track if we already have an active transaction.
* (ie: True if beginTransaction() already called)
*
* @var bool
*/
public $transaction = false;
2014-02-22 20:42:09 +00:00
2009-07-19 07:38:13 +00:00
/**
* For now, only connect to the cache, as we will pretty much certainly
* need it. There are some pages where all the data is in cache, so the
* DB connection is on-demand.
*/
2014-03-22 09:00:59 +00:00
public function __construct() {
$this->connect_cache();
}
private function connect_cache() {
$matches = array();
if(defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) {
if($matches[1] == "memcache") {
$this->cache = new MemcacheCache($matches[2]);
}
else if($matches[1] == "apc") {
$this->cache = new APCCache($matches[2]);
}
}
else {
$this->cache = new NoCache();
}
}
private function connect_db() {
2011-01-01 16:59:10 +00:00
# FIXME: detect ADODB URI, automatically translate PDO DSN
/*
* Why does the abstraction layer act differently depending on the
* back-end? Because PHP is deliberately retarded.
*
* http://stackoverflow.com/questions/237367
*/
$matches = array(); $db_user=null; $db_pass=null;
if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1];
if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1];
2011-01-01 16:59:10 +00:00
2012-02-02 07:43:43 +00:00
$db_params = array(
PDO::ATTR_PERSISTENT => DATABASE_KA,
2012-01-26 17:24:56 +00:00
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
2012-02-02 07:43:43 +00:00
);
2012-02-02 08:09:48 +00:00
if(defined("HIPHOP")) $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass);
2012-02-02 07:43:43 +00:00
else $this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, $db_params);
2010-12-31 19:29:15 +00:00
$this->connect_engine();
$this->engine->init($this->db);
$this->beginTransaction();
}
private function connect_engine() {
if(preg_match("/^([^:]*)/", DATABASE_DSN, $matches)) $db_proto=$matches[1];
else throw new SCoreException("Can't figure out database engine");
if($db_proto === "mysql") {
2009-08-09 12:10:59 +00:00
$this->engine = new MySQL();
}
else if($db_proto === "pgsql") {
2009-08-09 12:10:59 +00:00
$this->engine = new PostgreSQL();
}
else if($db_proto === "sqlite") {
2009-08-09 12:10:59 +00:00
$this->engine = new SQLite();
}
2011-01-01 16:59:10 +00:00
else {
die('Unknown PDO driver: '.$db_proto);
2011-01-01 16:59:10 +00:00
}
}
2009-01-19 18:18:23 +00:00
public function beginTransaction() {
if ($this->transaction === false) {
$this->db->beginTransaction();
2014-02-19 07:50:10 +00:00
$this->transaction = true;
}
}
2014-02-22 20:42:09 +00:00
/**
* @return bool
* @throws SCoreException
*/
public function commit() {
if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false;
return $this->db->commit();
}
else {
throw new SCoreException("<p><b>Database Transaction Error:</b> Unable to call commit() as there is no transaction currently open.");
}
}
}
/**
* @return bool
* @throws SCoreException
*/
public function rollback() {
if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false;
return $this->db->rollback();
}
else {
throw new SCoreException("<p><b>Database Transaction Error:</b> Unable to call rollback() as there is no transaction currently open.");
}
2014-02-19 07:17:23 +00:00
}
}
/**
* @param string $input
* @return string
*/
public function escape($input) {
if(is_null($this->db)) $this->connect_db();
return $this->db->Quote($input);
}
/**
* @param string $input
* @return string
*/
public function scoreql_to_sql($input) {
if(is_null($this->engine)) $this->connect_engine();
return $this->engine->scoreql_to_sql($input);
}
/**
* @return null|string
*/
public function get_driver_name() {
if(is_null($this->engine)) $this->connect_engine();
return $this->engine->name;
}
2009-07-19 07:38:13 +00:00
/**
* Execute an SQL query and return an PDO result-set.
*
* @param string $query
* @param array $args
* @return PDOStatement
* @throws SCoreException
2009-07-19 07:38:13 +00:00
*/
public function execute($query, $args=array()) {
2014-02-19 21:16:01 +00:00
try {
if(is_null($this->db)) $this->connect_db();
_count_execs($this->db, $query, $args);
$stmt = $this->db->prepare($query);
if (!array_key_exists(0, $args)) {
foreach($args as $name=>$value) {
if(is_numeric($value)) {
2012-01-11 20:57:00 +00:00
$stmt->bindValue(':'.$name, $value, PDO::PARAM_INT);
}
else {
2012-01-11 20:57:00 +00:00
$stmt->bindValue(':'.$name, $value, PDO::PARAM_STR);
}
}
$stmt->execute();
2014-02-22 20:42:09 +00:00
}
else {
$stmt->execute($args);
}
return $stmt;
2014-02-19 21:16:01 +00:00
}
catch(PDOException $pdoe) {
2012-03-31 16:07:11 +00:00
throw new SCoreException($pdoe->getMessage()."<p><b>Query:</b> ".$query);
2014-02-19 21:16:01 +00:00
}
}
2009-07-19 07:38:13 +00:00
/**
* Execute an SQL query and return a 2D array.
*
* @param string $query
* @param array $args
* @return array
2009-07-19 07:38:13 +00:00
*/
public function get_all($query, $args=array()) {
$_start = microtime(true);
$data = $this->execute($query, $args)->fetchAll();
$this->dbtime += microtime(true) - $_start;
return $data;
}
2009-07-19 07:38:13 +00:00
/**
* Execute an SQL query and return a single row.
*
* @param string $query
* @param array $args
* @return mixed|null
2009-07-19 07:38:13 +00:00
*/
public function get_row($query, $args=array()) {
$_start = microtime(true);
$row = $this->execute($query, $args)->fetch();
$this->dbtime += microtime(true) - $_start;
return $row ? $row : null;
}
/**
* Execute an SQL query and return the first column of each row.
*
* @param string $query
* @param array $args
* @return array
*/
public function get_col($query, $args=array()) {
$_start = microtime(true);
$stmt = $this->execute($query, $args);
$res = array();
foreach($stmt as $row) {
$res[] = $row[0];
}
$this->dbtime += microtime(true) - $_start;
return $res;
}
2011-01-01 16:27:56 +00:00
/**
* Execute an SQL query and return the the first row => the second rown.
*
* @param string $query
* @param array $args
* @return array
2011-01-01 16:27:56 +00:00
*/
public function get_pairs($query, $args=array()) {
$_start = microtime(true);
2011-01-01 16:27:56 +00:00
$stmt = $this->execute($query, $args);
$res = array();
foreach($stmt as $row) {
$res[$row[0]] = $row[1];
}
$this->dbtime += microtime(true) - $_start;
2011-01-01 16:27:56 +00:00
return $res;
}
/**
* Execute an SQL query and return a single value.
*
* @param string $query
* @param array $args
* @return mixed
*/
public function get_one($query, $args=array()) {
$_start = microtime(true);
$row = $this->execute($query, $args)->fetch();
$this->dbtime += microtime(true) - $_start;
return $row[0];
}
2011-01-03 15:18:24 +00:00
/**
* Get the ID of the last inserted row.
*
* @param string|null $seq
* @return string
2011-01-03 15:18:24 +00:00
*/
public function get_last_insert_id($seq) {
if($this->engine->name == "pgsql") {
return $this->db->lastInsertId($seq);
}
else {
return $this->db->lastInsertId();
}
2011-01-03 15:18:24 +00:00
}
2009-07-19 07:38:13 +00:00
/**
* Create a table from pseudo-SQL.
*
* @param string $name
* @param string $data
2009-07-19 07:38:13 +00:00
*/
2009-01-22 11:22:55 +00:00
public function create_table($name, $data) {
if(is_null($this->engine)) { $this->connect_engine(); }
2009-01-22 12:05:55 +00:00
$this->execute($this->engine->create_table_sql($name, $data));
2009-01-22 11:22:55 +00:00
}
2014-02-22 20:42:09 +00:00
2012-04-18 04:55:39 +00:00
/**
* Returns the number of tables present in the current database.
*
* @return int|null
2012-04-18 04:55:39 +00:00
*/
public function count_tables() {
if(is_null($this->db) || is_null($this->engine)) $this->connect_db();
2014-02-22 20:42:09 +00:00
2012-04-18 04:55:39 +00:00
if($this->engine->name === "mysql") {
return count(
$this->get_all("SHOW TABLES")
);
} else if ($this->engine->name === "pgsql") {
return count(
$this->get_all("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
);
} else if ($this->engine->name === "sqlite") {
return count(
$this->get_all(".tables")
);
} else {
// Hard to find a universal way to do this...
return NULL;
}
}
}
class MockDatabase extends Database {
/** @var int */
var $query_id = 0;
/** @var array */
var $responses = array();
/** @var \NoCache|null */
var $cache = null;
/**
* @param array $responses
*/
public function __construct($responses = array()) {
$this->cache = new NoCache();
$this->responses = $responses;
}
/**
* @param string $query
* @param array $params
* @return PDOStatement
*/
public function execute($query, $params=array()) {
log_debug("mock-database",
"QUERY: " . $query .
"\nARGS: " . var_export($params, true) .
"\nRETURN: " . var_export($this->responses[$this->query_id], true)
);
return $this->responses[$this->query_id++];
}
2014-04-29 05:33:03 +00:00
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
*/
public function get_all($query, $args=array()) {return $this->execute($query, $args);}
2014-04-29 05:33:03 +00:00
/**
* @param string $query
* @param array $args
* @return mixed|null|PDOStatement
*/
public function get_row($query, $args=array()) {return $this->execute($query, $args);}
2014-04-29 05:33:03 +00:00
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
*/
public function get_col($query, $args=array()) {return $this->execute($query, $args);}
2014-04-29 05:33:03 +00:00
/**
* @param string $query
* @param array $args
* @return array|PDOStatement
*/
public function get_pairs($query, $args=array()) {return $this->execute($query, $args);}
2014-04-29 05:33:03 +00:00
/**
* @param string $query
* @param array $args
* @return mixed|PDOStatement
*/
public function get_one($query, $args=array()) {return $this->execute($query, $args);}
2014-04-29 05:33:03 +00:00
/**
* @param null|string $seq
* @return int|string
*/
public function get_last_insert_id($seq) {return $this->query_id;}
2014-04-29 05:33:03 +00:00
/**
* @param string $sql
* @return string
*/
public function scoreql_to_sql($sql) {return $sql;}
public function create_table($name, $def) {}
public function connect_engine() {}
}