예제 #1
0
 protected function createCommand(ReflectionMethod $method)
 {
     $methodName = $method->getName();
     $pdo = HermitDataSourceManager::get($this->context->getName(), $methodName, HermitEvent::EVT_SETUP);
     if (null === $pdo) {
         throw new RuntimeException('setup connection fail. pdo: ' . $pdo);
     }
     if (HermitNamingUtils::isProcedure($methodName)) {
         $factory = new HermitProcedureSqlCommandFactory();
     } else {
         if (HermitNamingUtils::isInsert($methodName)) {
             $factory = new HermitInsertSqlCommandFactory();
         } else {
             if (HermitNamingUtils::isUpdate($methodName)) {
                 $factory = new HermitUpdateSqlCommandFactory();
             } else {
                 if (HermitNamingUtils::isDelete($methodName)) {
                     $factory = new HermitDeleteSqlCommandFactory();
                 } else {
                     $factory = new HermitSelectSqlCommandFactory();
                 }
             }
         }
     }
     $factory->setAnnote($this->annote);
     $factory->setMethod($method);
     return $factory->create($pdo, $this->context);
 }
예제 #2
0
 protected function getConnection($event = HermitEvent::UNKNOWN)
 {
     return HermitDataSourceManager::get($this->context->getName(), $this->method->getName(), $event);
 }
예제 #3
0
    public function callIN_OUT_MULTI(HermitParam $param);
    const callINOUT_MULTI_PROCEDURE = 'PROC_INOUT_MULTIRESULT';
    const callINOUT_MULTI_VALUE_TYPE = 'OBJ';
    public function callINOUT_MULTI(HermitParam $param);
    const callOUT_MULTI_PROCEDURE = 'PROC_OUT_MULTIRESULT';
    const callOUT_MULTI_VALUE_TYPE = 'OBJ';
    public function callOUT_MULTI(HermitParam $param);
    const callNOSPEC_PARAM_PROCEDURE = 'PROC_NOSPEC_PARAM';
    const callNOSPEC_PARAM_VALUE_TYPE = 'OBJ';
    public function callNOSPEC_PARAM(HermitParam $param);
}
$pdo = new PDO('mysql:host=localhost; dbname=hermit_test', 'root', 'password');
db_init($pdo);
$test = new lime_test();
$test->diag(basename(__FILE__));
HermitDataSourceManager::setDefault($pdo);
$hermit = new Hermit('PROC');
$param = new HermitParam();
$param->sales = 1000;
$param->tax = -1;
$result = $hermit->callIN_OUT($param);
$test->ok($param->tax !== -1);
$test->is($param->tax, 200);
$test->ok($result === null);
$param = new HermitParam();
$param->sales = 5000;
$result = $hermit->callINOUT($param);
$test->ok($result === null);
$test->is($param->sales, 1000);
$result2 = $hermit->callINOUT($param);
$test->ok($result === null);
예제 #4
0
 protected function getDataSource($methodName, $type)
 {
     $target = $this->context->getName();
     return HermitDataSourceManager::get($target, $methodName, $type);
 }
예제 #5
0
파일: hoge.php 프로젝트: nowelium/Hermit
class Hoge
{
    private $dao;
    public function __construct()
    {
        //HermitDaoManager::set(__CLASS__, 'EmployeeDao');
        $this->dao = new Hermit('EmployeeDao');
    }
    public function getAll()
    {
        return $this->dao->getAllEmployeeList();
    }
    public function getOne()
    {
        return $this->dao->getEmployeeByEmpNo(7698);
    }
    public function getEmp()
    {
        $emp = new Employee();
        $emp->empno = 7566;
        $emp->ename = 'JONES';
        return $this->dao->getEmployee($emp);
    }
}
$pdo = new PDO('sqlite:' . dirname(__FILE__) . '/resource/employee.db');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
HermitDataSourceManager::set('EmployeeDao', $pdo);
$hoge = new Hoge();
echo '[getAll] -----------------', var_export($hoge->getAll(), true), PHP_EOL;
echo '[getOne] -----------------', var_export($hoge->getOne(), true), PHP_EOL;
echo '[getEmp] -----------------', var_export($hoge->getEmp(), true), PHP_EOL;
예제 #6
0
 public static function setCallback(array $callback)
 {
     self::$callback = $callback;
 }