AutorÃa | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Mapper;
use LeadersLinked\Mapper\Common\MapperCommon;
use Laminas\Db\Adapter\AdapterInterface;
use LeadersLinked\Model\KnowledgeAreaCategoryContent;
class KnowledgeAreaCategoryContentMapper extends MapperCommon
{
const _TABLE = 'tbl_knowledge_area_category_content';
/**
*
* @var KnowledgeAreaCategoryContentMapper
*/
private static $_instance;
/**
*
* @param AdapterInterface $adapter
*/
private function __construct($adapter)
{
parent::__construct($adapter);
}
/**
*
* @param AdapterInterface $adapter
* @return KnowledgeAreaCategoryContentMapper
*/
public static function getInstance($adapter)
{
if(self::$_instance == null) {
self::$_instance = new KnowledgeAreaCategoryContentMapper($adapter);
}
return self::$_instance;
}
/**
*
* @param int $question_id
* @param int $category_id
* @return KnowledgeAreaCategoryContent
*/
public function fetchOneByQuestionIdAndCategoryId($question_id, $category_id )
{
$select = $this->sql->select(self::_TABLE);
$select->where->equalTo('category_id', $category_id);
$select->where->equalTo('question_id', $question_id);
$prototype = new KnowledgeAreaCategoryContent();
return $this->executeFetchOneObject($select, $prototype);
}
/**
*
* @param
* @return KnowledgeAreaCategoryContent[]
*/
public function fetchAllByQuestionId($question_id)
{
$select = $this->sql->select(self::_TABLE);
$select->where->equalTo('question_id', $question_id);
$prototype = new KnowledgeAreaCategoryContent();
return $this->executeFetchAllObject($select, $prototype);
}
/**
*
* @param int $question_id
* @param int $category_id
* @return boolean
*/
public function deleteByQuestionIdAndCategoryId($question_id, $category_id )
{
$delete = $this->sql->delete(self::_TABLE);
$delete->where->equalTo('category_id', $category_id);
$delete->where->equalTo('question_id', $question_id);
return $this->executeDelete($delete);
}
}