freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

zend_framework(編輯修改稿)

2025-08-28 16:14 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 able::setDefaultAdapter($db)。 ? 初始化數(shù)據(jù)庫(kù)連接 配置文件 ? 為了訪問(wèn)數(shù)據(jù)庫(kù),必須先配置使用的數(shù)據(jù)庫(kù)及登錄數(shù)據(jù)庫(kù)的用戶名密碼等信息,把這些信息保存在配置文件中,更便于以后的更新,配置文件存放在 application目錄下,戒者存在在單獨(dú)目錄中 application/config ? 使用 Zend_Config來(lái)提供靈活的面向?qū)ο笤L問(wèn)配置文件,配置文件可以是 PHP數(shù)組、一個(gè)INI文件戒者 XML文件。 [general] =PDO_MYSQL =localhost =root =root =bookdb =gb2312 Zend_Config ? 在 // load configuration $config = new Zend_Config_Ini(39。../application/39。, 39。general39。)。 $registry = Zend_Registry::getInstance()。 $registryset(39。config39。, $config)。 // setup database $db = Zend_Db::factory($configdb)。 $dbquery(“SET NAMES ‘”. $configdbparamscharset.“’”)。 // 設(shè)置字符集 Zend_Db_Table::setDefaultAdapter($db)。//設(shè)置默認(rèn)適配器 ? //load configuration – 構(gòu)造 Zend_Config_Ini和 Zend_Registry對(duì)象 – 讀取 “ general”節(jié)中的數(shù)據(jù) – 保存 $config對(duì)象到 $registry對(duì)象中,留以后其他地方使用 ? // setup database – 創(chuàng)建 Zend_Db對(duì)象,并讀取配置信息 – 設(shè)置操作數(shù)據(jù)庫(kù)字符集 – 通過(guò) Zend_Db對(duì)象的靜態(tài)方法將 db注冊(cè)到Zend_Db_Table中 模型 ? 現(xiàn)在該是考慮模型的時(shí)候了。記住,模型是用來(lái)處理程序的核心議題(即所謂的“商業(yè)規(guī)則” business rules) ? 管理我們的圖書(shū)是我們要考慮的業(yè)務(wù)核心,使用 Zend_Db_Table類來(lái)完成這個(gè)功能,由于它是抽象類,所以我們繼承它來(lái)創(chuàng)建管理圖書(shū)的數(shù)據(jù)庫(kù)模型 Zend_Db_Table ? Zend_Db_Table 是 Zend Framework的表模塊。它通過(guò) zend_db_adapter連接到 數(shù)據(jù)庫(kù),為數(shù)據(jù)庫(kù)模式檢查表對(duì)象,并對(duì)該表迚行操作和查詢。 ? Zend_DB_Table為抽象類,所以丌能直接實(shí)例化 ,只能先繼承該類 ,然后實(shí)例化子類 擴(kuò)展 Zend_Db_Table ? 模型根據(jù)操作的數(shù)據(jù)庫(kù)來(lái)創(chuàng)建 – 類名:使用的數(shù)據(jù)庫(kù)表名 – 屬性:設(shè)置 $_name屬性為要操作的表名 ? 存放路徑: – application\models\ ?php class Books extends Zend_Db_Table{ protected $_name = ‘books’。// 表明 //protected $_primary=39。id39。默認(rèn)表名 class_name,默認(rèn)主鍵 id } ? 數(shù)據(jù)庫(kù)操作 ? 揑入數(shù)據(jù) /*insert book(id,name,title) values(39。20139。,39。alex39。,39。PHP39。)*/ $books=new Books()。 $data=array(39。id39。=39。20139。, 39。name39。=39。alex39。, 39。title39。=39。PHP39。)。 $id=$booksinsert($data)。//返回?fù)I入數(shù)據(jù)行號(hào) ? 更新數(shù)據(jù) /*update books set name=39。alex001839。 where id=39。20139。*/ $books=new Books()。 $db=$booksgetAdapter()。 $set=array(39。name39。=39。alex001839。)。 $where=$dbquoteInto(39。id=?39。,39。20139。)。 $row_affected=$booksupdate($set,$where)。 //返回更新行數(shù) ? 刪除數(shù)據(jù) /*delete from books where name=39。alex001839。*/ $books=new Books()。 $db=$booksgetAdapter()。 $where=$dbquoteInto(39。name=?39。,39。alex001839。)。 $row_affected=$booksdelete($where)。 //返回刪除行數(shù) Zend_Db_Table_Row ? 該類丌能實(shí)例化,只能通過(guò)調(diào)用Zend_Db_Table::find()方法戒者Zend_Db_Table::fetchRow()做為結(jié)果數(shù)據(jù)返回過(guò)來(lái),一旦得到對(duì)象還可以迚行記錄值的修改等操作。 ? 取回一條記錄和修改一條記錄 $books = new Books()。 // 從表中取回的結(jié)果數(shù)據(jù)是一個(gè) Zend_Db_Table_Row對(duì)象 $row = $booksfetchRow(39。name = alex39。)。 // $row現(xiàn)在是一個(gè)帶有多種公有屬性的Zend_Db_Table_Row對(duì)象 // that map to table // $rowid = 39。20139。 // $rowname = 39。alex39。 // $rowtitle = 39。PHP‘ // $rowsave()。 保存修改,但丌能修改主鍵 ? 設(shè)置查詢條件取回一條記錄 /*select * from books where title=39。PHP39。 and name=39。alex39。 order by id*/ $books=new Books()。 $db=$booksgetAdapter()。 $where=$dbquoteInto(39。title=?39。,39。PHP39。) . $dbquoteInto(39。 and name=?39。,39。alex39。)。 $order=39。id39。 $row=$booksfetchRow($where,$order)。 //返回滿足條件的第一行數(shù)據(jù)的Zend_Db_Table_Row對(duì)象 . Zend_Db_Table_Rowset ? Zend_Db_Table_Rowset是 Zend_Db_Table_Row對(duì)象集合的迭代器。通常來(lái)說(shuō),你丌可以自己實(shí)例化該對(duì)象,而是通過(guò)調(diào)用 Zend_Db_Table::find()方法戒者fetchAll()方法將 Zend_Db_Table_Rowset作為結(jié)果數(shù)據(jù)返回過(guò)來(lái),接下來(lái)就可以遍歷Zend_Db_Table_Row對(duì)象集合并迚行修改 ? 根據(jù)主鍵查找數(shù)據(jù) $books=new Books()。 /*select * from books where id=39。20139。*/ $rows=$booksfind(201)。 /*select * from books where id in(39。20139。, 39。20239。, 39。20339。,)*/ $rows=$booksfind(array(201,202,203))。 //返回滿足條件的 Zend_Db_Table_Rowset對(duì)象 $rows=$booksfetchAll()。 //返回所有的記錄 ? 取回多條記錄 $books=new Books()。 $db = $booksgetAdapter()。 /*select * from books where title=39。PHP39。 order by id limit 10 offset 20*/ $where = $dbquoteInto(39。title=?39。, 39。PHP39。)。 $order = 39。id39。 $count = 10。 $offset = 20。 $rowset = $booksfetchAll($where, $order, $count, $offset)。 //返回滿足條件的數(shù)據(jù)的 Zend_Db_Table_Rowset對(duì)象 程序核心部分 ? 顯示圖書(shū)列表 ? 添加圖書(shū) ? 編輯圖書(shū) ? 刪除圖書(shū) 顯示圖書(shū)列表 ? 控制器 function indexAction(){ $thisviewtitle=我的圖書(shū)館 。 $books = new Books()。 $thisviewbooks = $booksfetchAll()。 } ? 視圖: application\views\scripts\index\ pa href=?php echo $thisurl(array(39。controller39。=39。index39。,39。action39。=39。add39。))。?添加圖書(shū)/a/p table tr thTitle/th thName/th th /th /tr ?php foreach($thisbooks as $book) : ? tr td?php echo $thisescape($booktitle)。?/td td?php echo $thisescape($bookname)。?/td td a href=?php echo $thisurl(array(39。controller39。=39。index39。, 39。action39。=39。edit39。, 39。id39。=$bookid))。?編輯 /a a href=?php echo $thisurl(array(39。controller39。=39。index39。, 39。action39。=39。delete39。, 39。id39。=$bookid))。?刪除 /a /td /tr ?php endforeach。 ? /t
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1