In mongoDB query with lumen : $or/$and/$nor entries need to be full objects
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
In my MongoDB, I have stored value as below,
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com,SL2PR01MB274333160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(5)
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(6)
My search keyword is:
"SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com"
Which is match with second array from above JSON.
This is my query,
$referanceId= "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com";
$mailExists = DB::connection('mongodb')->collection('email_message')
->select('email_thread_id');
if ($referanceId)
$mailExists->whereRaw("find_in_set(".$referanceId.", reference)");
$query = $mailExists->first();
But it gives me error like below:
ServerException in Find.php line 299:
$or/$and/$nor entries need to be full objects
Please help me to resolve this issue. Thank you.
php mongodb laravel lumen
add a comment |
In my MongoDB, I have stored value as below,
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com,SL2PR01MB274333160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(5)
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(6)
My search keyword is:
"SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com"
Which is match with second array from above JSON.
This is my query,
$referanceId= "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com";
$mailExists = DB::connection('mongodb')->collection('email_message')
->select('email_thread_id');
if ($referanceId)
$mailExists->whereRaw("find_in_set(".$referanceId.", reference)");
$query = $mailExists->first();
But it gives me error like below:
ServerException in Find.php line 299:
$or/$and/$nor entries need to be full objects
Please help me to resolve this issue. Thank you.
php mongodb laravel lumen
add a comment |
In my MongoDB, I have stored value as below,
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com,SL2PR01MB274333160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(5)
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(6)
My search keyword is:
"SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com"
Which is match with second array from above JSON.
This is my query,
$referanceId= "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com";
$mailExists = DB::connection('mongodb')->collection('email_message')
->select('email_thread_id');
if ($referanceId)
$mailExists->whereRaw("find_in_set(".$referanceId.", reference)");
$query = $mailExists->first();
But it gives me error like below:
ServerException in Find.php line 299:
$or/$and/$nor entries need to be full objects
Please help me to resolve this issue. Thank you.
php mongodb laravel lumen
In my MongoDB, I have stored value as below,
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com,SL2PR01MB274333160158C08C4B7A367285C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(5)
"_id" : ObjectId("5bed3f5019f0431be000412b"),
"reference" : "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com",
"email_thread_id" : NumberInt(6)
My search keyword is:
"SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com"
Which is match with second array from above JSON.
This is my query,
$referanceId= "SL2PR01MB2745E4160158C08C4B7A364444C30@SL2PR01MB2745.apcprd01.prod.exchangelabs.com";
$mailExists = DB::connection('mongodb')->collection('email_message')
->select('email_thread_id');
if ($referanceId)
$mailExists->whereRaw("find_in_set(".$referanceId.", reference)");
$query = $mailExists->first();
But it gives me error like below:
ServerException in Find.php line 299:
$or/$and/$nor entries need to be full objects
Please help me to resolve this issue. Thank you.
php mongodb laravel lumen
php mongodb laravel lumen
edited Nov 15 '18 at 10:11
kit
1,10631017
1,10631017
asked Nov 15 '18 at 9:47
hetal gohelhetal gohel
1149
1149
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can do this easier with the laravel where method, this will do the comparison you want, and also make your code better readable.
You can use the following query to accomplish this:
DB::connection('mongodb')->collection('email_message')
->where("reference", $referanceId)->first();
If your value contains multiple reference id's as a string you can use:
$regexQuery = '/.*'.$referanceId.'.*/';
DB::connection('mongodb')->collection('email_message')
->where("reference", 'regexp', $regexQuery)->first();
This will match the referenceId in any position in the string.
As @hetalgotel mentioned in the comments another query for this is:
$mailExists->where("reference", 'like', "%$referanceId%")
This one produced the expected result in this scenario
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
|
show 10 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316576%2fin-mongodb-query-with-lumen-or-and-nor-entries-need-to-be-full-objects%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do this easier with the laravel where method, this will do the comparison you want, and also make your code better readable.
You can use the following query to accomplish this:
DB::connection('mongodb')->collection('email_message')
->where("reference", $referanceId)->first();
If your value contains multiple reference id's as a string you can use:
$regexQuery = '/.*'.$referanceId.'.*/';
DB::connection('mongodb')->collection('email_message')
->where("reference", 'regexp', $regexQuery)->first();
This will match the referenceId in any position in the string.
As @hetalgotel mentioned in the comments another query for this is:
$mailExists->where("reference", 'like', "%$referanceId%")
This one produced the expected result in this scenario
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
|
show 10 more comments
You can do this easier with the laravel where method, this will do the comparison you want, and also make your code better readable.
You can use the following query to accomplish this:
DB::connection('mongodb')->collection('email_message')
->where("reference", $referanceId)->first();
If your value contains multiple reference id's as a string you can use:
$regexQuery = '/.*'.$referanceId.'.*/';
DB::connection('mongodb')->collection('email_message')
->where("reference", 'regexp', $regexQuery)->first();
This will match the referenceId in any position in the string.
As @hetalgotel mentioned in the comments another query for this is:
$mailExists->where("reference", 'like', "%$referanceId%")
This one produced the expected result in this scenario
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
|
show 10 more comments
You can do this easier with the laravel where method, this will do the comparison you want, and also make your code better readable.
You can use the following query to accomplish this:
DB::connection('mongodb')->collection('email_message')
->where("reference", $referanceId)->first();
If your value contains multiple reference id's as a string you can use:
$regexQuery = '/.*'.$referanceId.'.*/';
DB::connection('mongodb')->collection('email_message')
->where("reference", 'regexp', $regexQuery)->first();
This will match the referenceId in any position in the string.
As @hetalgotel mentioned in the comments another query for this is:
$mailExists->where("reference", 'like', "%$referanceId%")
This one produced the expected result in this scenario
You can do this easier with the laravel where method, this will do the comparison you want, and also make your code better readable.
You can use the following query to accomplish this:
DB::connection('mongodb')->collection('email_message')
->where("reference", $referanceId)->first();
If your value contains multiple reference id's as a string you can use:
$regexQuery = '/.*'.$referanceId.'.*/';
DB::connection('mongodb')->collection('email_message')
->where("reference", 'regexp', $regexQuery)->first();
This will match the referenceId in any position in the string.
As @hetalgotel mentioned in the comments another query for this is:
$mailExists->where("reference", 'like', "%$referanceId%")
This one produced the expected result in this scenario
edited Nov 15 '18 at 10:41
answered Nov 15 '18 at 10:11
Sven HakvoortSven Hakvoort
2,2102724
2,2102724
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
|
show 10 more comments
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
my case is like in may database it store as 1,2,3,4,5 and I have to match "1" then I can not use this qyery
– hetal gohel
Nov 15 '18 at 10:13
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
@hetalgohel, as an array or as a string containing these values?
– Sven Hakvoort
Nov 15 '18 at 10:14
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
as string , I have stored it in database
– hetal gohel
Nov 15 '18 at 10:17
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
can we use find_in_set with mongodb?
– hetal gohel
Nov 15 '18 at 10:18
1
1
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
it is working with $mailExists->where("reference", 'like', "%$referanceId%"); as expected result
– hetal gohel
Nov 15 '18 at 10:37
|
show 10 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316576%2fin-mongodb-query-with-lumen-or-and-nor-entries-need-to-be-full-objects%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown