1
Hi I have written a XoopsObject called kbActivity. One of my variables is initialised as type XOBJ_DTYPE_ARRAY. I have a problem retrieving it after assigning. I get the error:
Notice [PHP]: unserialize(): Argument is not a string in file e:\apache\htdocs\getupandgo\kernel\object.php line 343
Here is the portion in the handler where "activities" (my array) is assigned.
function &get($id) {
if (intval($id) > 0) {
$sql = "SELECT * FROM " . $this->db->prefix('kb_locations') . " WHERE lid = " . $id;
if (!$result = $this->db->query($sql)) {
return false;
}
$numrows = $this->db->getRowsNum($result);
if ($numrows == 1) {
$location = new kbLocation();
$location->assignVars($this->db->fetchArray($result));
$sql = "SELECT aid FROM " . $this->db->prefix('kb_activities') . " WHERE lid = " . $id;
if ($result = $this->db->query($sql)) {
$acts = array();
while($row = $this->db->fetchArray($result)){
$activity = serialize(new kbActivity($row['aid']));
$acts[] = $activity;
}
$location->assignVar("activities", $acts);
}
return $location;
}
}
return false;
}
My first problem is that when I call back 'activities' from my object with $this->getVar("activities") I get the error listed above. Do I need to serialize the whole array first manually?
Secondly when I work this problem out do I need to serialize my objects to store them in my array? I'd probably work this one out if I was able to retrieve my inital array first.
Ta,
Stu