public function indexAction() { $config = Config::singleton(); require $config->get('modelsFolder') . 'indexModel.php'; $db = new indexModel(); $this->data["hello"] = $db->example(); $this->view->show("index.php", $this->data); }
function __construct() { $mod = new indexModel(); $rows = $mod->getRows('*', array(array('name', '=', 'lmyoaoa'))); print_r($rows); /* $rows = $mod->getRowsCount(array( array('name', '=', 'lmyoaoa'), )); print_r($rows); */ $id = $mod->add(array('name' => 'a'), true); var_dump('新增的ID为:' . $id); $up = $mod->update(array(array('name', '=', 'b')), array('name' => "c'")); var_dump($up); }
function run() { require_once $this->sysRoot . '/Model/mysqlModel.php'; require_once $this->sysRoot . '/Model/indexModel.php'; $indexModel = new indexModel(); $newsData = $indexModel->run(); // newsDataを利用してcodeを生成 $code = ''; for ($i = 0; $i < count($newsData); $i++) { $imgPath = ''; if (0 < $newsData[$i]['images']) { // 画像が存在する // So, display it. $imgPath = NEWS_IMAGE_PATH . $newsData[$i]['image_src1']; $imgAlt = $newsData[$i]['image_alt1']; } else { // 画像が存在しない // teamによって表示させる画像を切り替える $imgPath = $this->helpers->teamsImg[$newsData[$i]['team']]; $imgAlt = $this->helpers->teamsName[$newsData[$i]['team']]; } // split for php5.2 $code .= '<li><a href="/news/'; $code .= $newsData[$i]['year']; $code .= '/'; $code .= $newsData[$i]['news_id']; $code .= '">'; $code .= '<div><img src="' . $imgPath . '" alt="' . $imgAlt . '" style="width: 200px;"></div>'; // split for php5.2 //$code .= '<p>' . $newsData[$i]['jpcreated'] . ' / ' . $this->helpers->teamsName[$newsData[$i]['team']] . '</p>'; $code .= '<p>'; $code .= $newsData[$i]['jpcreated']; $code .= ' / '; $code .= $this->helpers->teamsName[$newsData[$i]['team']]; $code .= '</p>'; $code .= '<p>' . $newsData[$i]['title'] . '</p>'; $code .= '</a></li>'; } require_once $this->sysRoot . '/Controller/templateController.php'; $tpl = new templateController($this->sysRoot); $tpl->newsList = $code; $tpl->show($this->sysRoot . '/View/index.php'); }
public function getPages() { if (empty(self::$conn)) { self::$conn = $this->connect_pdo(); } $sql = "SELECT p.id,p.name,p.des,p.image_icon,p.time_on,author_id,CONCAT_WS(' ',first_name,last_name) AS user_name\n\t\t\t\t\tFROM pages AS p\n\t\t\t\t\tLEFT JOIN users AS u\n\t\t\t\t\t\tON u.id=p.author_id\n\t\t\t\t\tORDER BY p.time_on DESC limit 3"; $stmt = self::$conn->query($sql); $pages = array(array()); $i = 0; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $pages[$i++] = $row; } $i--; return $pages; }