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\KnowledgeAreaCategory;use LeadersLinked\Hydrator\ObjectPropertyHydrator;use LeadersLinked\Model\KnowledgeAreaCategoryJobDescription;class KnowledgeAreaCategoryJobDescriptionMapper extends MapperCommon{const _TABLE = 'tbl_knowledge_area_category_jobs_description';/**** @var KnowledgeAreaCategoryJobDescriptionMapper*/private static $_instance;/**** @param AdapterInterface $adapter*/private function __construct($adapter){parent::__construct($adapter);}/**** @param AdapterInterface $adapter* @return KnowledgeAreaCategoryJobDescriptionMapper*/public static function getInstance($adapter){if(self::$_instance == null) {self::$_instance = new KnowledgeAreaCategoryJobDescriptionMapper($adapter);}return self::$_instance;}/**** @param int $category_id* @param int $job_description_id* @return KnowledgeAreaCategoryJobDescription*/public function fetchOneByCategoryIdAndJobDescriptionId($category_id, $job_description_id){$select = $this->sql->select(self::_TABLE);$select->where->equalTo('category_id', $category_id);$select->where->equalTo('job_description_id', $job_description_id);//echo $select->getSqlString($this->adapter->platform);$prototype = new KnowledgeAreaCategoryJobDescription();return $this->executeFetchOneObject($select, $prototype);}/**** @param* @return KnowledgeAreaCategoryJobDescription[]*/public function fetchAllByJobDescriptionId($job_description_id){$select = $this->sql->select(self::_TABLE);$select->where->equalTo('job_description_id', $job_description_id);$prototype = new KnowledgeAreaCategoryJobDescription();return $this->executeFetchAllObject($select, $prototype);}/**** @param int $company_id* @param array $job_description_ids* @return KnowledgeAreaCategoryJobDescription[]*/public function fetchAllByCompanyIdAndJobDescriptionIds($company_id, $job_description_ids){$select = $this->sql->select(self::_TABLE);$select->where->equalTo('company_id', $company_id);$select->where->in('job_description_id', $job_description_ids);$prototype = new KnowledgeAreaCategoryJobDescription();return $this->executeFetchAllObject($select, $prototype);}/**** @param array $job_description_ids* @return KnowledgeAreaCategoryJobDescription[]*/public function fetchAllByJobDescriptionIds($job_description_ids){$select = $this->sql->select(self::_TABLE);$select->where->in('job_description_id', $job_description_ids);$prototype = new KnowledgeAreaCategoryJobDescription();return $this->executeFetchAllObject($select, $prototype);}/**** @param* @return KnowledgeAreaCategoryJobDescription[]*/public function fetchAllByCategoryId($category_id){$select = $this->sql->select(self::_TABLE);$select->where->equalTo('category_id', $category_id);$prototype = new KnowledgeAreaCategoryJobDescription();return $this->executeFetchAllObject($select, $prototype);}/**** @param int $category_id* @return boolean*/public function deleteAllByCategoryId($category_id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('category_id', $category_id);return $this->executeDelete($delete);}/**** @param int $category_id* @param int $job_description_id* @return boolean*/public function deleteOneByCategoryIdAndUserId($category_id, $job_description_id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('category_id', $category_id);$delete->where->equalTo('job_description_id', $job_description_id);return $this->executeDelete($delete);}/**** @param int $id* @return boolean*/public function delete($id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('id', $id);return $this->executeDelete($delete);}/**** @param KnowledgeAreaCategory $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);$result = $this->executeInsert($insert);if($result) {$record->id = $this->lastInsertId;}return $result;}/**** @param KnowledgeAreaCategory $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);}}