Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 523551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:28:27+00:00 2026-05-13T08:28:27+00:00

I have a function which would query database and get content if it exists

  • 0

I have a function which would query database and get content if it exists for particular id and in there I have this Piece of Code:

var_dump($a); ---STEP 1
return $a     ---STEP 2
var_dump($a); ---STEP 3
exit();       ---STEP 4

When I do var_dump($a), it gives me —STEP 1

    object(ArrayObject)[67]
  public 'shoppingBasket' => 
    array
      'offers' => 
        array
          10 => 
            array
              ...
          11224 => 
            array
              ...
  public 'recommendations' => 
    array
      10017 => 
        array
          'object_id' => string '10017' (length=5)
          'offer_type' => string 'Atomic' (length=6)
          'family' => string '' (length=0)
          'is_unica' => boolean false
          'financial_terms' => 
            array
              ...
          'contract_constraints' => 
            array
              ...
          'prices' => 
            array
              ...

as $a is of ArrayObject type but when I use return $a and than var_dump($a) than it gives me — STEP 3

O:11:"ArrayObject":2:{s:14:"shoppingBasket";a:1:{s:6:"offers";a:2:{i:10;a:8:{s:9:"object_id";s:2:"10";s:6:"family";s:8:"Internet";s:8:"is_unica";b:1;s:10:"offer_type";s:6:"Atomic";s:24:"product_specification_id";s:6:"134455";s:20:"contract_constraints";a:5:{s:19:"min_contract_period";s:1:"1";s:13:"notice_period";s:2:"12";s:15:"rollover_period";s:1:"1";s:18:"right_of_wd_period";s:1:"1";s:19:"cancellation_period";s:6:"ALWAYS";}s:15:"financial_terms";a:3:{s:14:"billing_period";a:2:{i:0;s:6:"YEARLY";i:1;s:9:"QUARTERLY";}s:14:"payment_method";a:1:{i:0;s:12:"DIRECT_DEBIT";}s:17:"bill_presentation";a:1:{i:0;s:5:"PAPER";}}s:6:"prices";a:1:{i:25;a:1:{s:9:"object_id";s:2:"25";}}}i:11224;a:8:{s:9:"object_id";s:5:"11224";s:6:"family";s:8:"Internet";s:8:"is_unica";b:0;s:10:"offer_type";s:11:"DOUBLE_PLAY";s:24:"product_specification_id";s:5:"32567";s:20:"contract_constraints";a:5:{s:19:"min_contract_period";s:1:"8";s:13:"notice_period";s:1:"2";s:15:"rollover_period";s:1:"6";s:18:"right_of_wd_period";s:1:"1";s:19:"cancellation_period";s:12:"END_OF_MONTH";}s:15:"financial_terms";a:3:{s:14:"billing_period";a:2:{i:0;s:6:"YEARLY";i:1;s:9:"QUARTERLY";}s:14:"payment_method";a:1:{i:0;s:12:"DIRECT_DEBIT";}s:17:"bill_presentation";a:1:{i:0;s:5:"PAPER";}}s:6:"prices";a:0:{}}}}s:15:"recommendations";a:1:{i:10017;a:7:{s:9:"object_id";s:5:"10017";s:10:"offer_type";s:6:"Atomic";s:6:"family";s:0:"";s:8:"is_unica";b:0;s:15:"financial_terms";a:3:{s:14:"billing_period";a:1:{i:0;s:9:"QUARTERLY";}s:14:"payment_method";a:1:{i:0;s:12:"DIRECT_DEBIT";}s:17:"bill_presentation";a:1:{i:0;s:5:"PAPER";}}s:20:"contract_constraints";a:5:{s:19:"min_contract_period";i:24;s:19:"cancellation_period";s:6:"ALWAYS";s:13:"notice_period";i:3;s:15:"rollover_period";i:2;s:18:"right_of_wd_period";i:1;}s:6:"prices";a:1:{i:99;a:1:{s:9:"object_id";s:2:"99";}}}}}

I am not sure why its happening this way, normally if we have content in database for particular id than we query the database and get the content for that particular id.

Q: But am not sure why am getting different values for $a in here, any suggestions ?

Q: How can I unserialize the STEP 3 output in php. I have tried using unserialize function but its not working.

Thanks.

Update:

Here is the function which is calling associateCollateral function:

  public function getOfferById($id, $raw = FALSE)
        {
                $offers = $this->getOfferDao()->getByID($id);
                $offer_count = $offers->count();
                //var_dump($offer_count);
                //exit();
                // Throw an exception if no results were found.
                if (!$offers->count())
                {
                        throw new Exception("No offers were found while searching for ids: {$id}.");
                }

                if (!$raw)
                {
                        $offers = $this->validateOffers($offers);
                }


                // Associate collateral content with offers to send back.
                return $this->associateCollateral($offers);
                //$val = $this->associateCollateral($offers);
                //echo "Here is the value of Associate Collateral \n";
                //var_dump($val);
                //exit();

        }

Here is the associateCollateral Function, when the associateCollateral function is called than it would go and check into collateral content database and will look if the provided content id has some collateral content and if it does than it would go and get the collateral content.

  private function associateCollateral($entities)
        {
                //var_dump($entities);

                // Extract all object ids from the given set of ids, and pass into the getContentId.
                $content_ids = $this->getCollateralDao()->getContentId(array_keys($entities->offsetGet('recommendations')));
                // Call to CMS to get collateral content.
                /*foreach($content_ids as $content_id)
                {
                         $contentObj = CmsObjectHandler::get(OBJECT_TYPE_CONTENT,$content_id);
                         $content = $contentObj->getContent();
                         $result += $content;
                         echo"Here \n";
                         print_r($result)."\n";
                         //exit();
                }*/
                var_dump($entities);  ---STEP1
                return $entities;     ---STEP2
                //var_dump($entities);  ---STEP3
                //exit();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:28:27+00:00Added an answer on May 13, 2026 at 8:28 am

    It seems I don’t have enough reputation to Comment. So this is not an answer but a request for more information.

    Simply put its not possible for PHP to serialise the data out of thin air. something between the return from your function eg return $a; (step 2) and the var_dump($a) (step 3) call is serialising the data.

    You will need to provide a larger snippet of the code including the call to the function and whatever happens after the call to that function and before var_dump (step 3)

    Do you call var_dump immediately after the function return?
    Is the function called via another function?

    DC

    Ok

    Step 3 is never executed in associateCollateral(). I had wondered if your original question was just shortened or an error

                var_dump($entities);  ---STEP1
                return $entities;     ---STEP2 <== function is exited  
                var_dump($entities);  ---STEP3 <== never executed
                //exit();
    

    This means the echo you are seeing with the serialised output is from another part of your code

    DC

    There is another print statement somewhere in your code displaying the serialised data. Comment out all the var_dump statements and run it again. My guess is that the serialised data will still be output.
    Don’t forget serialised data is merely a string so it can be output by an echo or print statement which could be anywhere in your code. Probably somewhere after the getOfferById() function is called.

    If the serialised data is not output after commenting out the var_dump statements, then re-enable each one one at a time until the serialised data re-appears. but this scenario is highly unlikely given the information you have provided

    DC

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 296k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Do not perform actions on encoded strings; decode to unicode… May 13, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer Another answer already suggested pyinotify for Linux, let me add… May 13, 2026 at 7:12 pm
  • Editorial Team
    Editorial Team added an answer You could do something like the following: <% form_for @user,… May 13, 2026 at 7:12 pm

Related Questions

In codeigniter, as you know, a page of the form: /class/function/ID , where class
Stack Overflowers: I have a search function on my company's website (based on .NET
I want to make sure a file path set via query string does not
PHP mysql database I have created a follow on question to this one here
I'm fairly new to LINQ in general but I've managed to figure things out

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.