zoukankan      html  css  js  c++  java
  • Drupal启动阶段之三:数据库

    Drupal在数据库启动阶段仅仅是简单地包含了database.inc文件,然后再注册类加载器:

    function _drupal_bootstrap_database() {
      // Initialize the database system. Note that the connection
      // won't be initialized until it is actually requested.
      require_once DRUPAL_ROOT . '/includes/database/database.inc';
    
      // Register autoload functions so that we can access classes and interfaces.
      // The database autoload routine comes first so that we can load the database
      // system without hitting the database. That is especially important during
      // the install or upgrade process.
      spl_autoload_register('drupal_autoload_class');
      spl_autoload_register('drupal_autoload_interface');
    }

    为什么要在database.inc之后注册类加载器?这是因为Drupal的类加载器使用了后台数据库一个名为registry的表,在加载类时会查询该表,所以必须放在database.inc之后。关于Drupal的类加载器可以参考《Drupal如何实现类的自动加载?》。

    必须要注意关于database.inc的这段备注:

    // Initialize the database system. Note that the connection
    // won't be initialized until it is actually requested.

    当前数据库还没有连接,只有真正的请求到来时才会执行连接。

  • 相关阅读:
    开始学习C#
    关于串口数据读取的几个问题
    Joel测试
    VC查找内存泄漏技巧【转】
    思考题一
    自我介绍
    2020面向对象程序设计寒假作业1 题解
    思考题二
    题解 洛谷P2158 【[SDOI2008]仪仗队】
    深入浅出InfoPath系列
  • 原文地址:https://www.cnblogs.com/eastson/p/3363635.html
Copyright © 2011-2022 走看看