Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| beb48f41d2 | |||
| 8d917b0f92 |
+5
-3
@@ -1,4 +1,5 @@
|
|||||||
<?php /** @noinspection ALL */
|
<?php
|
||||||
|
/** @noinspection ALL */
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: whwyy
|
* User: whwyy
|
||||||
@@ -234,8 +235,9 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
* @return Model|null
|
* @return Model|null
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public static function findOne(int|string|array $param): ?static
|
public static function findOne(int|string|array|null $param): ?static
|
||||||
{
|
{
|
||||||
|
if (empty($param)) return null;
|
||||||
$model = static::instance();
|
$model = static::instance();
|
||||||
$query = new ActiveQuery($model);
|
$query = new ActiveQuery($model);
|
||||||
$query->from($model->getTable())->alias('t1');
|
$query->from($model->getTable())->alias('t1');
|
||||||
@@ -464,7 +466,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
if ($generate === false) {
|
if ($generate === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$this->getConnection()->createCommand($generate, $query->params)->save()) {
|
if (!$this->getConnection()->createCommand($generate, $query->params)->exec()) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return $this->refresh()->afterSave($old, $change);
|
return $this->refresh()->afterSave($old, $change);
|
||||||
|
|||||||
@@ -47,15 +47,6 @@ class Command extends Component
|
|||||||
return (bool)$this->_prepare();
|
return (bool)$this->_prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
* @throws
|
|
||||||
*/
|
|
||||||
public function save(): bool
|
|
||||||
{
|
|
||||||
return (bool)$this->_prepare();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
|
|||||||
+2
-2
@@ -18,10 +18,10 @@ interface ModelInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string|int $param
|
* @param array|string|int|null $param
|
||||||
* @return ModelInterface|null
|
* @return ModelInterface|null
|
||||||
*/
|
*/
|
||||||
public static function findOne(array|string|int $param): ?static;
|
public static function findOne(array|string|int|null $param): ?static;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user