MongoDB update in PHP: update one variable on multiple ids(which represents as variable)











up vote
0
down vote

favorite












I need to update a textual label into the MongoDB database based on the selected checkboxes from the last page in PHP.



For example,



I select 5 checkboxes and enter a textual label in the textbox. In the next page, I need to write the update statement to update the textual label into the database for the 5 selected checkboxes. It means that the 5 selected checkboxes'paths should have the same textual label updated into the database. The database does not include a textual label attribute.notes: selectedIds = selected checkboxes'paths; clusters do not have textLabel, so I have to create here?



$manager = new MongoDBDriverManager('mongodb://username:password@localhost:xxxx/db_name?authSource=db_name'); (the $manger works, it includes the information of username, passwork, db_name, and local_host). 
$updateResult = array();
foreach($selectedImages as $selectedImages){
$result = $manager->update(
array("filename.anonPath" => $selectedImages),
array("clusters_r37_mcs100.textLabel" => $textLabel),
array_push($updateResult,$result);
);
}
print_r("$updateResult");


I have one questions:



The terminal does not display anything whether I succeed to update or not. However, when I check in the MongoDB database, I did not see any textLabel update.



Thank you.










share|improve this question




















  • 1




    "I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
    – Neil Lunn
    Nov 12 at 6:25










  • @NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
    – Jojo717
    Nov 14 at 18:30










  • MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
    – Neil Lunn
    Nov 14 at 21:09















up vote
0
down vote

favorite












I need to update a textual label into the MongoDB database based on the selected checkboxes from the last page in PHP.



For example,



I select 5 checkboxes and enter a textual label in the textbox. In the next page, I need to write the update statement to update the textual label into the database for the 5 selected checkboxes. It means that the 5 selected checkboxes'paths should have the same textual label updated into the database. The database does not include a textual label attribute.notes: selectedIds = selected checkboxes'paths; clusters do not have textLabel, so I have to create here?



$manager = new MongoDBDriverManager('mongodb://username:password@localhost:xxxx/db_name?authSource=db_name'); (the $manger works, it includes the information of username, passwork, db_name, and local_host). 
$updateResult = array();
foreach($selectedImages as $selectedImages){
$result = $manager->update(
array("filename.anonPath" => $selectedImages),
array("clusters_r37_mcs100.textLabel" => $textLabel),
array_push($updateResult,$result);
);
}
print_r("$updateResult");


I have one questions:



The terminal does not display anything whether I succeed to update or not. However, when I check in the MongoDB database, I did not see any textLabel update.



Thank you.










share|improve this question




















  • 1




    "I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
    – Neil Lunn
    Nov 12 at 6:25










  • @NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
    – Jojo717
    Nov 14 at 18:30










  • MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
    – Neil Lunn
    Nov 14 at 21:09













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I need to update a textual label into the MongoDB database based on the selected checkboxes from the last page in PHP.



For example,



I select 5 checkboxes and enter a textual label in the textbox. In the next page, I need to write the update statement to update the textual label into the database for the 5 selected checkboxes. It means that the 5 selected checkboxes'paths should have the same textual label updated into the database. The database does not include a textual label attribute.notes: selectedIds = selected checkboxes'paths; clusters do not have textLabel, so I have to create here?



$manager = new MongoDBDriverManager('mongodb://username:password@localhost:xxxx/db_name?authSource=db_name'); (the $manger works, it includes the information of username, passwork, db_name, and local_host). 
$updateResult = array();
foreach($selectedImages as $selectedImages){
$result = $manager->update(
array("filename.anonPath" => $selectedImages),
array("clusters_r37_mcs100.textLabel" => $textLabel),
array_push($updateResult,$result);
);
}
print_r("$updateResult");


I have one questions:



The terminal does not display anything whether I succeed to update or not. However, when I check in the MongoDB database, I did not see any textLabel update.



Thank you.










share|improve this question















I need to update a textual label into the MongoDB database based on the selected checkboxes from the last page in PHP.



For example,



I select 5 checkboxes and enter a textual label in the textbox. In the next page, I need to write the update statement to update the textual label into the database for the 5 selected checkboxes. It means that the 5 selected checkboxes'paths should have the same textual label updated into the database. The database does not include a textual label attribute.notes: selectedIds = selected checkboxes'paths; clusters do not have textLabel, so I have to create here?



$manager = new MongoDBDriverManager('mongodb://username:password@localhost:xxxx/db_name?authSource=db_name'); (the $manger works, it includes the information of username, passwork, db_name, and local_host). 
$updateResult = array();
foreach($selectedImages as $selectedImages){
$result = $manager->update(
array("filename.anonPath" => $selectedImages),
array("clusters_r37_mcs100.textLabel" => $textLabel),
array_push($updateResult,$result);
);
}
print_r("$updateResult");


I have one questions:



The terminal does not display anything whether I succeed to update or not. However, when I check in the MongoDB database, I did not see any textLabel update.



Thank you.







php arrays mongodb mongodb-query sql-update






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 at 18:33

























asked Nov 12 at 6:21









Jojo717

103




103








  • 1




    "I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
    – Neil Lunn
    Nov 12 at 6:25










  • @NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
    – Jojo717
    Nov 14 at 18:30










  • MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
    – Neil Lunn
    Nov 14 at 21:09














  • 1




    "I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
    – Neil Lunn
    Nov 12 at 6:25










  • @NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
    – Jojo717
    Nov 14 at 18:30










  • MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
    – Neil Lunn
    Nov 14 at 21:09








1




1




"I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
– Neil Lunn
Nov 12 at 6:25




"I have two questions:" - Then you actually should not be asking "two" questions in the one question format of Stack Overflow without posting a new question. And for your "first question", you really need to show the actual error text. But I suspect you only installed the core PHP driver and not the PHPLib driver, which is what you are supposed to be using.
– Neil Lunn
Nov 12 at 6:25












@NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
– Jojo717
Nov 14 at 18:30




@NeilLunn Thak you for the remainder of the format. I have the code. Here is my new issue.
– Jojo717
Nov 14 at 18:30












MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
– Neil Lunn
Nov 14 at 21:09




MongoDBDriver is the wrong driver. That's the core driver as I stated days ago now. Don't bother editing the question. Go to the link I gave you in the comment, read it and install the correct driver and rewrite your code to use that.
– Neil Lunn
Nov 14 at 21:09

















active

oldest

votes











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',
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256840%2fmongodb-update-in-php-update-one-variable-on-multiple-idswhich-represents-as-v%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256840%2fmongodb-update-in-php-update-one-variable-on-multiple-idswhich-represents-as-v%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

How to pass form data using jquery Ajax to insert data in database?

National Museum of Racing and Hall of Fame

Guess what letter conforming each word