<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 使用命名空間(Working with Namespaces) [Namespaces](http://php.net/manual/en/language.namespaces.php)可以用來避免類名的沖突,比如如果在一個應用中有兩個控制器使用同樣的名稱,那么可以用namespace來區分他們。 另外命名空間在創建組件或者模塊的時候也是非常有用的。 ## 設置框架(Setting up the framework) Using namespaces has some implications when loading the appropriate controller. To adjust the framework behavior to namespaces is necessary to perform one or all of the following tasks: Use an autoload strategy that takes into account the namespaces, for example with[Phalcon\\Loader](http://docs.iphalcon.cn/api/Phalcon_Loader.html): ~~~ <?php $loader->registerNamespaces( [ "Store\\Admin\\Controllers" => "../bundles/admin/controllers/", "Store\\Admin\\Models" => "../bundles/admin/models/", ] ); ~~~ Specify it in the routes as a separate parameter in the route’s paths: ~~~ <?php $router->add( "/admin/users/my-profile", [ "namespace" => "Store\\Admin", "controller" => "Users", "action" => "profile", ] ); ~~~ Passing it as part of the route: ~~~ <?php $router->add( "/:namespace/admin/users/my-profile", [ "namespace" => 1, "controller" => "Users", "action" => "profile", ] ); ~~~ If you are only working with the same namespace for every controller in your application, then you can define a default namespace in the Dispatcher, by doing this, you don’t need to specify a full class name in the router path: ~~~ <?php use Phalcon\Mvc\Dispatcher; // Registering a dispatcher $di->set( "dispatcher", function () { $dispatcher = new Dispatcher(); $dispatcher->setDefaultNamespace( "Store\\Admin\\Controllers" ); return $dispatcher; } ); ~~~ ## 控制器加入命名空間(Controllers in Namespaces) The following example shows how to implement a controller that use namespaces: ~~~ <?php namespace Store\Admin\Controllers; use Phalcon\Mvc\Controller; class UsersController extends Controller { public function indexAction() { } public function profileAction() { } } ~~~ ## 模型加入命名空間(Models in Namespaces) Take the following into consideration when using models in namespaces: ~~~ <?php namespace Store\Models; use Phalcon\Mvc\Model; class Robots extends Model { } ~~~ If models have relationships they must include the namespace too: ~~~ <?php namespace Store\Models; use Phalcon\Mvc\Model; class Robots extends Model { public function initialize() { $this->hasMany( "id", "Store\\Models\\Parts", "robots_id", [ "alias" => "parts", ] ); } } ~~~ In PHQL you must write the statements including namespaces: ~~~ <?php $phql = "SELECT r.* FROM Store\Models\Robots r JOIN Store\Models\Parts p"; ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看