当前位置: 首页>>代码示例>>PHP>>正文


PHP parent::installed方法代码示例

本文整理汇总了PHP中parent::installed方法的典型用法代码示例。如果您正苦于以下问题:PHP parent::installed方法的具体用法?PHP parent::installed怎么用?PHP parent::installed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parent的用法示例。


在下文中一共展示了parent::installed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __constructStatic

 public static function __constructStatic()
 {
     /**
      * Get DB config
      */
     $config = \Lobby::config(true);
     if (is_array($config)) {
         /**
          * Make DB credentials variables from the config.php file
          */
         self::$prefix = $config['prefix'];
         self::$type = $config['type'];
         $options = array(\PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
         try {
             if ($config['type'] === 'mysql') {
                 self::$dbh = new \PDO("mysql:dbname={$config['dbname']};host={$config['host']};port={$config['port']};charset=utf8;", $config['username'], $config['password'], $options);
                 /**
                  * Check if Lobby tables exist
                  */
                 $notable = false;
                 $tables = array("options", "data");
                 // The Tables of Lobby
                 foreach ($tables as $tableName) {
                     $results = self::$dbh->prepare("SHOW TABLES LIKE ?");
                     $results->execute(array(self::$prefix . $tableName));
                     if ($results->rowCount() == 0) {
                         $notable = true;
                     }
                 }
             } else {
                 if ($config['type'] === 'sqlite') {
                     self::$dbh = new \PDO("sqlite:" . \Lobby\FS::loc($config['path']), "", "", $options);
                     /**
                      * Enable Multithreading Read/Write
                      */
                     self::$dbh->exec("PRAGMA journal_mode=WAL;");
                     /**
                      * Check if Lobby tables exist
                      */
                     $sql = self::$dbh->query("SELECT COUNT(1) FROM `sqlite_master` WHERE `type` = 'table' AND (`name` = 'l_data' OR `name` = 'l_options')");
                     $notable = $sql->fetchColumn() === "2" ? false : true;
                 }
             }
             if ($notable === false) {
                 /* There are database tables */
                 parent::$installed = true;
             } else {
                 parent::log(array("fatal", "Tables required by Lobby was not found in the database. Check your <b>config.php</b> and database to fix the error. Or Install again by removing <b>config.php</b>."));
             }
         } catch (\PDOException $e) {
             parent::$installed = false;
             $error = $e->getMessage();
             parent::log(array("fatal", "Unable to connect to database server. Is the database credentials given in <b>config.php</b> correct ? <blockquote>{$error}</blockquote>"));
         }
     } else {
         self::$installed = false;
     }
 }
开发者ID:LobbyOS,项目名称:server,代码行数:58,代码来源:DB.php

示例2: init

 public static function init()
 {
     $root = L_DIR;
     $config = \Lobby::config(true);
     if (is_array($config)) {
         /**
          * Make DB credentials variables from the config.php file
          */
         self::$prefix = $config['prefix'];
         $options = array(\PDO::ATTR_PERSISTENT => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION);
         try {
             self::$dbh = new \PDO("mysql:dbname={$config['dbname']};host={$config['host']};port={$config['port']}", $config['username'], $config['password'], $options);
             $notable = false;
             $tables = array("options", "data");
             // The Tables of Lobby
             foreach ($tables as $tableName) {
                 $results = self::$dbh->prepare("SHOW TABLES LIKE ?");
                 $results->execute(array(self::$prefix . $tableName));
                 if ($results->rowCount() == 0) {
                     $notable = true;
                 }
             }
             if ($notable === false) {
                 /* There are database tables */
                 parent::$installed = true;
             } else {
                 self::$error = "Lobby Tables Not Found";
                 self::log("Lobby Tables not found in database. Install Again.");
             }
         } catch (\PDOException $e) {
             parent::$installed = false;
             $error = $e->getMessage();
             self::$error = $error;
             $GLOBALS['initError'] = array("Couldn't Connect To Database", "Unable to connect to database server. Is the credentials given in <b>config.php</b> correct ? <blockquote>" . $error . "</blockquote>");
             self::log("Unable to connect to database server : " . $error);
         }
     } else {
         self::$installed = false;
     }
 }
开发者ID:anandubajith,项目名称:lobby,代码行数:40,代码来源:Database.php


注:本文中的parent::installed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。