Exemplo n.º 1
0
 /**
  * Delete and Insert database row.
  * @param $row array Row in table.
  * @param $table string Table name.
  * @return void
  */
 public static function updateRow($row, $table)
 {
     $fields = array_keys($row);
     $values = array_values($row);
     $pressholders = str_repeat("?,", count($fields) - 1);
     $insertSQL = "INSERT INTO " . $table . "(" . implode(',', $fields) . ") VALUES (" . $pressholders . "?)";
     $deleteSQL = "DELETE FROM " . $table . " WHERE " . current($fields) . " = ?";
     $db = Database::getInstance();
     $db->prepare($deleteSQL)->execute([current($values)]);
     $db->prepare($insertSQL)->execute($values);
     echo '→ MODIFY: (' . $table . ') ' . implode(', ', $values) . "\n";
 }
Exemplo n.º 2
0
 public function testGetInstance()
 {
     Closure::bind(function () {
         $this->assertNotNull(Database::$instance, Database::getInstance());
     }, $this, '\\Hikouki\\Stigma\\Database')->__invoke();
 }