国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

Zend Framework教程之模型Model用法簡單實例

2020-03-22 17:57:34
字體:
來源:轉載
供稿:網友
本文實例講述了Zend Framework教程之模型Model用法。分享給大家供大家參考,具體如下: 附一個簡單粗俗的例子。只是大概說明了用法:如果要深究,可以自己跟蹤源碼了解。 model_demo1 │ .project
│ .buildpath
│ .zfproject.xml

├─.settings
│ org.eclipse.php.core.prefs
│ .jsdtscope
│ org.eclipse.wst.jsdt.ui.superType.name
│ org.eclipse.wst.jsdt.ui.superType.container

├─application
│ │ Bootstrap.php
│ │
│ ├─configs
│ │ application.ini
│ │
│ ├─controllers
│ │ IndexController.php
│ │ ErrorController.php
│ │
│ ├─models
│ │ Test.php
│ │ ModelTest.php
│ │
│ └─views
│ ├─scripts
│ │ ├─index
│ │ │ index.phtml
│ │ │
│ │ └─error
│ │ error.phtml
│ │
│ └─helpers
├─docs
│ README.txt

├─library
│ ├─app
│ │ Test.php
│ │
│ ├─myApp
│ │ Test.php
│ │
│ ├─Zend
│ │ Test.php
│ │
│ ├─AppTest
│ │ Test.php
│ │
│ └─AppTest2
│ Test.php

├─public
│ index.php
│ .htaccess

└─tests
│ phpunit.xml
│ bootstrap.php

├─application
│ └─controllers
│ IndexControllerTest.php

└─library 如下是從上到下,每一個文件的源碼,不再詳細說明: /model_demo1/application/configs/application.ini [production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" autoloadernamespaces.app = "App_" autoloadernamespaces.my = "MyApp_" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 1 [staging : production] [testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 [development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 /model_demo1/application/controllers/IndexController.php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ public function indexAction() { var_dump ( Application_Model_Test::getUserInfo () ); App_Test::echoAppTest (); MyApp_Test::echoAMyAppTest (); Zend_Test::echoZendTest (); AppTest_Test::echoAppTestTest (); $auto_loader = Zend_Loader_Autoloader::getInstance(); $resourceLoader = new Zend_Loader_Autoloader_Resource(array( 'basePath' = '/www/model_demo1/application', 'namespace' = '', 'resourceTypes' = array( 'model' = array( 'path' = 'models', 'namespace' = 'Model' $auto_loader- pushAutoloader($resourceLoader); $auto_loader- registerNamespace(array('AppTest2_')); AppTest2_Test::echoAppTest2Test(); Model_ModelTest::echoModelModelTest(); exit (); /model_demo1/application/models/ModelTest.php class Model_ModelTest{ static function echoModelModelTest(){ echo 'Model_ModelTest br/ /model_demo1/application/models/Test.php class Application_Model_Test { static public function getUserInfo() { return array ( 'user_name' = '張三', 'user_gender' = '男' /model_demo1/application/Bootstrap.php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAutoload() { $app = $this- getApplication (); $namespaces = array ( 'AppTest' $app- setAutoloaderNamespaces ( $namespaces ); return $app; /model_demo1/library/app/Test.php class App_Test { static public function echoAppTest() { echo 'App_Test br/ /model_demo1/library/AppTest/Test.php class AppTest_Test{ static public function echoAppTestTest(){ echo 'AppTestTest br/ /model_demo1/library/AppTest2/Test.php class AppTest2_Test{ static public function echoAppTest2Test(){ echo 'AppTest2Test br/ /model_demo1/library/myApp/Test.php class MyApp_Test { static public function echoAMyAppTest() { echo 'MyApp_Test br/ /model_demo1/library/Zend/Test.php class Zend_Test{ static public function echoZendTest(){ echo 'ZendTest br/ 沒有貼出的代碼,是創建項目默認的代碼。 記住:遵循約定規則,就會避免不必要的麻煩。 更多關于zend相關內容感興趣的讀者可查看本站專題:《Zend FrameWork框架入門教程》、《php優秀開發框架總結》、《Yii框架入門及常用技巧總結》、《ThinkPHP入門教程》、《php面向對象程序設計入門教程》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》 希望本文所述對大家PHP程序設計有所幫助。PHP教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南皮县| 贺兰县| 图们市| 嘉善县| 辰溪县| 喜德县| 施秉县| 建瓯市| 土默特左旗| 邵阳市| 仪征市| 邯郸市| 兰州市| 苏尼特右旗| 新化县| 南雄市| 吴旗县| 永宁县| 荣成市| 怀远县| 吐鲁番市| 五寨县| 会东县| 浠水县| 张家口市| 汉中市| 兴山县| 兰坪| 报价| 郧西县| 罗平县| 库尔勒市| 临洮县| 垣曲县| 合阳县| 宜川县| 邢台市| 黑龙江省| 仲巴县| 河曲县| 鞍山市|