改名
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Database\Traits;
|
|||||||
use Database\ActiveQuery;
|
use Database\ActiveQuery;
|
||||||
use Database\ActiveRecord;
|
use Database\ActiveRecord;
|
||||||
use Database\Condition\MathematicsCondition;
|
use Database\Condition\MathematicsCondition;
|
||||||
|
use Database\Sql;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +57,23 @@ trait QueryTrait
|
|||||||
$this->filter = [];
|
$this->filter = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $condition
|
||||||
|
* @param $condition1
|
||||||
|
* @param $condition2
|
||||||
|
* @return $this
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function if(string $condition, string|array $condition1, string|array $condition2): static
|
||||||
|
{
|
||||||
|
$condition1 = (new Sql())->where($condition1)->getCondition();
|
||||||
|
$condition2 = (new Sql())->where($condition2)->getCondition();
|
||||||
|
|
||||||
|
$this->where[] = 'IF(' . $condition . ',' . $condition1 . ',' . $condition2 . ')';
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $bool
|
* @param $bool
|
||||||
* @return $this
|
* @return $this
|
||||||
|
|||||||
Reference in New Issue
Block a user