/** * 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"; }
public function testGetInstance() { Closure::bind(function () { $this->assertNotNull(Database::$instance, Database::getInstance()); }, $this, '\\Hikouki\\Stigma\\Database')->__invoke(); }