public static function I($arg_pdo) { if (is_null(self::$instance)) { self::$instance = new self(); } self::$pdo = $arg_pdo; return self::$instance; }
<?php $rootPass = dirname(__FILE__) . '/../../'; // $rootPass = dirname(__FILE__). '/../'; require_once $rootPass . 'lib/db/dbfunctions.php'; require_once $rootPass . 'lib/db/dbFacade.php'; $pdo = getPDO($argv[1]); // $pdo = getPDO('test'); $dbfacade = DBFacade::I($pdo); header("Content-Type: application/json; charset=utf-8"); echo json_encode($dbfacade->getAllLog());
public function testfindLOCAByUserID() { $pmapper = new PaymentMapper(self::$pdo); $dmapper = new DepositMapper(self::$pdo); $dbfacade = DBFacade::I(self::$pdo); $payment = getPaymentInstance(); $deposit = getDepositInstance(); $pmapper->insert($payment); $dmapper->insert($deposit); $result = $dbfacade->findLOCALogByUserID(1); // instanceは二つともuser_id=1になっているため $this->assertEquals(2, count($result)); }