AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Mapper;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Hydrator\ObjectPropertyHydrator;use Laminas\Log\LoggerInterface;use LeadersLinked\Model\Engagement;use LeadersLinked\Mapper\Common\MapperCommon;class EngagementMapper extends MapperCommon{const _TABLE = 'tbl_engagement';/**** @var EngagementMapper*/private static $_instance;/**** @param AdapterInterface $adapter*/private function __construct($adapter){parent::__construct($adapter);}/**** @param AdapterInterface $adapter* @return EngagementMapper*/public static function getInstance($adapter){if(self::$_instance == null) {self::$_instance = new EngagementMapper($adapter);}return self::$_instance;}/**** @param int $company_id* @return Engagement*/public function fetchOneByCompanyId($company_id){$select = $this->sql->select(self::_TABLE);$select->where->equalTo('company_id', $company_id);$select->limit(1);$prototype = new Engagement();return $this->executeFetchOneObject($select, $prototype);}/**** @param Engagement $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);return $this->executeInsert($insert);}/**** @param Engagement $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('company_id', $record->company_id);return $this->executeUpdate($update);}}