改名
This commit is contained in:
@@ -24,7 +24,7 @@ class SqlBuilder extends Component
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $query
|
* @param ISqlBuilder|null $query
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ namespace Database\Traits;
|
|||||||
|
|
||||||
|
|
||||||
use Database\ActiveQuery;
|
use Database\ActiveQuery;
|
||||||
|
use Database\ISqlBuilder;
|
||||||
use Database\Query;
|
use Database\Query;
|
||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
|
use Snowflake\Exception\NotFindClassException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +19,7 @@ use JetBrains\PhpStorm\Pure;
|
|||||||
class When
|
class When
|
||||||
{
|
{
|
||||||
|
|
||||||
public ActiveQuery|QueryTrait $query;
|
public ActiveQuery|ISqlBuilder $query;
|
||||||
|
|
||||||
|
|
||||||
private array $_condition = [];
|
private array $_condition = [];
|
||||||
@@ -28,21 +30,23 @@ class When
|
|||||||
/**
|
/**
|
||||||
* CaseWhen constructor.
|
* CaseWhen constructor.
|
||||||
* @param string $column
|
* @param string $column
|
||||||
* @param ActiveQuery|QueryTrait $activeQuery
|
* @param ActiveQuery|ISqlBuilder $activeQuery
|
||||||
*/
|
*/
|
||||||
public function __construct(public string $column, public ActiveQuery|QueryTrait $activeQuery)
|
public function __construct(public string $column, public ActiveQuery|ISqlBuilder $activeQuery)
|
||||||
{
|
{
|
||||||
$this->_condition[] = 'CASE ' . $column;
|
$this->_condition[] = 'CASE ' . $column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $condition
|
* @param array|\Closure $condition
|
||||||
* @param string $then
|
* @param string $then
|
||||||
* @return $this
|
* @return $this
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws NotFindClassException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function when(array|string $condition, string $then): static
|
public function when(array|\Closure $condition, string $then): static
|
||||||
{
|
{
|
||||||
$this->_condition[] = sprintf('WHEN %s THEN %s', $this->activeQuery->makeNewSqlGenerate()
|
$this->_condition[] = sprintf('WHEN %s THEN %s', $this->activeQuery->makeNewSqlGenerate()
|
||||||
->where($condition)
|
->where($condition)
|
||||||
|
|||||||
Reference in New Issue
Block a user