20250807
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
*
|
||||
* @return int Количество строк или -1, в случае ошибки.
|
||||
*/
|
||||
public function Count (string $table, ConditionBuilder $where): int
|
||||
public function Count (string $table, ConditionBuilder $where = new ConditionBuilder()): int
|
||||
{
|
||||
/**
|
||||
* Получаем условия.
|
||||
|
@@ -27,7 +27,7 @@
|
||||
*
|
||||
* @return bool Результат выполнения.
|
||||
*/
|
||||
public function Delete (string $table, ConditionBuilder $where): bool
|
||||
public function Delete (string $table, ConditionBuilder $where = new ConditionBuilder()): bool
|
||||
{
|
||||
/**
|
||||
* Получаю SQL-запрос и параметры для where.
|
||||
|
@@ -25,13 +25,13 @@
|
||||
* Извлекает одну запись из базы данных и создает соответствующий объект класса.
|
||||
*
|
||||
* @param string $table Название таблицы.
|
||||
* @param ConditionBuilder $where Условия выборки.
|
||||
* @param array $columns Колонки, которые нужно включить в запрос.
|
||||
* @param ConditionBuilder $where Условия выборки.
|
||||
* @param string $className Полное имя класса, реализуемого интерфейсом IDBItem.
|
||||
*
|
||||
* @return object|false Заполненный объект класса или <code>false</code> в случае ошибки.
|
||||
*/
|
||||
public function GetRow (string $table, ConditionBuilder $where, array $columns = [],
|
||||
public function GetRow (string $table, array $columns = [], ConditionBuilder $where = new ConditionBuilder(),
|
||||
string $className = "\\StdClass"): object|false
|
||||
{
|
||||
// Задаю массив параметров
|
||||
@@ -73,7 +73,8 @@
|
||||
*
|
||||
* @return false|ObjectArray Массив найденных классов или <code>false</code> в случае ошибки.
|
||||
*/
|
||||
public function GetRows (string $table, ConditionBuilder $where, array $columns = [],
|
||||
public
|
||||
function GetRows (string $table, ConditionBuilder $where, array $columns = [],
|
||||
string $className = "\\StdClass"): false|ObjectArray
|
||||
{
|
||||
// Задаю массив параметров
|
||||
@@ -122,7 +123,8 @@
|
||||
*
|
||||
* @see Query
|
||||
*/
|
||||
public function GetCol (string $table, string $column, ConditionBuilder $where): false|array
|
||||
public
|
||||
function GetCol (string $table, string $column, ConditionBuilder $where): false|array
|
||||
{
|
||||
/**
|
||||
* Интерпретирую условия.
|
||||
@@ -169,7 +171,8 @@
|
||||
*
|
||||
* @return mixed|null Результат запроса или <code>null</code> в случае ошибки.
|
||||
*/
|
||||
public function GetValue (string $table, string $column, ConditionBuilder $where): mixed
|
||||
public
|
||||
function GetValue (string $table, string $column, ConditionBuilder $where): mixed
|
||||
{
|
||||
// Получаю колонку по условию из таблицы
|
||||
$result = $this->GetCol($table, $column, $where);
|
||||
|
@@ -57,7 +57,7 @@
|
||||
$property = $primaryKeys[$i];
|
||||
|
||||
// - получаю ключ
|
||||
$whereKey = $property->FieldName;
|
||||
$whereKey = $property->Column->Name;
|
||||
|
||||
// - получаю значение ключа, конвертируя его в БД
|
||||
$whereValue = call_user_func($property->ConvertToDB, $property->Value);
|
||||
@@ -67,7 +67,7 @@
|
||||
}
|
||||
|
||||
// Получаю запись из базы данных
|
||||
$dbItem = $this->GetRow($table, $where, className: get_class($item));
|
||||
$dbItem = $this->GetRow($table, where: $where, className: get_class($item));
|
||||
|
||||
// Если запись не найдена
|
||||
if ($dbItem === false)
|
||||
@@ -80,7 +80,7 @@
|
||||
/**
|
||||
* Для каждого свойства...
|
||||
*
|
||||
* @var \goodboyalex\php_db_components_pack\models\DBItemProperty $property Свойство.
|
||||
* @var DBItemProperty $property Свойство.
|
||||
*/
|
||||
foreach ($properties as $property) {
|
||||
// ... если это первичный ключ
|
||||
@@ -112,7 +112,7 @@
|
||||
$value = call_user_func($property->ConvertToDB, $property->Value);
|
||||
|
||||
// - добавляю его в массив параметров для обновления
|
||||
$propertyToSet[$property->FieldName] = $value;
|
||||
$propertyToSet[$property->Column->Name] = $value;
|
||||
}
|
||||
|
||||
// Создаю массив set
|
||||
|
Reference in New Issue
Block a user