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.
php arrays mongodb mongodb-query sql-update
add a comment |
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.
php arrays mongodb mongodb-query sql-update
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
MongoDBDriveris 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
add a comment |
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.
php arrays mongodb mongodb-query sql-update
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
php arrays mongodb mongodb-query sql-update
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
MongoDBDriveris 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
add a comment |
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
MongoDBDriveris 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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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%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
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
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
MongoDBDriveris 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