Rev 2068 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Mapper;use LeadersLinked\Model\ChatGroup;use LeadersLinked\Mapper\Common\MapperCommon;use Laminas\Db\Adapter\AdapterInterface;use Laminas\Log\LoggerInterface;use Laminas\Db\Sql\Expression;use LeadersLinked\Hydrator\ObjectPropertyHydrator;class ChatGroupMapper extends MapperCommon{const _TABLE = 'tbl_chat_groups';/**** @var ChatGroupMapper*/private static $_instance;/**** @param AdapterInterface $adapter*/private function __construct($adapter){parent::__construct($adapter);}/**** @param AdapterInterface $adapter* @return ChatGroupMapper*/public static function getInstance($adapter){if(self::$_instance == null) {self::$_instance = new ChatGroupMapper($adapter);}return self::$_instance;}/**** @param ChatGroup $chatGroup* @return boolean*/public function insert($chatGroup){$hydrator = new ObjectPropertyHydrator();$values = $hydrator->extract($chatGroup);$values = $this->removeEmpty($values);$insert = $this->sql->insert(self::_TABLE);$insert->values($values);//echo $insert->getSqlString($this->adapter->getPlatform());$result = $this->executeInsert($insert);if($result) {$chatGroup->id = $this->lastInsertId;}return $result;}/**** @param string $id* @return boolean*/public function deleteByGroupId($id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('id', $id);return $this->executeDelete($delete);}/**** @param string $id* @return ChatGroup*/public function fetchOne($id){$prototype = new ChatGroup();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('id', $id);$select->limit(1);return $this->executeFetchOneObject($select, $prototype);}public function fetchOneHptg($id){$prototype = new ChatGroup();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('high_performance_team_group_id', $id);$select->limit(1);return $this->executeFetchOneObject($select, $prototype);}/**** @param string $uuid* @return ChatGroup*/public function fetchOneByUuid($uuid){$prototype = new ChatGroup();$select = $this->sql->select(self::_TABLE);$select->where->equalTo('uuid', $uuid);$select->limit(1);return $this->executeFetchOneObject($select, $prototype);}public function update($form){$hydrator = new ObjectPropertyHydrator();$values = $hydrator->extract($form);$values = $this->removeEmpty($values);$update = $this->sql->update(self::_TABLE);$update->set($values);$update->where->equalTo('high_performance_team_group_id', $form->high_performance_team_group_id );return $this->executeUpdate($update);}}