Compare commits
3 Commits
b282d5479f
...
master
Author | SHA1 | Date | |
---|---|---|---|
b19e7d8789 | |||
4dfdb52519 | |||
b0891885f9 |
@ -28,7 +28,6 @@ class Model
|
|||||||
protected static array $ignoreSave = ['id'];
|
protected static array $ignoreSave = ['id'];
|
||||||
protected static array $forceSave = [];
|
protected static array $forceSave = [];
|
||||||
protected static string $table;
|
protected static string $table;
|
||||||
protected static string $tableSufix = 's';
|
|
||||||
protected static array $queryVars = [];
|
protected static array $queryVars = [];
|
||||||
protected static array $querySelect = [
|
protected static array $querySelect = [
|
||||||
'select' => ['*'],
|
'select' => ['*'],
|
||||||
@ -313,8 +312,6 @@ class Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_r($result);
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +342,7 @@ class Model
|
|||||||
return static::$table;
|
return static::$table;
|
||||||
}
|
}
|
||||||
|
|
||||||
return static::camelCaseToSnakeCase(static::className()) . static::$tableSufix;
|
return static::camelCaseToSnakeCase(static::className()) . 's';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,7 +470,7 @@ class Model
|
|||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function select(array $columns): static
|
public static function select(...$columns): static
|
||||||
{
|
{
|
||||||
static::$querySelect['select'] = $columns;
|
static::$querySelect['select'] = $columns;
|
||||||
|
|
||||||
@ -488,7 +485,7 @@ class Model
|
|||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function from(array $tables): static
|
public static function from(...$tables): static
|
||||||
{
|
{
|
||||||
static::$querySelect['from'] = join(', ', $tables);
|
static::$querySelect['from'] = join(', ', $tables);
|
||||||
|
|
||||||
@ -983,15 +980,15 @@ class Model
|
|||||||
* Permite definir como nulo el valor de un atributo.
|
* Permite definir como nulo el valor de un atributo.
|
||||||
* Sólo funciona para actualizar un elemento de la BD, no para insertar.
|
* Sólo funciona para actualizar un elemento de la BD, no para insertar.
|
||||||
*
|
*
|
||||||
* @param string|array $atts
|
* @param array $attributes
|
||||||
* Atributo o arreglo de atributos que se definirán como nulos.
|
* Atributo o arreglo de atributos que se definirán como nulos.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setNull(string|array $atts): void
|
public function setNull(...$attributes): void
|
||||||
{
|
{
|
||||||
if (is_array($atts)) {
|
if (is_array($attributes)) {
|
||||||
foreach ($atts as $att) {
|
foreach ($attributes as $att) {
|
||||||
if (!in_array($att, $this->toNull)) {
|
if (!in_array($att, $this->toNull)) {
|
||||||
$this->toNull[] = $att;
|
$this->toNull[] = $att;
|
||||||
}
|
}
|
||||||
@ -999,8 +996,8 @@ class Model
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($atts, $this->toNull)) {
|
if (!in_array($attributes, $this->toNull)) {
|
||||||
$this->toNull[] = $atts;
|
$this->toNull[] = $attributes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user