| Thursday 07 August 2008 6:49:11 am 
                                                                
                                                                 Hello, yesterday I tried to extend the Collected information Export extension (http://projects.ez.no/cie) to export the ezoption datatype. In that course I discovered some strange behaviour where I could not reference an associative array as I thought I could.  
class eZOptionHandler extends BaseHandler{
       function exportAttribute(&$attribute, $seperationChar) {
             echo $array['DataInt'];
             ...
that last statement never produced any output, whereas var_dump($attribute) shows: 
object(ezinformationcollectionattribute)(10) {
  ["PersistentDataDirty"]=>
  bool(false)
  ["Content"]=>
  NULL
  ["ID"]=>
  string(5) "15178"
  ["InformationCollectionID"]=>
  string(5) "11191"
  ["ContentClassAttributeID"]=>
  string(4) "1005"
  ["ContentObjectAttributeID"]=>
  &string(6) "172424"
  ["ContentObjectID"]=>
  &string(5) "20112"
  ["DataText"]=>
  string(0) ""
  ["DataInt"]=>
  string(1) "3"
  ["DataFloat"]=>
  string(1) "0"
}
I have worked around that problem by iterating over the keys of the structure: 
foreach ($attribute as $key => $value) {
      if ($key == 'DataInt') {
           $option_value = $value;
      }
}
I remember somewhere in the back of my mind to have read something about variables/datatypes getting "loaded" from the db only "on demand". Otherwise I have no idea what is going on here. Can anonye explain? 
ThanksOliver
 |