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


PHP TikiDb::set方法代码示例

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


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

示例1: die

$api_tiki = 'adodb';
$local_php = __DIR__ . '/local.php';
require_once $local_php;
$style_base = 'skeleton';
// Force autoloading
if (!class_exists('ADOConnection')) {
    die('AdoDb not found.');
}
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$initializer = new TikiDb_Initializer();
$initializer->setPreferredConnector($api_tiki);
$db = $initializer->getConnection(array('host' => $host_tiki, 'user' => $user_tiki, 'pass' => $pass_tiki, 'dbs' => $dbs_tiki, 'charset' => $client_charset));
if (!$db) {
    die("\nUnable to connect to the database\n\n");
}
TikiDb::set($db);
global $tikilib;
require_once 'lib/tikilib.php';
$tikilib = new TikiLib();
// update db if needed
require_once 'lib/init/initlib.php';
include_once 'installer/installlib.php';
$installer = new Installer();
if (!$installer->tableExists('tiki_preferences')) {
    echo "Installing Tiki database...\n";
    $installer->cleanInstall();
} else {
    if ($installer->requiresUpdate()) {
        echo "Updating Tiki database...\n";
        $installer->update();
    }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:31,代码来源:bootstrap.php

示例2: initTikiDB

/**
 * @param $api
 * @param $driver
 * @param $host
 * @param $user
 * @param $pass
 * @param $dbname
 * @param $client_charset
 * @param $dbTiki
 * @return bool|int
 */
function initTikiDB(&$api, &$driver, $host, $user, $pass, $dbname, $client_charset, &$dbTiki)
{
    $initializer = new TikiDb_Initializer();
    $initializer->setPreferredConnector($api_tiki);
    $initializer->setInitializeCallback(function ($db) {
        $db->setServerType($db_tiki);
        $db->setErrorHandler(new InstallerDatabaseErrorHandler());
    });
    global $tikifeedback;
    $dbcon = false;
    try {
        $dbTiki = $initializer->getConnection(array('host' => $host, 'user' => $user, 'pass' => $pass, 'dbs' => $dbname, 'charset' => $client_charset));
        $dbcon = !empty($dbTiki);
    } catch (Exception $e) {
        $tikifeedback[] = array('num' => 1, 'mes' => $e->getMessage());
    }
    // Attempt to create database. This might work if the $user has create database permissions.
    // First check that suggested database name will not cause issues
    $dbname_clean = preg_replace('/[^a-z0-9$_-]/', "", $dbname);
    if ($dbname_clean != $dbname) {
        $tikifeedback[] = array('num' => 1, 'mes' => tra("Some invalid characters were detected in database name. Please use alphanumeric characters or _ or -.", '', false, array($dbname_clean)));
        $attempt_creation = false;
    } else {
        $attempt_creation = true;
    }
    if (!$dbcon && $attempt_creation == true) {
        $sql = "CREATE DATABASE IF NOT EXISTS `{$dbname_clean}` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;";
        $dbTiki->query($sql, $error);
        if (empty($error)) {
            $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` was created.", '', false, array($dbname_clean)));
        } else {
            $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` creation failed. You need to create the database.", '', false, array($dbname_clean)));
        }
        try {
            $dbTiki = $initializer->getConnection(array('host' => $host, 'user' => $user, 'pass' => $pass, 'dbs' => $dbname, 'charset' => $client_charset));
            $dbcon = !empty($dbTiki);
        } catch (Exception $e) {
            $tikifeedback[] = array('num' => 1, 'mes' => $e->getMessage());
        }
    }
    TikiDb::set($dbTiki);
    return $dbcon;
}
开发者ID:hurcane,项目名称:tiki-azure,代码行数:54,代码来源:tiki-installer.php

示例3: array

    $pdo_options = array();
    $pdo_post_queries = array();
    if (isset($client_charset)) {
        $charset_query = "SET NAMES {$client_charset}";
        if (defined('PDO::MYSQL_ATTR_INIT_COMMAND')) {
            $pdo_options[PDO::MYSQL_ATTR_INIT_COMMAND] = $charset_query;
        } else {
            $pdo_post_queries[] = $charset_query;
        }
        unset($charset_query);
    }
    $dbTiki = new PDO("{$db_tiki}:{$db_hoststring};dbname={$dbs_tiki}", $user_tiki, $pass_tiki, $pdo_options);
    $dbTiki->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
    $dbTiki->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
    $dbTiki->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
    TikiDb::set(new TikiDb_Pdo($dbTiki));
    $tempDb = TikiDb::get();
    if ($api_tiki_forced || isset($dbversion_tiki) && $dbversion_tiki[0] >= 4) {
        $previousApi = $api_tiki;
    } else {
        $previousApi = 'adodb';
    }
    foreach ($pdo_post_queries as $query) {
        $tempDb->query($query);
    }
    unset($tempDb, $pdo_options, $pdo_post_queries);
} catch (PDOException $e) {
    require_once 'lib/init/smarty.php';
    $smarty->assign('msg', $e->getMessage());
    $smarty->assign('where', 'connection');
    echo $smarty->fetch('database-connection-error.tpl');
开发者ID:railfuture,项目名称:tiki-website,代码行数:31,代码来源:tiki-db-pdo.php

示例4: initTikiDB

function initTikiDB(&$api, &$driver, $host, $user, $pass, $dbname, $client_charset, &$dbTiki)
{
    global $tikifeedback;
    $dbcon = false;
    // This section handles the case of adodb (not the preferred case)
    if (isset($api) && $api == 'adodb' || !extension_loaded('pdo')) {
        $api = 'adodb';
        $dbTiki = ADONewConnection($driver);
        $db = new TikiDb_Adodb($dbTiki);
        if (!($dbcon = (bool) @$dbTiki->Connect($host, $user, $pass, $dbname))) {
            $tikifeedback[] = array('num' => 1, 'mes' => $dbTiki->ErrorMsg());
        }
        // Attempt to create database. This might work if the $user has create database permissions.
        // First check that suggested database name will not cause issues
        $dbname_clean = preg_replace('/[^a-z0-9$_-]/', "", $dbname);
        if ($dbname_clean != $dbname) {
            $tikifeedback[] = array('num' => 1, 'mes' => tra("Some invalid characters were detected in database name. Please use alphanumeric characters or _ or -.", '', false, array($dbname_clean)));
            $attempt_creation = false;
        } else {
            $attempt_creation = true;
        }
        if (!$dbcon && $attempt_creation == true) {
            $dbh = ADONewConnection($driver);
            if (@$dbh->Connect($host, $user, $pass)) {
                $sql = "CREATE DATABASE IF NOT EXISTS `{$dbname_clean}` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;";
                $dbcon = $dbh->Execute($sql);
                if ($dbcon) {
                    $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` was created.", '', false, array($dbname_clean)));
                } else {
                    $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` creation failed. You need to create the database.", '', false, array($dbname_clean)));
                }
            } else {
                $tikifeedback[] = array('num' => 1, 'mes' => $dbh->ErrorMsg());
            }
            if ($dbcon) {
                $dbTiki = ADONewConnection($driver);
                $db = new TikiDb_Adodb($dbTiki);
                if (!($dbcon = (bool) @$dbTiki->Connect($host, $user, $pass, $dbname))) {
                    $tikifeedback[] = array('num' => 1, 'mes' => $dbTiki->ErrorMsg());
                }
            }
        }
        // This section handles the case of PDO (preferred case)
    } else {
        $db_hoststring = "host={$host}";
        if ($driver == 'mysqli') {
            $driver = 'mysql';
            if (isset($socket_tiki)) {
                $db_hoststring = "unix_socket={$socket_tiki}";
            }
        }
        try {
            $dbTiki = new PDO("{$driver}:{$db_hoststring};dbname={$dbname}", $user, $pass);
            $db = new TikiDb_Pdo($dbTiki);
            $dbcon = true;
        } catch (PDOException $e) {
            $dbcon = false;
            $tikifeedback[] = array('num' => 1, 'mes' => $e->getMessage());
        }
        // Attempt to create database. This might work if the $user has create database permissions.
        // First check that suggested database name will not cause issues
        $dbname_clean = preg_replace('/[^a-z0-9$_-]/', "", $dbname);
        if ($dbname_clean != $dbname) {
            $tikifeedback[] = array('num' => 1, 'mes' => tra("Some invalid characters were detected in database name. Please use alphanumeric characters or _ or -.", '', false, array($dbname_clean)));
            $attempt_creation = false;
        } else {
            $attempt_creation = true;
        }
        if (!$dbcon && $attempt_creation == true) {
            try {
                $dbh = new PDO("{$driver}:{$db_hoststring}", $user, $pass);
                $sql = "CREATE DATABASE IF NOT EXISTS `{$dbname_clean}` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;";
                $dbcon = $dbh->exec($sql);
                if ($dbcon) {
                    $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` was created.", '', false, array($dbname_clean)));
                } else {
                    $tikifeedback[] = array('num' => 1, 'mes' => tra("Database `%0` creation failed. You need to create the database.", '', false, array($dbname_clean)));
                }
            } catch (PDOException $e) {
                $dbcon = false;
                $tikifeedback[] = array('num' => 1, 'mes' => $e->getMessage());
            }
            if ($dbcon) {
                try {
                    $dbTiki = new PDO("{$driver}:{$db_hoststring};dbname={$dbname}", $user, $pass);
                    $db = new TikiDb_Pdo($dbTiki);
                } catch (PDOException $e) {
                    $dbcon = false;
                    $tikifeedback[] = array('num' => 1, 'mes' => $e->getMessage());
                }
            }
        }
    }
    if ($dbcon) {
        $db->setErrorHandler(new InstallerDatabaseErrorHandler());
        if (!empty($client_charset)) {
            $db->query("SET CHARACTER SET {$client_charset}");
        }
        TikiDb::set($db);
    }
//.........这里部分代码省略.........
开发者ID:railfuture,项目名称:tiki-website,代码行数:101,代码来源:tiki-installer.php

示例5: dirname

$local_php = dirname(__FILE__) . '/local.php';
require_once $local_php;
$style_base = 'skeleton';
// Force autoloading
if (!class_exists('ADOConnection')) {
    die('AdoDb not found.');
}
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
// for now the unit test suite only works with adodb
// using pdo generate an error when phpunit tries to serialize the globals variables
// since it is not possible to serialize a PDO object
$dbTiki = ADONewConnection($db_tiki);
if (!@$dbTiki->Connect($host_tiki, $user_tiki, $pass_tiki, $dbs_tiki)) {
    die("\nUnable to connect to the database\n\n");
}
TikiDb::set(new TikiDb_Adodb($dbTiki));
global $tikilib;
require_once 'lib/tikilib.php';
$tikilib = new TikiLib();
// update db if needed
require_once 'lib/init/initlib.php';
include_once 'installer/installlib.php';
$installer = new Installer();
if (!$installer->tableExists('tiki_preferences')) {
    echo "Installing Tiki database...\n";
    $installer->cleanInstall();
} else {
    if ($installer->requiresUpdate()) {
        echo "Updating Tiki database...\n";
        $installer->update();
    }
开发者ID:hurcane,项目名称:tiki-azure,代码行数:31,代码来源:bootstrap.php


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