20250820 v1.0.2-b2

This commit is contained in:
2025-08-20 18:09:37 +03:00
parent cc3b1ef41b
commit 95aa7d9411
22 changed files with 594 additions and 68 deletions

View File

@@ -7,6 +7,7 @@
use goodboyalex\php_components_pack\classes\ObjectArray;
use goodboyalex\php_db_components_pack\classes\ConditionBuilder;
use goodboyalex\php_db_components_pack\enums\DBDriver;
use goodboyalex\php_db_components_pack\enums\DBOperation;
use goodboyalex\php_db_components_pack\interfaces\IDBItem;
use PDO;
@@ -33,22 +34,22 @@
* @return IDBItem|false Заполненный объект класса или <code>false</code> в случае ошибки.
*/
public function GetRow (string $table, array $columns = [], ConditionBuilder $where = new ConditionBuilder(),
string $className = "\\StdClass"): IDBItem|false
string $className = "\\StdClass"): IDBItem | false
{
// Задаю массив параметров
$params = [];
// Подготавливаю имя таблицы
$table = $this->PrepareTableName($table);
// Формируем SQL-запрос
$sql = $this->PrepareSQLForRowsQuery($table, $columns, $where, $params);
// Добавляю лимит
$sql .= " LIMIT 1";
// Получаю строку
$row = $this->Query($sql, $params);
$row = $this->QueryFirst($sql, $params);
// Если не получено
if ($row === false)
if ($row === false || count($row) == 0)
// - то вывожу false
return false;
@@ -75,11 +76,14 @@
* @return false|ObjectArray Массив найденных классов или <code>false</code> в случае ошибки.
*/
public function GetRows (string $table, array $columns = [], ConditionBuilder $where = new ConditionBuilder(),
string $className = "\\StdClass"): false|ObjectArray
string $className = "\\StdClass"): false | ObjectArray
{
// Задаю массив параметров
$params = [];
// Подготавливаю имя таблицы
$table = $this->PrepareTableName($table);
// Получаю SQL запрос
$sql = $this->PrepareSQLForRowsQuery($table, $columns, $where, $params);
@@ -124,18 +128,23 @@
* @see Query
*/
public function GetCol (string $table, string $column, ConditionBuilder $where = new ConditionBuilder()):
false|array
{
false | array {
/**
* Интерпретирую условия.
*
* @var string $sql_where Строка запроса.
* @var array $params Массив параметров строки запроса.
*/
[$sql_where, $params] = $where->Build();
[$sql_where, $params] = $where->Build($this->Config->Driver);
// Получаю знаки открытия параметра и закрытия его
[$signOpen, $signClose] = DBDriver::GetSigns($this->Config->Driver);
// Подготавливаю имя таблицы
$table = $this->PrepareTableName($table);
// Создаю запрос
$sql = "SELECT $this->DBSignOpen$column$this->DBSignClose FROM $this->DBSignOpen$table$this->DBSignClose";
$sql = "SELECT $signOpen$column$signClose FROM $table";
// Если заданы where-параметры
if ($where->Count() > 0)