Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:11:51+00:00 2026-06-06T02:11:51+00:00

I have a collection with information on visitors to a website, each visitor has

  • 0

I have a collection with information on visitors to a website, each visitor has various information about them including if a salesperson had them “locked” or not. Currently I have the following code:

$db = $conn->Surreal;
$collection = $db->visitors;
$criteria = array(
    'locked_by' => $_REQUEST['ownerkey'],
);
$criteriat = array(
    'locked_by' => null,
);
$cursor = $collection->find($criteria);
$cursort = $collection->find($criteriat);
//echo $doc->count() . ' document(s) found. <br/>';
foreach ($cursor as $doc) {
    //List all  
    if($doc['locked_by'] ==null) $doc['locked_by'] = " ";
    $pieces = explode("&&", $doc['location']);
    echo('Surreal - '.$doc['name'].'//'.$doc['uuid'].'//'.$doc['uuid'].'//'.$doc['locked_by'].'//'.$doc['location'].'*');       
}
foreach ($cursort as $doc) {
    //List all  
    if($doc['locked_by'] ==null) $doc['locked_by'] = " ";
    $pieces = explode("&&", $doc['location']);
    echo('Surreal - '.$doc['name'].'//'.$doc['uuid'].'//'.$doc['uuid'].'//'.$doc['locked_by'].'//'.$doc['location'].'*');       
}

Basically echoing out the information using two foreach statements. Can I somehow instead use a query to say basicly

if(locked_by == "RANDOM" || locked_by == null) 

?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:11:52+00:00Added an answer on June 6, 2026 at 2:11 am

    Well, MongoDB supports OR conditions in queries, starting from the 1.5.3 version:

    db.foo.find( { $or : [ { a : 1 } , { b : 2 } ] } )
    

    … so it should be implemented by something like this:

    $criteria = array(
        '$or' => array(array('locked_by' => 'RANDOM'), array('locked_by' => null))
    );
    

    The question it whether the driver you use supports this type of queries. I’ve faced some difficulties using this particular type, but that was a year ago; I suppose the things might get changed to best. )

    UPDATE: at least there’s a similar query here in comments, so I guess the things DID change to best. )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection of recipes, each having a number of ingredients. This information
I have configured java to dump garbage collection information into the logs ( verbose
I have Collection List<Car> . How to compare each item from this collection with
I'm planning to have collection of items stored in a TCollection. Each item will
I have 1 collection called Visit , in it I save documents with information
I have information that was gathered from a service about TFS builds put into
I posted a question about this earlier, but I have more information now and
I have a model called Project, which is a collection of information stored by
I have a collection: App.ViewModel.historyItemCollection That has 4 properties: id name meterValue meterDate I
I have a collection that represents the population (M, F) for each years of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.