forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
<?php |
|
|
|
/* |
|
* To change this template, choose Tools | Templates |
|
* and open the template in the editor. |
|
*/ |
|
|
|
class simpleDbMemory { |
|
|
|
function Create($tableName, $fields) { |
|
$this->tHead[$tableName] = $fields; |
|
} |
|
|
|
function Insert($tableName, $values) { |
|
$this->tStorage[$tableName][] = $values; |
|
} |
|
|
|
function Delete($tableName, $key = null, $value = null) { |
|
if ($key == null) { |
|
$this->tStorage[$tableName] = array(); |
|
} else { |
|
$newTable = array(); |
|
$table = $this->tStorage[$tableName]; |
|
|
|
foreach ($table as $linha) { |
|
if ($linha[$key] != $value) { |
|
$newTable[] = $linha; |
|
} |
|
} |
|
$this->tStorage[$tableName] = $newTable; |
|
} |
|
} |
|
|
|
function Select($tableName, $key = null, $value = null) { |
|
if (!$key) { |
|
return $this->tStorage[$tableName]; |
|
} else { |
|
$newTable = array(); |
|
$table = $this->tStorage[$tableName]; |
|
|
|
foreach ($table as $linha) { |
|
if ($linha[$key] == $value) { |
|
$newTable[] = $linha; |
|
} |
|
} |
|
return $newTable; |
|
} |
|
} |
|
|
|
private $db; |
|
private $tStorage; |
|
private $tHead; |
|
|
|
} |
|
|
|
?>
|
|
|