Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94857ecb46 | |||
| 0f0a3349fb | |||
| 7fb9c3ea05 | |||
| 11a939e8a1 | |||
| 1666af9906 | |||
| 78f7faba55 |
+3
-3
@@ -692,14 +692,14 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
public function __set(string $name, mixed $value): void
|
public function __set(string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
$prefix = 'set' . ucfirst($name);
|
$prefix = 'set' . ucfirst($name);
|
||||||
if (method_exists($name, $prefix)) {
|
if (method_exists($this, $prefix)) {
|
||||||
$this->{$prefix}($value);
|
$this->{$prefix}($value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = $prefix . 'Attribute';
|
$method = $prefix . 'Attribute';
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
$this->_attributes[$name] = $this->{$method} ($value);
|
$this->_attributes[$name] = $this->{$method}($value);
|
||||||
} else {
|
} else {
|
||||||
$this->_attributes[$name] = $value;
|
$this->_attributes[$name] = $value;
|
||||||
}
|
}
|
||||||
@@ -766,7 +766,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
*/
|
*/
|
||||||
protected function withRelate(string $name): mixed
|
protected function withRelate(string $name): mixed
|
||||||
{
|
{
|
||||||
$response = $this->$name();
|
$response = $this->{'get' . ucfirst($name)}();
|
||||||
if ($response instanceof \Database\Traits\Relation) {
|
if ($response instanceof \Database\Traits\Relation) {
|
||||||
$response = $response->get();
|
$response = $response->get();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,4 +1,5 @@
|
|||||||
<?php /** @noinspection ALL */
|
<?php
|
||||||
|
/** @noinspection ALL */
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ class SqlBuilder extends Component
|
|||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
if (preg_match('/^[+|-]\s\d+$/', $value)) {
|
if (preg_match('/^[+|-]\s\d+$/', (string)$value)) {
|
||||||
$keys[] = $key . '=' . $key . ' ' . $value;
|
$keys[] = $key . '=' . $key . ' ' . $value;
|
||||||
} else {
|
} else {
|
||||||
$this->query->pushParam($value);
|
$this->query->pushParam($value);
|
||||||
|
|||||||
+11
-9
@@ -793,20 +793,22 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $columns
|
* @param string $columns
|
||||||
* @param array|Closure $value
|
* @param array|Closure|Query $value
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function whereIn(string $columns, array|Closure $value): static
|
public function whereIn(string $columns, array|Closure|Query $value): static
|
||||||
{
|
{
|
||||||
if ($value instanceof Closure) {
|
if (is_array($value)) {
|
||||||
$value = $this->makeClosureFunction($value);
|
if (count($value) < 1) throw new Exception('Value must be an not empty array');
|
||||||
}
|
|
||||||
if (count($value) < 1) {
|
|
||||||
$value = [-1];
|
|
||||||
}
|
|
||||||
$this->where[] = $columns . ' IN (' . implode(',', $value) . ')';
|
$this->where[] = $columns . ' IN (' . implode(',', $value) . ')';
|
||||||
|
} else if ($value instanceof Query) {
|
||||||
|
$this->where[] = $columns . ' IN (' . $value->build() . ')';
|
||||||
|
} else {
|
||||||
|
$this->where[] = $columns . ' IN (' . $this->makeClosureFunction($value) . ')';
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user