diff options
Diffstat (limited to 'codebase')
-rwxr-xr-x | codebase/base_connector.php | 2 | ||||
-rwxr-xr-x | codebase/db_common.php | 65 | ||||
-rw-r--r-- | codebase/db_mysql.php | 67 | ||||
-rw-r--r-- | codebase/mixed_connector.php | 1 |
4 files changed, 69 insertions, 66 deletions
diff --git a/codebase/base_connector.php b/codebase/base_connector.php index cb44b15..622fb17 100755 --- a/codebase/base_connector.php +++ b/codebase/base_connector.php @@ -330,7 +330,7 @@ class Connector { public function __construct($db,$type=false, $item_type=false, $data_type=false, $render_type = false){ $this->exec_time=microtime(true); - if (!$type) $type="MySQL"; + if (!$type) $type="PDO"; if (class_exists($type."DBDataWrapper",false)) $type.="DBDataWrapper"; if (!$item_type) $item_type="DataItem"; if (!$data_type) $data_type="DataProcessor"; diff --git a/codebase/db_common.php b/codebase/db_common.php index eddc7ad..3650cfa 100755 --- a/codebase/db_common.php +++ b/codebase/db_common.php @@ -1100,69 +1100,6 @@ class ArrayQueryWrapper{ $this->index = 0; } } -/*! Implementation of DataWrapper for MySQL -**/ -class MySQLDBDataWrapper extends DBDataWrapper{ - protected $last_result; - public function query($sql){ - LogMaster::log($sql); - $res=mysql_query($sql,$this->connection); - if ($res===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); - $this->last_result = $res; - return $res; - } - - public function get_next($res){ - if (!$res) - $res = $this->last_result; - - return mysql_fetch_assoc($res); - } - - public function get_new_id(){ - return mysql_insert_id($this->connection); - } - - public function escape($data){ - return mysql_real_escape_string($data, $this->connection); - } - public function tables_list() { - $result = mysql_query("SHOW TABLES"); - if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); - - $tables = array(); - while ($table = mysql_fetch_array($result)) { - $tables[] = $table[0]; - } - return $tables; - } - - public function fields_list($table) { - $result = mysql_query("SHOW COLUMNS FROM `".$table."`"); - if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); - - $fields = array(); - $id = ""; - while ($field = mysql_fetch_assoc($result)) { - if ($field['Key'] == "PRI") - $id = $field["Field"]; - else - $fields[] = $field["Field"]; - } - return array("fields" => $fields, "key" => $id ); - } - - /*! escape field name to prevent sql reserved words conflict - @param data - unescaped data - @return - escaped data - */ - public function escape_name($data){ - if ((strpos($data,"`")!==false || is_int($data)) || (strpos($data,".")!==false)) - return $data; - return '`'.$data.'`'; - } -} +include_once(__DIR__."/db_pdo.php"); ?>
\ No newline at end of file diff --git a/codebase/db_mysql.php b/codebase/db_mysql.php new file mode 100644 index 0000000..d31d210 --- /dev/null +++ b/codebase/db_mysql.php @@ -0,0 +1,67 @@ +<?php + +/*! Implementation of DataWrapper for MySQL +**/ +class MySQLDBDataWrapper extends DBDataWrapper{ + protected $last_result; + public function query($sql){ + LogMaster::log($sql); + $res=mysql_query($sql,$this->connection); + if ($res===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); + $this->last_result = $res; + return $res; + } + + public function get_next($res){ + if (!$res) + $res = $this->last_result; + + return mysql_fetch_assoc($res); + } + + public function get_new_id(){ + return mysql_insert_id($this->connection); + } + + public function escape($data){ + return mysql_real_escape_string($data, $this->connection); + } + + public function tables_list() { + $result = mysql_query("SHOW TABLES"); + if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); + + $tables = array(); + while ($table = mysql_fetch_array($result)) { + $tables[] = $table[0]; + } + return $tables; + } + + public function fields_list($table) { + $result = mysql_query("SHOW COLUMNS FROM `".$table."`"); + if ($result===false) throw new Exception("MySQL operation failed\n".mysql_error($this->connection)); + + $fields = array(); + $id = ""; + while ($field = mysql_fetch_assoc($result)) { + if ($field['Key'] == "PRI") + $id = $field["Field"]; + else + $fields[] = $field["Field"]; + } + return array("fields" => $fields, "key" => $id ); + } + + /*! escape field name to prevent sql reserved words conflict + @param data + unescaped data + @return + escaped data + */ + public function escape_name($data){ + if ((strpos($data,"`")!==false || is_int($data)) || (strpos($data,".")!==false)) + return $data; + return '`'.$data.'`'; + } +}
\ No newline at end of file diff --git a/codebase/mixed_connector.php b/codebase/mixed_connector.php index bbef8d4..99edf86 100644 --- a/codebase/mixed_connector.php +++ b/codebase/mixed_connector.php @@ -18,7 +18,6 @@ class MixedConnector extends Connector { public function add($name, $conn) { $this->connectors[$name] = $conn; - $conn->simple = true; } public function render() { |