コード例 #1
0
ファイル: GenModels.php プロジェクト: eruraindil/MattMVC
 public function __construct()
 {
     $db = Database::get();
     $this->isSqlite = App::DB_TYPE == 'sqlite';
     if ($this->isSqlite) {
         $query = $db->prepare("select name from sqlite_master where type='table'");
     } else {
         $query = $db->prepare("show tables from " . DB_NAME);
     }
     $query->execute();
     //$tables = array();
     while ($rows = $query->fetch(Database::FETCH_CLASSTYPE)) {
         if ($this->isSqlite) {
             $tableQuery = $db->prepare("PRAGMA TABLE_INFO(" . $rows[0] . ");");
         } else {
             $tableQuery = $db->prepare("show columns from " . $rows[0]);
         }
         $tableQuery->execute();
         $rows['columns'] = array();
         while ($tableRows = $tableQuery->fetch(Database::FETCH_OBJ)) {
             $rows['columns'][] = $tableRows;
         }
         $this->genFile($rows);
     }
 }
コード例 #2
0
ファイル: Model.php プロジェクト: eruraindil/MattMVC
 /**
  * create a new instance of the database helper
  */
 public function __construct()
 {
     //connect to PDO here.
     $this->_db = Database::get();
 }