/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/php/php-507-143-015/main.php
36 строк
829 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
class QueryBuilder { protected $select = ['*']; protected $from; protected $where = []; protected $bindings = []; public function select($columns = ['*']) { $this->select = $columns; return $this; } public function from($table) { $this->from = $table; return $this; } public function where($column, $value) { $this->where[] = "$column = ?"; $this->bindings[] = $value; return $this; } public function get() { // Генерация SQL и выполнение $sql = "SELECT " . implode(', ', $this->select) . " FROM " . $this->from; if ($this->where) { $sql .= " WHERE " . implode(' AND ', $this->where); } return DB::select($sql, $this->bindings); } }