コード例 #1
0
ファイル: index.php プロジェクト: limweb/kotchasan
 /**
  * inint index
  */
 public function index()
 {
     // ถ้าไม่มีโมดูลเลือกหน้า home
     $module = empty($_GET['module']) ? 'home' : $_GET['module'];
     // สร้าง View
     $view = $this->createClass('Index\\Index\\View');
     // template default
     $view->add(array('MENU' => $this->createClass('Index\\Menu\\Controller')->render($module), 'TITLE' => 'Welcome to GCMS++', 'CONTENT' => \Template::load('', '', $module), 'TIME' => \Datetool::format(\Kotchasan::$mktime)));
     // output เป็น HTML
     $view->renderHTML();
 }
コード例 #2
0
ファイル: index.php プロジェクト: limweb/kotchasan
 public function index()
 {
     // อ่านรายชื่อฟิลด์ของตาราง
     $model = Recordset::create('Index\\World\\Model');
     $fields = $model->getFileds();
     echo implode(', ', array_keys($fields)) . '<br>';
     // ลบข้อมูลทั้งตาราง
     $model->truncate();
     // insert new record
     for ($i = 0; $i < 10000; $i++) {
         $query = World::create();
         $query->updated_at = \Datetool::mktimeToSqlDateTime(\Kotchasan::$mktime);
         $query->save();
     }
     // อัปเดททุก record
     $model->updateAll(array('created_at' => \Datetool::mktimeToSqlDateTime(\Kotchasan::$mktime)));
     // อ่านจำนวนข้อมูลทั้งหมดในตาราง
     echo 'All ' . $model->count() . ' records.<br>';
     // สุ่ม record มาแก้ไข
     for ($i = 0; $i < 5; $i++) {
         $rnd = rand(1, 10000);
         $world = $model->find($rnd);
         $world->name = 'Hello World!';
         $world->save();
     }
     // query รายการที่มีการแก้ไข
     $model->where(array('name', '!=', ''));
     // อ่านจำนวนข้อมูลที่พบ
     echo 'Found ' . $model->count() . ' records.<br>';
     // แสดงผลรายการที่พบ
     foreach ($model->all('id', 'name') as $item) {
         echo $item->id . '=' . $item->name . '<br>';
         // ลบรายการที่กำลังแสดงผล
         $item->delete();
     }
     // อ่านรายชื่อฟิลด์ของ query
     $fields = $model->getFileds();
     echo implode(', ', array_keys($fields)) . '<br>';
     // อ่านจำนวนข้อมูลที่เหลือ
     echo 'Remain ' . Recordset::create('Index\\World\\Model')->count() . ' records.<br>';
 }