31 public static function find($value, $column =
'id',
$table =
'')
33 if (empty(self::$tables)) {
39 if (!in_array(
$table, self::$tables))
return;
40 $sth =
$dbh->prepare(
"SELECT * FROM `$table` WHERE `$column` = :value");
41 $sth->bindValue(
':value', $value);
55 public static function all($value =
'', $column =
'id',
$table =
'')
57 if (empty(self::$tables)) {
62 if (!in_array(
$table, self::$tables))
return;
64 $sth =
$dbh->prepare(
"SELECT * FROM `$table` WHERE `$column` = :value");
65 $sth->bindValue(
':value', $value);
67 $sth =
$dbh->prepare(
"SELECT * FROM `$table`");
70 return $sth->fetchAll();
83 public static function count($value =
'', $column =
'id',
$table =
'', $where =
'')
85 if (empty(self::$tables)) {
90 if (!in_array(
$table, self::$tables))
return;
92 $sth =
$dbh->prepare(
"SELECT COUNT(*) FROM `$table` WHERE `$column` = :value $where");
93 $sth->bindValue(
':value', $value);
95 $sth =
$dbh->prepare(
"SELECT COUNT(*) FROM `$table` $where");
98 return $sth->fetchColumn();
113 $sth =
$dbh->prepare(
"UPDATE `$table` SET `act` = IF (`act` = 1, 0, 1) WHERE `id` = :id");
114 $sth->bindValue(
':id', $id);
116 if (
$sth->rowCount()) {
129 public static function table($class)
131 if (empty(self::$tables)) {
135 $table = strtolower(basename(str_replace(
'\\',
'/', $class)));
137 if (!in_array(
$table, self::$tables)) {
150 self::$tables =
$dbh->query(
"SHOW TABLES")->fetchAll(\PDO::FETCH_COLUMN);
160 public static function name($id)
162 return basename(self::find($id)->request);
if(!($row=Wrong\Models\Crontabs::find($_POST['id']))) if(! $user->access() ->write($row)) $sth
if(!in_array($_POST['table'], Wrong\Database\Controller::$tables)) $table
static getInstance($ignore_error=false)
Controller контроллер для запросов к БД
static count($value='', $column='id', $table='', $where='')
static find($value, $column='id', $table='')
static all($value='', $column='id', $table='')
static toggle($id, $table)