public static function factory(stdClass $result) { $self = new self(); $self->_id = isset($result->id) ? $result->id : NULL; $self->_name = isset($result->filename) ? $result->filename : NULL; $self->_description = isset($result->description) ? new Showcase_Article($result->description) : NULL; $self->_path = isset($result->filepath) ? $result->filepath : NULL; $self->_type = isset($result->filetype) ? Showcase_Type::factory($result->filetype) : NULL; $self->_stream_path = isset($result->stream_path) ? $result->stream_path : NULL; $self->_filetype_name = isset($result->filetype_name) ? $result->filetype_name : NULL; $self->_category = isset($result->category) ? $result->category instanceof stdClass ? Showcase_Category::factory($result->category) : new Showcase_Category($result->category) : NULL; $self->_identifier = isset($result->identifier) ? $result->identifier : NULL; $self->_status = isset($result->status) ? $result->status : NULL; return $self; }
private function setChildren($arr, $id = null, $max = false, $iteration = 0) { if (!$arr) { return false; } $iteration++; if ($max && $iteration > $max) { return false; } $children = array(); reset($arr); while ($a = current($arr)) { //print_r($a->inherits); die; if ($a->inherits == $id) { $child_array = $this->setChildren($arr, $a->id, $max, $iteration); // put the id as key of the array as pass it trough the object $children[$a->id] = Showcase_Category::factory($a, $child_array); } next($arr); } return $children; }
protected function _getCategory($mediaId) { try { $stmt = Zend_Registry::get('dbh')->proc('get_categories_by_media_id'); $stmt->bindParam(':id', $mediaId, PDO::PARAM_INT); try { $stmt->execute(); $category = $stmt->fetch(PDO::FETCH_OBJ); $stmt->closeCursor(); } catch (Zend_Db_Statement_Exception $e) { die($e->getMessage()); } return $category; } catch (Zend_Db_Statement_Exception $e) { die(__LINE__ . ':' . __FILE__ . ':' . $e->getMessage()); } $category = Showcase_Category::factory($category); return $category; }