Category : mongodb

this problem is facing me in my code and i am unable to solve this, so plz help me. $tmp_file = $_FILES[‘image’][‘tmp_name’]; $dst = "proimages/" .basename($filename); //uploading images move_uploaded_file( $tmp_file ,$dst); //insert query $ad_p="INSERT INTO product(`cat_name`, `p_name`, `image`, `keywords`, `price`, `quantity`, `description`, `status`) VALUES (‘[$p_cat_nm]’,'[$p_name]’,'[$filename]’,'[$p_keyword]’,'[$p_price]’,'[$p_quant]’,'[$p_desc]’,'[$p_status]’)"; Sourc..

Read more

i want to use transaction in mongodb in jenssegers/mongodb in this link https://github.com/jenssegers/laravel-mongodb/issues/1334 i tried to used all of the example but its not working my jenssegers/mongodb version is "^3.8.4" Controller: $session = DB::connection(‘mongodb’)->getMongoClient()->startSession(); $session->startTransaction(); try { $db = UserWebsite::create([ ‘userID’ => $dbUser->id, ‘categoryID’ => $dbCategory->id, ‘name’ => $request->name, ‘website’ => $request->website, ‘favIcon’ => $request->favIcon, ..

Read more

model casting on update same value not working on below solutions : protected $casts =[ ‘age’ => ‘integer’ ]; public function setAgeAttribute() { $this->attributes[‘age’] = (int) $this->attributes[‘age’]; } and in controller request()->validate([ ‘name’ => ‘required’, ‘detail’ => ‘required’, ‘age’ => ‘required’, ]); $book->update($request->all()); now when change the age value then casting works but need solution ..

Read more

So, I am trying to add 3 more columns to the already existing table by fetching data from MongoDB. But, it’s giving me a headache. Code in Controller: public function checkPendingPickups(){ $last2DaysDate = date(‘Y-m-d’, strtotime(date(‘Y-m-d’).’ -30 days’)); $orderids = AppModelsCart::where(‘created_at’,’>=’,new DateTime($last2DaysDate))->whereIn(‘order_status’,[‘open’])->whereNotIn(‘cancel_by’,[‘system’,’customer’])->whereNotIn(‘status’,[‘-1’])->lists(‘order_id’)->toArray(); $receivedOrders = $this->packageService->receivedOrders($last2DaysDate); $receviedNDocketNoUpdatedOrders = $this->packageService->getOrdersNotDeliveredDocketStatus($receivedOrders); if(!empty($receviedNDocketNoUpdatedOrders)){ $allOrderids = array_merge($receviedNDocketNoUpdatedOrders,$orderids); $allOrderids = array_unique($allOrderids); }else{ ..

Read more

In PHP I have some data to insert. The sample data is shown below Array ( [0] => Array ( [uuid] => membership-60f929a1989d6960400020 [channel] => channel-594b9e3568ac3969784876 [user] => user-5b1e6e1b636e5325325732 [emailnotifications] => off [email] => [email protected] ) [1] => Array ( [uuid] => membership-60f929a198a1a549293025 [channel] => channel-594b9edcdea14894901526 [user] => user-5b1e6e1b636e5325325732 [emailnotifications] => off [email] => [email protected] ..

Read more

i’m having trouble persisting data using EmbedMany and strategy addToSet. Reference: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.2/reference/storage-strategies.html https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.2/reference/embedded-mapping.html#embed_many When adding more than one Consumer to the embedded collection, the data persistent is not coherent, and also the strategy addToSet that prevents duplicates does not work properly. The main reason is to append data to consumers embedded collection without duplicates Example: ..

Read more