We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49499
    • 48 Posts
    I have a script that selects multiple users by email. Here is my query:

    $c = $modx->newQuery('modUser');
    $c->select($modx->getSelectColumns('modUser','modUser','',array('id','username')));
    $c->innerJoin('modUserProfile','Profile');
    $c->where(array(
    	'Profile.email:IN' => $email_array,
    	'modUser.active' => true,
    ));


    I was getting mixed results from time to time and realized that if an email address in the $email_array is not capitalized exactly how it is in the database, it will not be included in the query. Is there a way around this?

    Maybe we can somehow use both IN and LIKE for the array?

    Any help is appreciated!

    This question has been answered by Bruno17. See the first response.

      • 4172
      • 5,888 Posts
      Maybe we can somehow use both IN and LIKE for the array?
      yes, multiple ORs with LIKE.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 49499
        • 48 Posts
        Quote from: Bruno17 at Apr 14, 2016, 12:05 PM
        Maybe we can somehow use both IN and LIKE for the array?
        yes, multiple ORs with LIKE.

        I'm not well versed in XPDO... Any idea how you would write that to check an array?
        • discuss.answer
          • 4172
          • 5,888 Posts
          something like that:

          $subwheres = array();
          foreach ($email_array as $email){
              $subwheres[] = array('OR:Profile.email:LIKE' => $email);    
          }
          
          $c = $modx->newQuery('modUser');
          $c->select($modx->getSelectColumns('modUser','modUser','',array('id','username')));
          $c->innerJoin('modUserProfile','Profile');
          $c->where(array(
              'modUser.active' => true,
              $subwheres
          ));
          
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!