如何在mongodb codeigniter中更新数组值

时间:2017-02-05 09:28:52

标签: arrays mongodb codeigniter mongodb-query

我有这样的收藏品,

"machine" : [
         {
                 "machine_name" : "C",
                 "machine_type" : "Analog",
                 "tonnage" : "53",
                 "indicator" : "asd",
                 "specification" : {
                         "list_of_specification" : "dsfd"
                 },
                 "required_software" : "wer",
                 "version" : "3.3",
                 "price" : "10000",
                 "warranty_period" : "2 years",
                 "amc_charge" : "6000",
                 "machine_identification_number" : "fd",
                 "software" : {
                         "renewal_cost" : "df",
                         "current_version" : "df",
                         "installed_date" : "02/28/2017",
                         "end_date" : "03/07/2017",
                         "software_type" : "df",
                         "updates" : {
                                 "version" : "df",
                                 "updated_by" : "df",
                                 "updated_on" : "03/08/2017",
                                 "end_date" : "03/07/2017"
                         }
                 },
                 "stamping" : {
                         "next_stamping_date" : "02/21/2017",
                         "last_stamping_date" : "03/01/2017",
                         "stamping_details" : {
                                 "stamped_on" : "02/21/2017",
                                 "stamped_by" : "df",
                                 "comments" : "fd"
                         }
                 },
                 "amc" : {
                         "amc_cost" : "f",
                         "next_renewal_date" : "03/07/2017",
                         "last_renewed_date" : "03/06/2017",
                         "amc_paid" : {
                                 "amc_paid_date" : "02/21/2017",
                                 "amc_valid_upto" : "02/13/2017"
                         }
                 },
                 "operator" : {
                         "operator_id" : "df",
                         "operator_name" : "df",
                         "phone_number" : "df",
                         "mail_id" : "df",
                         "timing" : "df"
                 },
                 "payment" : {
                         "payment_id" : "df",
                         "payment_amount" : "df",
                         "payment_date" : "03/07/2017",
                         "payment_comments" : "df",
                         "payment_type" : "cdf"
                 }
         },
         {
                 "machine_name" : "B",
                 "machine_type" : "Digital",
                 "tonnage" : "40",
                 "indicator" : "sdasd",
                 "specification" : {
                         "list_of_specification" : "sds"
                 },
                 "required_software" : "wer",
                 "version" : "2.31",
                 "price" : "30000",
                 "warranty_period" : "2 year",
                 "amc_charge" : "5000",
                 "machine_identification_number" : "a",
                 "software" : {
                         "renewal_cost" : "8900",
                         "current_version" : "12",
                         "installed_date" : "02/22/2017",
                         "end_date" : "02/22/2017",
                         "software_type" : "as",
                         "updates" : {
                                 "version" : "d",
                                 "updated_by" : "d",
                                 "updated_on" : "03/09/2017",
                                 "end_date" : "02/22/2017"
                         }
                 },
                 "stamping" : {
                         "next_stamping_date" : "02/22/2017",
                         "last_stamping_date" : "02/14/2017",
                         "stamping_details" : {
                                 "stamped_on" : "03/01/2017",
                                 "stamped_by" : "",
                                 "comments" : "fd"
                         }
                 },
                 "amc" : {
                         "amc_cost" : "df",
                         "next_renewal_date" : "03/05/2017",
                         "last_renewed_date" : "02/27/2017",
                         "amc_paid" : {
                                 "amc_paid_date" : "03/07/2017",
                                 "amc_valid_upto" : "02/21/2017"
                         }
                 },
                 "operator" : {
                         "operator_id" : "df",
                         "operator_name" : "df",
                         "phone_number" : "9865978452",
                         "mail_id" : "sugan",
                         "timing" : "df"
                 },
                 "payment" : {
                         "payment_id" : "as",
                         "payment_amount" : "",
                         "payment_date" : "03/01/2017",
                         "payment_comments" : "",
                         "payment_type" : ""
                 }
         }
 ]

如何使用MongoDB Codeigniter更新文本框中的单个数组值?

1 个答案:

答案 0 :(得分:0)

我通过使用以下查询得到了这个问题的答案....

$ this-> mongo_db-> where(array(" machine.machine_identification_number" => $ machine_identification_number)) - > set(" machine。$", $数据) - >更新('顾客&#39);