Rev 1674 | 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\Hydrator\ObjectPropertyHydrator;
use Laminas\Paginator\Paginator;
use Laminas\Db\ResultSet\HydratingResultSet;
use Laminas\Paginator\Adapter\DbSelect;
use LeadersLinked\Model\CompanyPerformanceEvaluationTestSelf;
class CompanyPerformanceEvaluationTestSelfMapper extends MapperCommon
{
const _TABLE = 'tbl_company_performance_evaluation_tests_self';
/**
*
* @var CompanyPerformanceEvaluationTestSelfMapper
*/
private static $_instance;
/**
*
* @param AdapterInterface $adapter
*/
private function __construct($adapter)
{
parent::__construct($adapter);
}
/**
*
* @param AdapterInterface $adapter
* @return CompanyPerformanceEvaluationTestSelfMapper
*/
public static function getInstance($adapter)
{
if(self::$_instance == null) {
self::$_instance = new CompanyPerformanceEvaluationTestSelfMapper($adapter);
}
return self::$_instance;
}
/**
*
* @param int $id
* @return CompanyPerformanceEvaluationTestSelf
*/
public function fetchOne($id)
{
$prototype = new CompanyPerformanceEvaluationTestSelf();
$select = $this->sql->select(self::_TABLE);
$select->where->equalTo('id', $id);
return $this->executeFetchOneObject($select, $prototype);
}
/**
*
* @param int $id
* @return CompanyPerformanceEvaluationTestSelf
*/
public function fetchOneByTestId($test_id)
{
$prototype = new CompanyPerformanceEvaluationTestSelf();
$select = $this->sql->select(self::_TABLE);
$select->where->equalTo('test_id', $test_id);
return $this->executeFetchOneObject($select, $prototype);
}
/**
*
* @param int $uuid
* @return CompanyPerformanceEvaluationTestSelf
*/
public function fetchOneByUuid($uuid)
{
$prototype = new CompanyPerformanceEvaluationTestSelf();
$select = $this->sql->select(self::_TABLE);
$select->where->equalTo('uuid', $uuid);
return $this->executeFetchOneObject($select, $prototype);
}
/**
*
* @param CompanyPerformanceEvaluationTestSelf $test
* @return boolean
*/
public function insert($test)
{
$hydrator = new ObjectPropertyHydrator();
$values = $hydrator->extract($test);
$values = $this->removeEmpty($values);
$insert = $this->sql->insert(self::_TABLE);
$insert->values($values);
// echo $insert->getSqlString($this->adapter->platform); exit;
$result = $this->executeInsert($insert);
if($result) {
$test->id = $this->lastInsertId;
}
return $result;
}
/**
*
* @param CompanyPerformanceEvaluationTestSelf $test
* @return boolean
*/
public function update($test)
{
$hydrator = new ObjectPropertyHydrator();
$values = $hydrator->extract($test);
$values = $this->removeEmpty($values);
$update = $this->sql->update(self::_TABLE);
$update->set($values);
$update->where->equalTo('id', $test->id);
return $this->executeUpdate($update);
}
/**
*
* @param CompanyPerformanceEvaluationTestSelf $test
* @return boolean
*/
public function delete($test)
{
$delete = $this->sql->delete(self::_TABLE);
$delete->where->equalTo('id', $test->id);
return $this->executeDelete($delete);
}
}