public static function dispense($table) //создает объект из строки
{
$stmt = self::$db->query('DESCRIBE ' . $table);
$r = [];
foreach ($stmt as $field) {
foreach ($field as $key => $value) {
if ($key === 'Field') unset($r[$value]);
}
}
$r['tablename'] = $table;
return $r;
}
public static function create($array) //создает строку
{
$table = $array['tablename'];
unset($array['tablename']);
$questionmarks = [];
$c = sizeof($array);
for ($i = 0; $i < $c; ++$i) {
$questionmarks[] = '?';
}
$stmt = self::$db->prepare('INSERT INTO `' . $table . '` (' . implode(',', array_keys($array)) . ') VALUES (' . implode(',', $questionmarks) . ')');
$stmt->execute(array_values($array));
}
public static function delete($table, $query, $params = []) //удаляет строку
{
self::$db->prepare('DELETE FROM `' . $table . '` WHERE ' . $query)->execute($params);
}