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
* @var MysqliDb
*/
protected static $_instance;
/**
* Table prefix
*
* @var string
*/
protected $_prefix;
/**
* MySQLi instance
*
......@@ -112,7 +106,6 @@ class MysqliDb
$this->port = $port;
$this->connect();
$this->setPrefix();
self::$_instance = $this;
}
......@@ -157,16 +150,6 @@ class MysqliDb
$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.
*
......@@ -231,7 +214,7 @@ class MysqliDb
$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->execute();
$this->_stmtError = $stmt->error;
......@@ -265,7 +248,7 @@ class MysqliDb
*/
public function insert($tableName, $insertData)
{
$this->_query = "INSERT into $this->_prefix$tableName";
$this->_query = "INSERT into $tableName";
$stmt = $this->_buildQuery(null, $insertData);
$stmt->execute();
$this->_stmtError = $stmt->error;
......@@ -284,7 +267,7 @@ class MysqliDb
*/
public function update($tableName, $tableData)
{
$this->_query = "UPDATE $this->_prefix$tableName SET ";
$this->_query = "UPDATE $tableName SET ";
$stmt = $this->_buildQuery(null, $tableData);
$stmt->execute();
......@@ -304,7 +287,7 @@ class MysqliDb
*/
public function delete($tableName, $numRows = null)
{
$this->_query = "DELETE FROM $this->_prefix$tableName";
$this->_query = "DELETE FROM $tableName";
$stmt = $this->_buildQuery($numRows);
$stmt->execute();
......@@ -365,7 +348,7 @@ class MysqliDb
if ($joinType && !in_array ($joinType, $allowedTypes))
die ('Wrong JOIN type: '.$joinType);
$this->_join[$joinType . " JOIN " . $this->_prefix.$joinTable] = $joinCondition;
$this->_join[$joinType . " JOIN " . $joinTable] = $joinCondition;
return $this;
}
......
......@@ -10,11 +10,6 @@ After that, create a new instance of the class.
$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.
### Insert Query
......
......@@ -5,9 +5,6 @@ error_reporting(E_ALL);
$db = new Mysqlidb('localhost', 'root', '', 'testdb');
if(!$db) die("Database error");
$prefix = 'prefix_';
$db->setPrefix($prefix)
$tables = Array (
'users' => Array (
'login' => 'char(10) not null',
......@@ -95,7 +92,7 @@ function createTable ($name, $data) {
foreach ($tables as $name => $fields) {
$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