Commit a8b8c8db authored by Alexander Butenko's avatar Alexander Butenko

Allow prefix configuration out of constructor

parent ea35ad41
...@@ -24,7 +24,7 @@ class MysqliDb ...@@ -24,7 +24,7 @@ class MysqliDb
* *
* @var string * @var string
*/ */
public static $prefix; public static $prefix = '';
/** /**
* MySQLi instance * MySQLi instance
* *
...@@ -167,7 +167,8 @@ class MysqliDb ...@@ -167,7 +167,8 @@ class MysqliDb
$this->isSubQuery = true; $this->isSubQuery = true;
return; return;
} }
$this->setPrefix(); if (isset ($prefix))
$this->setPrefix ($prefix);
self::$_instance = $this; self::$_instance = $this;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
require_once ("../MysqliDb.php"); require_once ("../MysqliDb.php");
error_reporting(E_ALL); error_reporting(E_ALL);
$prefix = 't_';
$db = new Mysqlidb('localhost', 'root', '', 'testdb'); $db = new Mysqlidb('localhost', 'root', '', 'testdb');
if(!$db) die("Database error"); if(!$db) die("Database error");
...@@ -12,13 +13,11 @@ $db = new Mysqlidb(Array ( ...@@ -12,13 +13,11 @@ $db = new Mysqlidb(Array (
'host' => 'localhost', 'host' => 'localhost',
'username' => 'root', 'username' => 'root',
'password' => '', 'password' => '',
'db'=> 'testdb', 'db' => 'testdb',
'prefix' => $prefix,
'charset' => null)); 'charset' => null));
if(!$db) die("Database error"); if(!$db) die("Database error");
$prefix = 't_';
$db->setPrefix($prefix);
$db->setTrace(true); $db->setTrace(true);
$tables = Array ( $tables = Array (
...@@ -117,7 +116,6 @@ if (!$db->ping()) { ...@@ -117,7 +116,6 @@ if (!$db->ping()) {
exit; exit;
} }
$str = $db->escape ("te'st");
// insert test with autoincrement // insert test with autoincrement
foreach ($data as $name => $datas) { foreach ($data as $name => $datas) {
foreach ($datas as $d) { foreach ($datas as $d) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment