Zend Framework Tutorial Model Usage Simple example, zendframework_php tutorial

Source: Internet
Author: User
Tags zend framework

Zend Framework Tutorial Model Usage Simple example, zendframework


This example describes the model usage of the Zend Framework tutorial. Share to everyone for your reference, as follows:

Attach a simple and vulgar example. Just about the usage: if you want to drill down, you can follow the source code to understand.

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
││
│└─helper S
├─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

The following is from top to bottom, each file source code, no longer detailed description:

/model_demo1/application/configs/application.ini

[production]phpsettings.display_startup_errors = 1phpsettings.display_errors = 1includepaths.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 = 1phpsettings.display_errors = 1[development:production] Phpsettings.display_startup_errors = 1phpsettings.display_errors = 1resources.frontcontroller.params.displayexceptions = 1

/model_demo1/application/controllers/indexcontroller.php

<?phpclass Indexcontroller extends Zend_controller_action {public function init () {/* Initializ    E 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 ' = ' and ', ' resourcetypes ' = = Array (' model ' = = Array (' path ' +    Odels ', ' namespace ' = ' Model ')));    $auto _loader->pushautoloader ($resourceLoader);    $auto _loader->registernamespace (Array (' apptest2_ '));    Apptest2_test::echoapptest2test ();    Model_modeltest::echomodelmodeltest ();  Exit (); }}

/model_demo1/application/models/modeltest.php

<?phpclass model_modeltest{  static function Echomodelmodeltest () {    echo ' model_modeltest
'; }}

/model_demo1/application/models/test.php

<?phpclass application_model_test {  static public function GetUserInfo () {    return array (        ' user_name ' =& Gt ' Zhang San ',        ' user_gender ' = ' male '    );  }

/model_demo1/application/bootstrap.php

<?phpclass 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

<?phpclass app_test {  static public function echoapptest () {    echo ' app_test
'; }}

/model_demo1/library/apptest/test.php

<?phpclass apptest_test{  static public Function echoapptesttest () {    echo ' apptesttest
'; }}

/model_demo1/library/apptest2/test.php

<?phpclass apptest2_test{  static public Function echoapptest2test () {    echo ' apptest2test
'; }}

/model_demo1/library/myapp/test.php

<?phpclass myapp_test {  static public function echoamyapptest () {    echo ' myapp_test
'; }}

/model_demo1/library/zend/test.php

<?phpclass zend_test{  static public Function echozendtest () {    echo ' zendtest
'; }}

The code that is not posted is the default code for creating the project.

Remember: Following the Convention rules will avoid unnecessary hassles.

More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Zend Framework Tutorial Model basic rules and how to use them
    • Zend Framework Tutorial Zend_layout Layout Assistant Detailed
    • Methods of using Memcache in the Zend Framework
    • Resolution of URL case problem in Zend Framework frame
    • Zend Framework 2.0 Event Manager (the EventManager) Getting Started tutorial
    • Zend Framework Page Cache instance
    • Very useful Zend Framework paging class
    • Layout in the Zend Framework (modular layout) detailed
    • Zend Framework Configuration Operations Database instance analysis
    • Windows Zendframework Project Environment Setup (via command line configuration)

http://www.bkjia.com/PHPjc/1106111.html www.bkjia.com true http://www.bkjia.com/PHPjc/1106111.html techarticle Zend Framework Tutorial Model Usage Simple example, zendframework This example describes the Zend framework tutorial model usage. Share to everyone for your reference, as follows: ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.