AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Mapper;use LeadersLinked\Model\UserHobbyAndInterest;use LeadersLinked\Mapper\Common\MapperCommon;use Laminas\Db\Adapter\AdapterInterface;use Laminas\Log\LoggerInterface;use LeadersLinked\Hydrator\ObjectPropertyHydrator;class UserHobbyAndInterestMapper extends MapperCommon{const _TABLE = 'tbl_user_hobbies_and_interests';/**** @var UserHobbyAndInterestMapper*/private static $_instance;/**** @param AdapterInterface $adapter*/private function __construct($adapter){parent::__construct($adapter);}/**** @param AdapterInterface $adapter* @return \LeadersLinked\Mapper\UserHobbyAndInterestMapper*/public static function getInstance($adapter){if(self::$_instance == null) {self::$_instance = new UserHobbyAndInterestMapper($adapter);}return self::$_instance;}/**** @param int $user_id* @return UserHobbyAndInterest[]*/public function fetchAllByUserId($user_id){$prototype = new UserHobbyAndInterest;$select = $this->sql->select(self::_TABLE);$select->where->equalTo('user_id', $user_id);return $this->executeFetchAllObject($select, $prototype);}/**** @param int $user_profile_id* @return UserHobbyAndInterest[]*/public function fetchAllByUserProfileId($user_profile_id){$prototype = new UserHobbyAndInterest;$select = $this->sql->select(self::_TABLE);$select->where->equalTo('user_profile_id', $user_profile_id);return $this->executeFetchAllObject($select, $prototype);}/**** @param int $user_profile_id* @return boolean*/public function deleteByUserProfileId($user_profile_id){$delete = $this->sql->delete(self::_TABLE);$delete->where->equalTo('user_profile_id', $user_profile_id);return $this->executeDelete($delete);}/**** @param UserHobbyAndInterest $userHobbyAndInterest* @return boolean*/public function insert($userHobbyAndInterest){$hydrator = new ObjectPropertyHydrator();$values = $hydrator->extract($userHobbyAndInterest);$values = $this->removeEmpty($values);$insert = $this->sql->insert(self::_TABLE);$insert->values($values);return $this->executeInsert($insert);}}