mongodb-php

Mongodb php query, search in array?

房东的猫 提交于 2021-02-10 03:26:49
问题 I am looking for a way to search for a keyword (ex. "Henrik") in the "answers" array of documents with the following structure Array ( [_id] => MongoId Object ( [$id] => 4eeedd9545c717620a000007 ) [formId] => 6 [respId] => 4eeedd95c93228 [dateCreated] => 2011-10-14 07:45 [answers] => Array ( [field1] => Henrik [field6] => myemail@domain.com [field7] => my city address ) ) I am working in PHP on this project, and quering like this works of course: $answers = $collection->find( array('formId' =

Mongodb php query, search in array?

时光怂恿深爱的人放手 提交于 2021-02-10 03:23:31
问题 I am looking for a way to search for a keyword (ex. "Henrik") in the "answers" array of documents with the following structure Array ( [_id] => MongoId Object ( [$id] => 4eeedd9545c717620a000007 ) [formId] => 6 [respId] => 4eeedd95c93228 [dateCreated] => 2011-10-14 07:45 [answers] => Array ( [field1] => Henrik [field6] => myemail@domain.com [field7] => my city address ) ) I am working in PHP on this project, and quering like this works of course: $answers = $collection->find( array('formId' =

Mongodb php query, search in array?

Deadly 提交于 2021-02-10 03:22:47
问题 I am looking for a way to search for a keyword (ex. "Henrik") in the "answers" array of documents with the following structure Array ( [_id] => MongoId Object ( [$id] => 4eeedd9545c717620a000007 ) [formId] => 6 [respId] => 4eeedd95c93228 [dateCreated] => 2011-10-14 07:45 [answers] => Array ( [field1] => Henrik [field6] => myemail@domain.com [field7] => my city address ) ) I am working in PHP on this project, and quering like this works of course: $answers = $collection->find( array('formId' =

Laravel: Unable to JSON encode payload. Error code: 5

只谈情不闲聊 提交于 2021-01-24 05:00:48
问题 I'm working on Laravel (v5.7) app that converts uploaded CSV (with contacts) into array that is then passed as argument when job class is being dispatched. Here is the example of CSV file (format that is supported): 123456,Richard,Smith 654321,John,Doe Uploaded (CSV) file is handled like this: $file_path = $request->file_name->store('contacts'); $file = storage_path('app/' . $file_path); $contactsIterator = $this->getContacts($file); $contacts = iterator_to_array($contactsIterator); // Array

Laravel: Unable to JSON encode payload. Error code: 5

北慕城南 提交于 2021-01-24 04:48:54
问题 I'm working on Laravel (v5.7) app that converts uploaded CSV (with contacts) into array that is then passed as argument when job class is being dispatched. Here is the example of CSV file (format that is supported): 123456,Richard,Smith 654321,John,Doe Uploaded (CSV) file is handled like this: $file_path = $request->file_name->store('contacts'); $file = storage_path('app/' . $file_path); $contactsIterator = $this->getContacts($file); $contacts = iterator_to_array($contactsIterator); // Array

Laravel: Unable to JSON encode payload. Error code: 5

删除回忆录丶 提交于 2021-01-24 04:48:38
问题 I'm working on Laravel (v5.7) app that converts uploaded CSV (with contacts) into array that is then passed as argument when job class is being dispatched. Here is the example of CSV file (format that is supported): 123456,Richard,Smith 654321,John,Doe Uploaded (CSV) file is handled like this: $file_path = $request->file_name->store('contacts'); $file = storage_path('app/' . $file_path); $contactsIterator = $this->getContacts($file); $contacts = iterator_to_array($contactsIterator); // Array

MongoDB Schema Design (nested array vs separate collection)

99封情书 提交于 2020-02-24 12:17:08
问题 I'm writing client management web application. I'm trying to figure out the right way to manage my clients-payments relations. Once a day application is sending request to another API and synchronizing amount of payments for each client which I store in my database. I constantly need to run reports on payments (amount of payments) based on type of client (contract_type, sale_date and so on). I already have a clients collection. I trying to choice between two schema: { "client_id": "asdf123",

MongoDB Aggregation PHP, Group by Hours

旧城冷巷雨未停 提交于 2020-01-21 02:32:52
问题 I have documents with the following format { "_id" : ObjectId("12e123123123123123"), "client_id" : "12345667889", "resource" : "test/test", "version" : "v2", "ts" : new Date("Wed, 02 Jan 2013 15:34:58 GMT +08:00") } The ts is a MongoDate() field. I am trying to use MongoDB aggregate function in php to group by client_id and hour and count usage to display in a table/graph This is my current attempt $usage = $this->db->Usage->aggregate(array(array( '$project' => array( 'hour' => array( 'years'

MongoDB Aggregation PHP, Group by Hours

跟風遠走 提交于 2020-01-21 02:32:04
问题 I have documents with the following format { "_id" : ObjectId("12e123123123123123"), "client_id" : "12345667889", "resource" : "test/test", "version" : "v2", "ts" : new Date("Wed, 02 Jan 2013 15:34:58 GMT +08:00") } The ts is a MongoDate() field. I am trying to use MongoDB aggregate function in php to group by client_id and hour and count usage to display in a table/graph This is my current attempt $usage = $this->db->Usage->aggregate(array(array( '$project' => array( 'hour' => array( 'years'

mongodb php Strings to float values

亡梦爱人 提交于 2020-01-16 07:52:43
问题 I tried make it from mongodb console, but it doesn't work, because I can not work with arrays like afrray[0] afrray[1] afrray[2] etc How to change array elements Now I try to do it from php, but i see only zeros in base (((( What do I wrong? $out = $collection->update( array("type" => 'chair'), array('$set' => array( 'vmfqvfjptu' => floatval('vmfqvfjptu'), 'versions.0.content.vmfqvfjptu'=> floatval('versions.0.content.vmfqvfjptu'), 'versions.1.content.vmfqvfjptu'=> floatval('versions.1