protected function from_db_row($row) { set_fields($this, $row, array('id' => 'id', 'url' => 'url', 'reason_code' => 'status', 'submitted' => 'when_submitted')); if (!is_null($row['expected_journo'])) { $this->expected_journo = array_to_object($row, array('expected_journo' => 'id', 'expected_ref' => 'ref', 'expected_prettyname' => 'prettyname')); } else { $this->expected_journo = null; } if (!is_null($row['submitted_by'])) { $this->submitted_by = array_to_object($row, array('submitted_by' => 'id', 'submitted_by_name' => 'name', 'submitted_by_email' => 'email')); } else { $this->submitted_by = NULL; } if (!is_null($row['article_id'])) { $this->article = array_to_object($row, array('article_id' => 'id', 'article_title' => 'title', 'article_byline' => 'byline')); // $this->article->authors = array(); $author_refs = preg_split("/[{},]/", $row['attributed'], -1, PREG_SPLIT_NO_EMPTY); foreach ($author_refs as $ref) { $author = new stdClass(); $author->ref = $ref; $this->article->authors[] = $author; } } else { $this->article = NULL; } }
function insert_fields($entity_class, $data = array()) { UIFacade::insert($entity_class, set_fields($entity_class, $data)); }
function array_to_object($src_array, $fields) { $ob = new stdClass(); set_fields($ob, $src_array, $fields); return $ob; }