oms-QA/Models/QACategoryMapper.php

90 lines
2.0 KiB
PHP

<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types = 1);
namespace Modules\QA\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\Column;
use phpOMS\DataStorage\Database\RelationType;
/**
* Mapper class.
*
* @category Tasks
* @package Modules
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class QACategoryMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array
* @since 1.0.0
*/
protected static $columns = [
'qa_category_id' => ['name' => 'qa_category_id', 'type' => 'int', 'internal' => 'id'],
'qa_category_name' => ['name' => 'qa_category_name', 'type' => 'string', 'internal' => 'name'],
'qa_category_parent' => ['name' => 'qa_category_parent', 'type' => 'int', 'internal' => 'parent'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static $table = 'qa_category';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static $primaryField = 'qa_category_id';
/**
* Create object.
*
* @param mixed $obj Object
* @param int $relations Behavior for relations creation
*
* @return mixed
*
* @since 1.0.0
*/
public static function create($obj, int $relations = RelationType::ALL)
{
try {
$objId = parent::create($obj, $relations);
if ($objId === null || !is_scalar($objId)) {
return $objId;
}
} catch (\Exception $e) {
var_dump($e->getMessage());
return false;
}
return $objId;
}
}