public function testToArrayDeep() { $author = new Author(); $author->setId(5678); $author->setFirstName('George'); $author->setLastName('Byron'); $book = new Book(); $book->setId(9012); $book->setTitle('Don Juan'); $book->setISBN('0140422161'); $book->setPrice(12.99); $book->setAuthor($author); $coll = new PropelObjectCollection(); $coll->setModel('Book'); $coll[] = $book; $expected = array(array('Id' => 9012, 'Title' => 'Don Juan', 'ISBN' => '0140422161', 'Price' => 12.99, 'PublisherId' => null, 'AuthorId' => 5678, 'Author' => array('Id' => 5678, 'FirstName' => 'George', 'LastName' => 'Byron', 'Email' => null, 'Age' => null, 'Books' => array('Book_0' => '*RECURSION*')))); $this->assertEquals($expected, $coll->toArray()); }
protected function setUp() { parent::setUp(); $publisher = new Publisher(); $publisher->setId(1234); $publisher->setName('Penguin'); $author = new Author(); $author->setId(5678); $author->setFirstName('George'); $author->setLastName('Byron'); $book = new Book(); $book->setId(9012); $book->setTitle('Don Juan'); $book->setISBN('0140422161'); $book->setPrice(12.99); $book->setAuthor($author); $book->setPublisher($publisher); $this->book = $book; }
/** * Retrieve all authors from published papers * @param $schedConfId int * @return $authors array Author Objects */ function getPublishedPaperAuthors($schedConfId) { $primaryLocale = AppLocale::getPrimaryLocale(); $locale = AppLocale::getLocale(); $authors = array(); $result =& $this->retrieve('SELECT aa.*, aspl.setting_value AS affiliation_pl, asl.setting_value AS affiliation_l FROM authors aa LEFT JOIN published_papers pa ON (pa.paper_id = aa.submission_id) LEFT JOIN author_settings aspl ON (aspl.author_id = aa.author_id AND aspl.setting_name = ? AND aspl.locale = ?) LEFT JOIN author_settings asl ON (asl.author_id = aa.author_id AND asl.setting_name = ? AND asl.locale = ?) WHERE pa.sched_conf_id = ?', array('affiliation', $primaryLocale, 'affiliation', $locale, (int) $schedConfId)); while (!$result->EOF) { $row = $result->GetRowAssoc(false); $author = new Author(); $author->setId($row['author_id']); $author->setSubmissionId($row['paper_id']); $author->setFirstName($row['first_name']); $author->setMiddleName($row['middle_name']); $author->setLastName($row['last_name']); $author->setAffiliation($row['affiliation_pl'], $primaryLocale); $author->setAffiliation($row['affiliation_l'], $locale); $author->setEmail($row['email']); $author->setBiography($row['biography']); $author->setPrimaryContact($row['primary_contact']); $author->setSequence($row['seq']); $authors[] = $author; $result->moveNext(); } $result->Close(); unset($result); return $authors; }
/** * Test the BaseObject#equals(). */ public function testEquals() { $b = BookPeer::doSelectOne(new Criteria()); $c = new Book(); $c->setId($b->getId()); $this->assertTrue($b->equals($c), "Expected Book objects to be equal()"); $a = new Author(); $a->setId($b->getId()); $this->assertFalse($b->equals($a), "Expected Book and Author with same primary key NOT to match."); }
/** * Retrieve all authors from published papers * @param $schedConfId int * @return $authors array Author Objects */ function getPublishedPaperAuthors($schedConfId) { $authors = array(); $result =& $this->retrieve('SELECT aa.* FROM paper_authors aa, published_papers pa WHERE aa.paper_id = pa.paper_id AND pa.sched_conf_id = ? ORDER BY pa.sched_conf_id', $schedConfId); while (!$result->EOF) { $row = $result->GetRowAssoc(false); $author = new Author(); $author->setId($row['author_id']); $author->setPaperId($row['paper_id']); $author->setFirstName($row['first_name']); $author->setMiddleName($row['middle_name']); $author->setLastName($row['last_name']); $author->setAffiliation($row['affiliation']); $author->setEmail($row['email']); $author->setBiography($row['biography']); $author->setPrimaryContact($row['primary_contact']); $author->setSequence($row['seq']); $authors[] = $author; $result->moveNext(); } $result->Close(); unset($result); return $authors; }
/** * Internal function to return an Author object from a row. * @param $row array * @return Author */ function &_returnAuthorFromRow(&$row) { $author = new Author(); $author->setId($row['author_id']); $author->setPaperId($row['paper_id']); $author->setFirstName($row['first_name']); $author->setMiddleName($row['middle_name']); $author->setLastName($row['last_name']); $author->setAffiliation($row['affiliation']); $author->setCountry($row['country']); $author->setEmail($row['email']); $author->setUrl($row['url']); $author->setPrimaryContact($row['primary_contact']); $author->setSequence($row['seq']); $this->getDataObjectSettings('paper_author_settings', 'author_id', $row['author_id'], $author); HookRegistry::call('AuthorDAO::_returnAuthorFromRow', array(&$author, &$row)); return $author; }
/** * Retrieve all authors from published articles * @param $issueId int * @return $authors array Author Objects */ function getPublishedArticleAuthors($issueId) { $primaryLocale = Locale::getPrimaryLocale(); $locale = Locale::getLocale(); $authors = array(); $result =& $this->retrieve('SELECT aa.* FROM authors aa LEFT JOIN published_articles pa ON (pa.article_id = aa.submission_id) WHERE pa.issue_id = ? ORDER BY pa.issue_id', (int) $issueId); while (!$result->EOF) { $row = $result->GetRowAssoc(false); $author = new Author(); $author->setId($row['author_id']); $author->setSubmissionId($row['article_id']); $author->setFirstName($row['first_name']); $author->setMiddleName($row['middle_name']); $author->setLastName($row['last_name']); $author->setAffiliation($row['affiliation_pl'], $primaryLocale); $author->setAffiliation($row['affiliation_l'], $locale); $author->setEmail($row['email']); $author->setBiography($row['biography']); $author->setPrimaryContact($row['primary_contact']); $author->setSequence($row['seq']); $authors[] = $author; $result->moveNext(); } $result->Close(); unset($result); return $authors; }
public function testToKeyValue() { $author = new Author(); $author->setId(5678); $author->setFirstName('George'); $author->setLastName('Byron'); $book = new Book(); $book->setId(9012); $book->setTitle('Don Juan'); $book->setISBN('0140422161'); $book->setPrice(12.99); $book->setAuthor($author); $coll = new PropelObjectCollection(); $coll->setModel('Book'); $coll->append($book); $this->assertCount(1, $coll); // This will call $book->getId() $this->assertEquals(array(9012 => 'Don Juan'), $coll->toKeyValue('Id', 'Title')); // This will call: $book->getAuthor()->getBooks()->getFirst()->getId() $this->assertEquals(array(9012 => 'Don Juan'), $coll->toKeyValue(array('Author', 'Books', 'First', 'Id'), 'Title')); }
function getAllAuthor() { $key = 'author'; $collection = CacheManager::get($key, TRUE); if ($collection) { return $collection; } $collection = new Collection(); $this->connect(); $result = $this->conn->query("CALL sp_get_all_author()"); if ($result) { //$row = $result->fetch_assoc(); while ($obj = $result->fetch_object()) { $author = new Author(); $author->setId($obj->Author_id); $author->setName($obj->Author_name); $collection->addItem($author, $obj->Author_id); } $result->close(); // for fetch_object() } //$result->free_result(); // for fetch_assoc() $this->close(); CacheManager::set($key, $collection, TRUE); return $collection; }
private function _toObject($row) { $author = new Author(); $author->setId($row->AvtorId); $author->setFirstName($row->FirstName); $author->setMiddleName($row->MiddleName); $author->setLastName($row->LastName); $author->setHomePage($row->HomePage); $author->setNickname($row->NickName); $author->setBooksNumber($row->BooksNumber); return $author; }