Example #1
0
 /**
  * @return DAO
  * @param string $name
  */
 public static function get($name)
 {
     static $_daos;
     if (!$_daos) {
         $_daos = array();
     }
     if (!isset($_daos[$name])) {
         //自動生成を行う
         $implClassName = $name . "DAOImpl";
         if (!class_exists($implClassName)) {
             $filepath = DB::getConfigure("cache_dir") . "/" . $name . "DAO.php";
             DAOBuilder::create($name)->write($filepath);
             require $filepath;
             if (!class_exists($implClassName)) {
                 throw new \Exception("failed to load " . $name . "DAO");
             }
         }
         $dao = new $implClassName();
         $_daos[$name] = $dao;
     }
     $dao = $_daos[$name];
     $dao->setLimit(null);
     $dao->setOffset(null);
     return $dao;
 }
Example #2
0
 /**
  * @return DAOBase
  */
 public static function DAO()
 {
     $daoClassName = __CLASS__ . "DAO";
     if (class_exists($daoClassName . "Impl")) {
         //check implemented
         return DAO::get(__CLASS__);
     }
     $filepath = DB::getConfigure("cache_dir") . DIRECTORY_SEPARATOR . $daoClassName . ".php";
     // 		if(file_exists($filepath)){
     // 			require $filepath;
     // 			return DAO::get(__CLASS__);
     // 		}
     //DAOを作成する
     if (class_exists(DAO::class)) {
         DAOBuilder::create(__CLASS__)->write($filepath);
         require $filepath;
     }
     return DAO::get(__CLASS__);
 }