Created
June 11, 2013 14:31
-
-
Save sugarHoge/5757297 to your computer and use it in GitHub Desktop.
SELECT⇒結果(連想配列)⇒View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Zend/Db.php'; | |
class MainController extends Zend_Controller_Action | |
{ | |
public function init() | |
{ | |
} | |
public function indexAction() | |
{ | |
$param = $this->getRequest()->getParam('token'); | |
if ($param !== "aaa") { | |
throw new Zend_Exeption("不正使用エラー"); | |
} | |
// DB接続情報を連想配列に格納 | |
$dbInit = array( | |
'host' => 'localhost', | |
'username' => 'root', | |
'password' => 'mysql123', | |
'dbname' => '_udkrent', | |
'charset' => 'utf8' | |
); | |
try { | |
// 接続 | |
$db = Zend_Db::factory('Pdo_Mysql', $dbInit); | |
$dat = new Zend_Date(); | |
$nowDate = $dat->toString("yyyy-MM-dd"); | |
$this->view->nowDate = $nowDate; | |
$sql = 'SELECT * FROM dtb_order where create_date >= "' . "2010-06-09" .'"'; | |
$result = $db->query($sql); | |
$row = $result->fetchAll(); | |
$count = count($row); | |
} catch (Zend_Exception $e) { | |
// 例外発生時 | |
die($e->getMessage()); | |
} | |
// DBへの接続を切断 | |
$db->closeConnection(); | |
$this->view->newOrderKensu = "【" . $count . "件】"; | |
$this->view->hoge = $row; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php foreach ($this->hoge as $val): ?> | |
<li><a><?php echo $val['order_name01'] . $val['order_name02'] ?></a></li> | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment