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


PHP Dba::dbh方法代码示例

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


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

示例1: get_version

 /**
  * get_version
  *
  * This checks to see what version you are currently running.
  * Because we may not have the update_info table we have to check
  * for its existence first.
  */
 public static function get_version()
 {
     $version = "";
     /* Make sure that update_info exits */
     $sql = "SHOW TABLES LIKE 'update_info'";
     $db_results = Dba::read($sql);
     if (!Dba::dbh()) {
         header("Location: test.php");
     }
     // If no table
     if (!Dba::num_rows($db_results)) {
         // They can't upgrade, they are too old
         header("Location: test.php");
     } else {
         // If we've found the update_info table, let's get the version from it
         $sql = "SELECT * FROM `update_info` WHERE `key`='db_version'";
         $db_results = Dba::read($sql);
         $results = Dba::fetch_assoc($db_results);
         $version = $results['value'];
     }
     return $version;
 }
开发者ID:bl00m,项目名称:ampache,代码行数:29,代码来源:update.class.php

示例2: install_create_config

/**
 * install_create_config
 *
 * Attempts to write out the config file or offer it as a download.
 */
function install_create_config($download = false)
{
    $config_file = AmpConfig::get('prefix') . '/config/ampache.cfg.php';
    /* Attempt to make DB connection */
    Dba::dbh();
    $params = AmpConfig::get_all();
    if (empty($params['database_username']) || empty($params['database_password']) && strpos($params['database_hostname'], '/') !== 0) {
        Error::add('general', T_("Invalid configuration settings"));
        return false;
    }
    // Connect to the DB
    if (!Dba::check_database()) {
        Error::add('general', T_("Database Connection Failed Check Hostname, Username and Password"));
        return false;
    }
    $final = generate_config($params);
    // Make sure the directory is writable OR the empty config file is
    if (!$download) {
        if (!check_config_writable()) {
            Error::add('general', T_('Config file is not writable'));
            return false;
        } else {
            // Given that $final is > 0, we can ignore lazy comparison problems
            if (!file_put_contents($config_file, $final)) {
                Error::add('general', T_('Error writing config file'));
                return false;
            }
        }
    } else {
        $browser = new Horde_Browser();
        $browser->downloadHeaders('ampache.cfg.php', 'text/plain', false, strlen($final));
        echo $final;
        exit;
    }
    return true;
}
开发者ID:nioc,项目名称:ampache,代码行数:41,代码来源:install.lib.php


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