N1ql query returns array instead of object in php sdk 3.0

hi
i am trying to upgrade from php sdk 2.6 to 3.o the issue i am facing right now is . Niql query returning array instead of object as it was return object in sdk 2.6. is there any way to get object or i need to replace my code with array instead of object ?

thanks

hello @muhammad_ibrahim use our migration guide this should help you

HI thanks. I have read it everything is fine. My issue is my app is displaying data as object previously it was return object when i was using php sdk 2.6 but now its returning array using n1ql. The doc is also saying the same that in sdk 3.0 it returns array. Is there any way to get return data as object without doing any casting in php.I am saying this because my app becomes huge now. Thanks

Hi @muhammad_ibrahim, can you show what N1QL query you are running? Is the query supposed to return a single document?

HI,

Here is the code for single doc its returning array for both for single plus multiple

//GETTING THE SINGLE RECORD FROM DB

                $result = $this->db_obj->get("branch_".$single_store->code)->content();

                $result['is_admin']         = $single_store->is_admin;

                $result['mall']             = $single_store->mall;

                $result['telephone']        = $single_store->telephone;

                $result['contact']          = $single_store->contact;

                $result['address']          = $single_store->address;

                $result['city']             = $single_store->city;

                $result['province']         = $single_store->province;

                $result['postalcode']       = $single_store->postalcode;

                $result['ll']               = $single_store->ll;

                $result['sqft']             = $single_store->sqft;

                $result['status']           = $single_store->status;

                $result['tax_name']         = $single_store->tax_name;

                $result['email_address']    = $single_store->email_address;

                $result['pst']              = (double) $single_store->pst;

                $result['gst']              = (double) $single_store->gst;

                $result['regular_hrs']      = (int) $single_store->regular_hrs;

                $result['daily_hrs']        = (int) 8;

                $result['stat_holiday_rate'] = (double) 1.5;

                $result['overtime_rate']    = (double) 1.5;

                $result['service_date']     = $single_store->service_date;

                $result['cost_center']      = $single_store->cost_center;

                $result['overtime']         = (double)$single_store->overtime;

                $result['birhtday']         = (double)$single_store->birhtday;

                $result['stat_hol']         = (double)$single_store->stat_hol;

                $result['statwork']         = (double)$single_store->statwork;

                $result['meetcon']          = (double)$single_store->meetcon;

                $result['personel']         = (double)$single_store->personel;

                $result['sickhrs']          = (double)$single_store->sickhrs;

                $result['vacations']        = (double)$single_store->vacations;

                $result['bereavmt']         = (double)$single_store->bereavmt;

                $result['training']         = (double)$single_store->training;

                $result['tax_code']         =  $single_store->tax_code;

                $result['enable_email_sms'] = $single_store->enable_email_sms;

                $result['updated_date']     = $single_store->updated_date;

                $result = $this->db_obj->REPLACE('branch_'.$single_store->code,$result);

//HERE IS FOR MULTIPLE DOCS

$query = "SELECT branch.*, region.country, region.province_name, region.region_name FROM bucket1 branch LEFT JOIN bucket1 region ON region.region_id = branch.province AND region.type = ‘region’

    WHERE  ( LOWER(branch.contact) LIKE  LOWER('%$this->search_keyword%')

    OR LOWER(branch.code) LIKE LOWER('%$this->search_keyword')

    OR LOWER(branch.mall) LIKE LOWER('%$this->search_keyword'))

    AND branch.type = 'branch' ORDER BY branch.updated_date ASC LIMIT 20";

    $result = $this->cluster->query($query);

    return $result->rows();

Same issue. Went from queries returning objects, now outputting assoc arrays.

Could not find any mention in documentation that this significant change has been made. I have noticed that in each example on this page shows clearly 2.x using Objects, 3.X using assoc arrays.
https://docs.couchbase.com/php-sdk/current/project-docs/migrating-sdk-code-to-3.n.html

PHP 7.4
Debian 10
Couchbase SDK 3.1
Couchbase CE 6.6

Updated from CB 2.6 to 3.1.

Tried PHP.ini configs recommended on Transcoder settings, no impact or change in the output at all.

Any guidance on how to force objects?

So this investigation took us 16 hours. The fix was using couchbase.decoder.json_arrays=false in the ini. Make sure to use that = sign!

Put this in both your CLI and Apache php.ini file.