Commit 743541f7 authored by Alexander Butenko's avatar Alexander Butenko

Revert "Merge pull request #5 from screeper/master"

This reverts commit 5b2113e5, reversing
changes made to fee1b126.
parent 5b2113e5
...@@ -19,12 +19,6 @@ class MysqliDb ...@@ -19,12 +19,6 @@ class MysqliDb
* @var MysqliDb * @var MysqliDb
*/ */
protected static $_instance; protected static $_instance;
/**
* Table prefix
*
* @var string
*/
protected $_prefix;
/** /**
* MySQLi instance * MySQLi instance
* *
...@@ -112,7 +106,6 @@ class MysqliDb ...@@ -112,7 +106,6 @@ class MysqliDb
$this->port = $port; $this->port = $port;
$this->connect(); $this->connect();
$this->setPrefix();
self::$_instance = $this; self::$_instance = $this;
} }
...@@ -156,16 +149,6 @@ class MysqliDb ...@@ -156,16 +149,6 @@ class MysqliDb
$this->_query = null; $this->_query = null;
$this->count = 0; $this->count = 0;
} }
/**
* Method to set a prefix
*
* @param string $prefix Contains a tableprefix
*/
public function setPrefix($prefix = '')
{
$this->_prefix = $prefix;
}
/** /**
* Pass in a raw query and an array containing the parameters to bind to the prepaird statement. * Pass in a raw query and an array containing the parameters to bind to the prepaird statement.
...@@ -231,7 +214,7 @@ class MysqliDb ...@@ -231,7 +214,7 @@ class MysqliDb
$columns = '*'; $columns = '*';
$column = is_array($columns) ? implode(', ', $columns) : $columns; $column = is_array($columns) ? implode(', ', $columns) : $columns;
$this->_query = "SELECT $column FROM $this->_prefix$tableName"; $this->_query = "SELECT $column FROM $tableName";
$stmt = $this->_buildQuery($numRows); $stmt = $this->_buildQuery($numRows);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error; $this->_stmtError = $stmt->error;
...@@ -265,7 +248,7 @@ class MysqliDb ...@@ -265,7 +248,7 @@ class MysqliDb
*/ */
public function insert($tableName, $insertData) public function insert($tableName, $insertData)
{ {
$this->_query = "INSERT into $this->_prefix$tableName"; $this->_query = "INSERT into $tableName";
$stmt = $this->_buildQuery(null, $insertData); $stmt = $this->_buildQuery(null, $insertData);
$stmt->execute(); $stmt->execute();
$this->_stmtError = $stmt->error; $this->_stmtError = $stmt->error;
...@@ -284,7 +267,7 @@ class MysqliDb ...@@ -284,7 +267,7 @@ class MysqliDb
*/ */
public function update($tableName, $tableData) public function update($tableName, $tableData)
{ {
$this->_query = "UPDATE $this->_prefix$tableName SET "; $this->_query = "UPDATE $tableName SET ";
$stmt = $this->_buildQuery(null, $tableData); $stmt = $this->_buildQuery(null, $tableData);
$stmt->execute(); $stmt->execute();
...@@ -304,7 +287,7 @@ class MysqliDb ...@@ -304,7 +287,7 @@ class MysqliDb
*/ */
public function delete($tableName, $numRows = null) public function delete($tableName, $numRows = null)
{ {
$this->_query = "DELETE FROM $this->_prefix$tableName"; $this->_query = "DELETE FROM $tableName";
$stmt = $this->_buildQuery($numRows); $stmt = $this->_buildQuery($numRows);
$stmt->execute(); $stmt->execute();
...@@ -365,7 +348,7 @@ class MysqliDb ...@@ -365,7 +348,7 @@ class MysqliDb
if ($joinType && !in_array ($joinType, $allowedTypes)) if ($joinType && !in_array ($joinType, $allowedTypes))
die ('Wrong JOIN type: '.$joinType); die ('Wrong JOIN type: '.$joinType);
$this->_join[$joinType . " JOIN " . $this->_prefix.$joinTable] = $joinCondition; $this->_join[$joinType . " JOIN " . $joinTable] = $joinCondition;
return $this; return $this;
} }
......
...@@ -10,11 +10,6 @@ After that, create a new instance of the class. ...@@ -10,11 +10,6 @@ After that, create a new instance of the class.
$db = new Mysqlidb('host', 'username', 'password', 'databaseName'); $db = new Mysqlidb('host', 'username', 'password', 'databaseName');
``` ```
It's also possible to set a table prefix:
```php
$db->setPrefix('tablePrefix');
```
Next, prepare your data, and call the necessary methods. Next, prepare your data, and call the necessary methods.
### Insert Query ### Insert Query
......
...@@ -5,9 +5,6 @@ error_reporting(E_ALL); ...@@ -5,9 +5,6 @@ error_reporting(E_ALL);
$db = new Mysqlidb('localhost', 'root', '', 'testdb'); $db = new Mysqlidb('localhost', 'root', '', 'testdb');
if(!$db) die("Database error"); if(!$db) die("Database error");
$prefix = 'prefix_';
$db->setPrefix($prefix)
$tables = Array ( $tables = Array (
'users' => Array ( 'users' => Array (
'login' => 'char(10) not null', 'login' => 'char(10) not null',
...@@ -95,7 +92,7 @@ function createTable ($name, $data) { ...@@ -95,7 +92,7 @@ function createTable ($name, $data) {
foreach ($tables as $name => $fields) { foreach ($tables as $name => $fields) {
$db->rawQuery("DROP TABLE $name"); $db->rawQuery("DROP TABLE $name");
createTable ($prefix.$name, $fields); createTable ($name, $fields);
} }
......
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