From 8acdfdbcd5f806f735eaf78aa56108a024d5032f Mon Sep 17 00:00:00 2001 From: KJ Date: Sat, 17 Feb 2024 22:10:30 -0400 Subject: [PATCH] Undeprecated where_in method. The initial report that requested deprecation was an error. After a manual report, I discovered that the actual method is functioning properly. --- src/Libs/Model.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index 89abc58..c7d1538 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -482,6 +482,34 @@ class Model { return new static(); } + /** + * Define WHERE usando IN en la sentencia SQL. + * + * @param string $column + * La columna a comparar. + * + * @param array $arr + * Arreglo con todos los valores a comparar con la columna. + * + * @param bool $in + * Define si se tienen que comprobar negativa o positivamente. + * + * @return static + */ + public static function where_in(string $column, array $arr, bool $in = true) : static { + $arrIn = []; + foreach($arr as $value) { + $arrIn[] = static::bindValue($value); + } + + if ($in) + static::$querySelect['where'] = "$column IN (".join(', ', $arrIn).")"; + else + static::$querySelect['where'] = "$column NOT IN (".join(', ', $arrIn).")"; + + return new static(); + } + /** * Define LEFT JOIN en la sentencia SQL. *