Rev 2143 | AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Mapper;use LeadersLinked\Mapper\Common\MapperCommon;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Model\FeedTopic;use LeadersLinked\Hydrator\ObjectPropertyHydrator;use Laminas\Paginator\Paginator;use Laminas\Db\ResultSet\HydratingResultSet;use Laminas\Paginator\Adapter\DbSelect;class FeedTopicMapper extends MapperCommon{const _TABLE = 'tbl_topics_feed';/**** @var FeedTopicMapper*/private static $_instance;/**** @param AdapterInterface $adapter*/private function __construct($adapter){parent::__construct($adapter);}/**** @param AdapterInterface $adapter* @return FeedTopicMapper*/public static function getInstance($adapter){if(self::$_instance == null) {self::$_instance = new FeedTopicMapper($adapter);}return self::$_instance;}/**** @param int $id* @return FeedTopic*/public function fetchOne($id){$prototype = new FeedTopic();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('id', $id);return $this->executeFetchOneObject($select, $prototype);}/**** @param int $id* @return FeedTopic*/public function fetchOneByFeedId($feed_id){$prototype = new FeedTopic();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('feed_id', $feed_id);return $this->executeFetchOneObject($select, $prototype);}/**** @param int $uuid* @return FeedTopic*/public function fetchOneByUuid($uuid){$prototype = new FeedTopic();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('uuid', $uuid);// echo $select->getSqlString($this->adapter->platform); exit;return $this->executeFetchOneObject($select, $prototype);}/**** @param int $feed_id* @return FeedTopic*/public function fetchAllByFeedId($feed_id){$prototype = new FeedTopic();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('feed_id', $feed_id);//echo $select->getSqlString($this->adapter->platform); exit;return $this->executeFetchAllObject($select, $prototype);}/**** @param int $feed_id* @return FeedTopic*/public function fetchAllByTopicId($topic_id){$prototype = new FeedTopic();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('topic_id', $topic_id);//echo $select->getSqlString($this->adapter->platform); exit;return $this->executeFetchAllObject($select, $prototype);}/**** @param FeedTopic $record* @return boolean*/public function insert($record){$hydrator = new ObjectPropertyHydrator();$values = $hydrator->extract($record);$values = $this->removeEmpty($values);$insert = $this->sql->insert(self::_TABLE);$insert->values($values);//echo $insert->getSqlString($this->adapter->platrecord); exit;$result = $this->executeInsert($insert);if($result) {$record->id = $this->lastInsertId;}return $result;}/**** @param FeedTopic $record* @return boolean*/public function update($record){$hydrator = new ObjectPropertyHydrator();$values = $hydrator->extract($record);$values = $this->removeEmpty($values);$update = $this->sql->update(self::_TABLE);$update->set($values);$update->where->equalTo('id', $record->id);return $this->executeUpdate($update);}/**** @param int $record_id* @return boolean*/public function delete($id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('id', $id);return $this->executeDelete($delete);}}