logo
down
shadow

laravel query: orWhere: double condition


laravel query: orWhere: double condition

By : Sean Munson
Date : November 21 2020, 01:01 AM
will be helpful for those in need I don't know your exact goal nor do I know what your db looks so this is just a wild guess:
code :
$query = $query->join('events_dates', function($join) use ($data){ 
            $join->on('events.id', '=', 'events_dates.event_id')
                    ->where('events_dates.start_date', "<=", date_format(date_create($data['date_end']), "Y-m-d"))
                    ->where('events_dates.end_date', '>=', date_format(date_create($data['date_start']), "Y-m-d"))
                    ->orWhere('recurrent', "=", 1)
                    ->whereRaw('DATEDIFF(?, event_dates.start_date) % event_dates.repeat_interval = 0', array($data['date_start']));
->where('events_dates.start_date', '<=', new Carbon($data['date_end']))
->where('events_dates.end_date', '>=', new Carbon($data['date_start']))


Share : facebook icon twitter icon
Laravel: Proper way to use Where and orWhere in query

Laravel: Proper way to use Where and orWhere in query


By : Christopher
Date : March 29 2020, 07:55 AM
This might help you See this example from the documentation:
code :
DB::table('users')
        ->where('name', '=', 'John')
        ->orWhere(function($query)
        {
            $query->where('votes', '>', 100)
                  ->where('title', '<>', 'Admin');
        })
        ->get();
Laravel Query builder - OrWhere + Where

Laravel Query builder - OrWhere + Where


By : Fajar Nur Rachmad
Date : March 29 2020, 07:55 AM
around this issue I have the following query: , How about using this query?
code :
$id = $this->id;

$battle = PvpBattle::where('mode', '!=', 'FINISH')
    ->where(function ($query) use ($id) {
        $query->where('player1_id', '=' , $id)
            ->orWhere('player2_id', '=', $id);
    })
    ->first();
Laravel 5.3 adding brackets to eloquent query that has orWhere clause and AND condition

Laravel 5.3 adding brackets to eloquent query that has orWhere clause and AND condition


By : paulg
Date : March 29 2020, 07:55 AM
Hope this helps You've actually done the right thing, just in reverse.
Right now, your query reads
code :
WHERE (is_enumerator IS NOT NULL)
AND firstname LIKE '%...%'
AND email LIKE '%...%'
... and so on
$user = User::where(function ($q) use ($query) {
        $q->where('firstname', 'LIKE', '%' . $query . '%')
          ->orWhere('email', 'LIKE', '%' . $query . '%')
          ->orWhere('id', 'LIKE', '%' . $query . '%')
          ->orWhere('lastname', 'LIKE', '%' . $query . '%')
          ->orWhere('county', 'LIKE', '%' . $query . '%')
          ->orWhere('ward', 'LIKE', '%' . $query . '%');
    })
    ->whereNotNull('is_enumerator')
    ->get();
Laravel: unable to build multiple orWhere query with laravel query builder

Laravel: unable to build multiple orWhere query with laravel query builder


By : Nikola Obradovic
Date : March 29 2020, 07:55 AM
Hope this helps In order to group WHERE clauses so that they're surrounded by brackets you need to pass a callback to where() call.
The following code should do the trick:
code :
$dbObj =  DB::table($datatableName->dataset_table);
$column1 = 2015;
$column2 = 2016;    

$dbObj->where(function($query) use ($column1, $column2) {
  $query->orWhere('column_1',$column1);
  $query->orWhere('column_2',$column2);
});
$dbObj->where(array('column_1','GNDU'));
How to access varible inside orWhere() in laravel query builder|Laravel

How to access varible inside orWhere() in laravel query builder|Laravel


By : Leon
Date : March 29 2020, 07:55 AM
may help you . You need to use the use clause to make the variable accessible in the closure scope. So, change this:
code :
->orWhere(function ($query) {
->orWhere(function ($query) use($user) {
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org