How To Remove A Specific Where Clause From The Query

[Solved] How To Remove A Specific Where Clause From The Query | Php Frameworks Codeigniter - Code Explorer | yomemimo.com
Question : How to remove a specific 'where' clause from the Query Builder

Answered by : uptight-unicorn-yut7jc8icac1

/** * @param Builder $builder * @param $whereColumn * @return Builder */ public static function removeWhere(Builder $builder, $whereColumn) { $bindings = $builder->getQuery()->bindings['where']; $wheres = $builder->getQuery()->wheres; $whereKey = false; foreach ($wheres as $key => $where) { if ($where['column'] == $whereColumn) { $whereKey = $key; break; } } if ($whereKey !== false) { unset($bindings[$whereKey]); unset($wheres[$whereKey]); } $builder->getQuery()->wheres = $wheres; $builder->getQuery()->bindings['where'] = $bindings; return $builder; }

Source : https://stackoverflow.com/questions/61007091/laravel-how-to-remove-a-specific-where-clause-from-the-query-builder | Last Update : Sat, 09 Jul 22

Answers related to how to remove a specific where clause from the query builder

Code Explorer Popular Question For Php Frameworks Codeigniter