Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where multiple conditions

$query->where([
    ['column_1', '=', 'value_1'],
    ['column_2', '<>', 'value_2'],
    [COLUMN, OPERATOR, VALUE],
    ...
])
Comment

laravel where multiple conditions on single colmn

//laravel
// here, i have used two different where condition on a single column
$today = Carbon::today();
$data = Users::where('type',1)
        ->where(function($query) use ($today) {
            return $query->whereDate('updated_at','!=', $today)
            ->orWhere('updated_at',null);
         })
         ->get();

//another example ->
//when you need to use like and in_array functionality together
//when column value is like {tag:active} and you are checking with an array
$query->where(function($query) use ($filter_tags) {
     foreach($filter_tags as $tag){
         $query->orWhere('user.tags', 'LIKE', "%{tag}%");
    }
});
Comment

PREVIOUS NEXT
Code Example
Php :: how to fix PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted 
Php :: laravel post request search query 
Php :: how to completely delete php 
Php :: Class "AppHttpControllersAdminController" not found in laravel 8 
Php :: get post index wordpress 
Php :: if else if ternary php 
Php :: laravel 8 foreign key 
Php :: Merge Two Array ( Laravel ) 
Php :: php Convert String containing commas to array 
Php :: php convert to string 
Php :: how do we calculate average in laravel 8 
Php :: mcrypt php extension required 
Php :: laravel select selected 
Php :: htmlspecialchars (PHP 4, PHP 5, PHP 7, PHP 8) htmlspecialchars — Convert special characters to HTML entities 
Php :: php mysql prepare query 
Php :: Laravel: Validation unique on update 
Php :: php is defined 
Php :: print array in php 
Php :: Create Model with Controller in Laravel 
Php :: php artisan storage:link not working 
Php :: Display the image on the front end from category taxonomy 
Php :: wp plugins action link 
Php :: belongs to many laravel 
Php :: laravel model save get id 
Php :: php rotate image 
Php :: php autoload classes 
Php :: form validation for file type in codeigniter 
Php :: comments in php 
Php :: insert key-value pair into array php 
Php :: In PackageManifest.php line 122: Undefined index: name 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =