I am having difficultly loading a Pod twice.

Say I load a Pod which is related to another Pod - let's call it the child pod. Later in the page, if I try to load the child pod, I will get empty result.


$pods = new Pod('customization_category');
        $pods->findRecords(array('select' => "t.id, t.name", 'where' => "t.id=$id"));
        $entity = new customization_category_entity;
        $entity->id = $pods->get_field('id');
        $entity->name = $pods->get_field('name');
        $entity->options = array();

        // process options
        $customization_option_model = new customization_option_model();
        $options = $pods->get_field('options');     

        foreach ($options as $v)
            $entity->options[] = $customization_option_model->create_from_array($v);

        return $entity;     

customization_category has a PICK field to the customization_option pod. After I call this code to load the customization_option pod (using $pods->get_field), I will get an empty array if I am do call this code next:

function get_single($id)
        echo "$id = $id<br/>";
        $pod = new Pod('customization_option', $id);
        return $this->create_from_array($pod->fetchRecord());       

    function create_from_array($array)
        $entity = new customization_option_entity();
        $entity->id = $array['id'];
        $entity->name = $array['name'];
        $entity->selection_image = $array['selection_image'];
        $entity->layer_image = $array['layer_image'];
        $entity->price = $array['price'];
        echo '<pre>entity='.print_r($entity, true).'</pre>';

        return $entity;

The code above will load when I load in customization_strategy pod, but later on when I call it again (via the get_single function), it will not work.

Google search yields nothing. Any idea?

1 Answer 1


fetchRecord will load the next record and is only for use when you're using findRecords. When you give an ID to the Pod class, it will automatically fetchRecord for that ID, so calling it again will result in an empty return. Try $pod->data instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.