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


PHP MySQL::Open方法代码示例

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


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

示例1: DB_Escape

function DB_Escape($String)
{
    /******************************************************************************/
    #$__args_types = Array('string');
    #-------------------------------------------------------------------------------
    $__args__ = Func_Get_Args();
    eval(FUNCTION_INIT);
    /******************************************************************************/
    $Link =& Link_Get('DB');
    #-------------------------------------------------------------------------------
    if (!Is_Object($Link)) {
        #-------------------------------------------------------------------------------
        $Config = Config();
        #-------------------------------------------------------------------------------
        $Link = new MySQL($Config['DBConnection']);
        #-------------------------------------------------------------------------------
        if (Is_Error($Link->Open())) {
            #-------------------------------------------------------------------------------
            $Link = NULL;
            #-------------------------------------------------------------------------------
            return ERROR | @Trigger_Error('[DB_Query]: невозможно соединиться с базой данных');
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
        if (Is_Error($Link->SelectDB())) {
            #-------------------------------------------------------------------------------
            $Link = NULL;
            #-------------------------------------------------------------------------------
            return ERROR | @Trigger_Error('[DB_Query]: невозможно выбрать базу данных');
            #-------------------------------------------------------------------------------
        }
        #-------------------------------------------------------------------------------
    }
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
    return MySQL_Real_Escape_String($String);
    #-------------------------------------------------------------------------------
    #-------------------------------------------------------------------------------
}
开发者ID:carriercomm,项目名称:jbs,代码行数:39,代码来源:DB.php

示例2: MySQL

<?php

ini_set("display_errors", 0);
include "./classes/mysql.class.php";
if ($_GET['pid'] == "") {
    echo "enter pid in url";
    exit;
} else {
    $reqparam = $_GET['pid'];
}
$db = new MySQL();
$db->Open();
$sql1 = "SELECT p.name,  DATE_FORMAT(p.age,'%d-%b-%Y') as dob, floor((((YEAR(NOW()) - YEAR(p.age)))*12 + (((MONTH(NOW()) - MONTH(p.age)))))/12) as age, place FROM person p where p.personid = '" . $reqparam . "'";
$row1 = $db->QueryArray($sql1);
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />  
<meta name="viewport" content="width=360, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title><?php 
echo $row1[0][0];
?>
 - Filmography</title>

<!-- / END -->
开发者ID:filmyjo,项目名称:FJMDb-Dev,代码行数:30,代码来源:printp.php

示例3: int

-- --------------------------------------------
-- SQL to generate test table
-- --------------------------------------------
CREATE TABLE `test` (
  `TestID` int(10)     NOT NULL auto_increment,
  `Color`  varchar(15) default NULL,
  `Age`    int(10)     default NULL,
  PRIMARY KEY  (`TestID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------
*/
// --- Open the database --------------------------------------------
// (Also note that you can fill in the variables in the top of the class
// if you want to automatically connect when the object is created. If
// you fill in the values when you create the obect, this is not needed.)
if (!$db->Open("test", "localhost", "root", "password")) {
    $db->Kill();
}
echo "You are connected to the database<br />\n";
// --- Insert a new record ------------------------------------------
$sql = "INSERT INTO Test (Color, Age) Values ('Red', 7)";
if (!$db->Query($sql)) {
    $db->Kill();
}
echo "Last ID inserted was: " . $db->GetLastInsertID();
// --- Or insert a new record with transaction processing -----------
$sql = "INSERT INTO Test (Color, Age) Values ('Blue', 3)";
$db->TransactionBegin();
if ($db->Query($sql)) {
    $db->TransactionEnd();
    echo "Last ID inserted was: " . $db->GetLastInsertID() . "<br /><br />\n";
开发者ID:kimai,项目名称:kimai,代码行数:31,代码来源:example.php

示例4: array

// Twig engine
include_once $APP_DIR . "/lib/Twig/Autoloader.php";
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem($APP_DIR . "/template");
if ($config->twig_cache) {
    $twig = new Twig_Environment($loader, array('debug' => $config->twig_debug, 'cache' => $APP_DIR . "/cache/" . $env));
} else {
    $twig = new Twig_Environment($loader, array('debug' => $config->twig_debug, 'cache' => ""));
}
//load extentions
$twig->addExtension(new Twig_Extension_User());
// BootStrap framework object
$cms = new bootstrap();
// Database framework object
$db = new MySQL();
if (!$db->Open($config->db_name, $config->db_host, $config->db_user, $config->db_pass)) {
    echo "There was a error connecting to the database of ssa, please try again later.";
    @$db->Kill();
}
$db->ThrowExceptions = true;
// User object
$user = new user();
//Set error settings
if ($config->debug) {
    error_reporting(-1);
    ini_set('display_errors', '1');
} else {
    error_reporting(0);
    ini_set('display_errors', '0');
}
// Stop loading stuff below, because its media
开发者ID:sNakiex,项目名称:StendenTwitter,代码行数:31,代码来源:loader.php

示例5: MySQL

/*
 *
 * @project 0xSentinel
 * @author KinG-InFeT
 * @licence GNU/GPL
 *
 * @file banner.php
 *
 * @link http://0xproject.netsons.org#0xSentinel
 *
 */
include "config.php";
include_once "lib/mysql.class.php";
include_once "lib/layout.class.php";
$mysql = new MySQL();
$mysql->Open($db_host, $db_user, $db_pass, $db_name);
$active = $mysql->Query("SELECT * FROM 0xSentinel_settings");
$row = mysql_fetch_array($active);
$image = "images/banner.png";
$im = ImageCreateFromPNG($image);
imageAlphaBlending($im, TRUE);
imageSaveAlpha($im, TRUE);
$txt_color = ImageColorAllocate($im, 80, 80, 80);
if ($row['active'] == 1) {
    $color_status = ImageColorAllocate($im, 80, 80, 80);
} else {
    $color_status = ImageColorAllocate($im, 255, 0, 0);
}
$attack_blocked = intval(mysql_num_rows($mysql->Query("SELECT * FROM 0xSentinel_logs")));
$version = VERSION;
ImageString($im, 2, 10, 25, "Version: {$version}", $txt_color);
开发者ID:KinG-InFeT,项目名称:0xSentinel,代码行数:31,代码来源:banner.php

示例6: Args

$Args = Args();
#-------------------------------------------------------------------------------
$Server = (string) @$Args['Server'];
$Port = (int) @$Args['Port'];
$User = (string) @$Args['User'];
$Password = (string) @$Args['Password'];
$DbName = (string) @$Args['DbName'];
$Users = (string) @$Args['Users'];
#-------------------------------------------------------------------------------
$Course = 30;
#-------------------------------------------------------------------------------
$Params = array('Server' => $Server, 'Port' => $Port, 'User' => $User, 'Password' => $Password, 'DbName' => $DbName);
#-------------------------------------------------------------------------------
$Link = new MySQL($Params);
#-------------------------------------------------------------------------------
if (Is_Error($Link->Open())) {
    return 'Не удалось подключиться к серверу MySQL';
}
#-------------------------------------------------------------------------------
$Result = $Link->Query(SPrintF('SET NAMES `%s`', $Charset));
if (Is_Error($Result)) {
    return $Link->GetError();
}
#-------------------------------------------------------------------------------
if (Is_Error($Link->SelectDB())) {
    return $Link->GetError();
}
#-------------------------------------------------------------------------------
$Query = 'SELECT * FROM `users`';
#-------------------------------------------------------------------------------
if ($Users) {
开发者ID:carriercomm,项目名称:jbs,代码行数:31,代码来源:ClientExec.comp.php

示例7: MySQL

// Final step
if ($nextstep == 'final' && checkAuth()) {
    //
    // Installation actions
    //  - Set collected data
    //
    // Let's start with a clean sheet
    $err = 0;
    // Include MySQL class && initiate
    /*MARKER*/
    require_once BASE_PATH . '/lib/class/mysql.class.php';
    $db = new MySQL();
    //
    // Try database connection
    //
    if (!$db->Open(null, $_SESSION['variables']['db_host'], $_SESSION['variables']['db_user'], $_SESSION['variables']['db_pass'], 'utf8', 'utf8_unicode_ci')) {
        $errors[] = 'Error: could not connect to the database engine';
        $errors[] = $db->Error();
        $errors[] = $db->MyDyingMessage();
        $err++;
    } else {
        $log[] = "Database engine connection successful";
    }
    //
    // Either Select the database or create it when it does not exist yet
    //
    if (!$db->SelectDatabase($_SESSION['variables']['db_name'])) {
        if (!$db->CreateDatabase($_SESSION['variables']['db_name'])) {
            $errors[] = 'Error: could not create the database "' . $_SESSION['variables']['db_name'] . '"';
            $errors[] = $db->Error();
            $errors[] = $db->MyDyingMessage();
开发者ID:GerHobbelt,项目名称:CompactCMS,代码行数:31,代码来源:installer.inc.php

示例8: MySQL

<?php

/* Basic Achievements MVC model */
require_once __ROOT__ . "core/includes/class/mysql.class.php";
require_once __ROOT__ . "core/includes/smarty/Smarty.class.php";
$db = new MySQL(false, $sql_dbname, $sql_host, $sql_user, $sql_pass, $sql_charset, $sql_pcon);
$success = $db->Open();
if (!$success) {
    die("Couldn't establish database connection. Check your configuration file.");
}
$db->TimerStart();
require_once __ROOT__ . "core/includes/achievements/achievements.class.php";
$achievements = new Achievements();
require_once __ROOT__ . "core/includes/func/func.inc.php";
require_once __ROOT__ . "core/controllers/initialize.php";
$smarty = new Controller();
$smarty->setTemplateDir(__ROOT__ . "themes/{$current_theme}/");
require_once __ROOT__ . "/core/language/LanguageInit.inc.php";
require_once __ROOT__ . "core/controllers/main.ctr.php";
require_once __ROOT__ . "core/controllers/content_controllers/" . ACLIB::GetContent() . ".ctr.php";
$smarty->debugging = $smarty_debug;
$db->TimerStop();
if (isset($_GET['simplified'])) {
    $smarty->displayTemplate(__ROOT__ . "themes/{$current_theme}/templates/main_game.tpl");
} else {
    $smarty->displayTemplate(__ROOT__ . "themes/{$current_theme}/templates/main.tpl");
}
开发者ID:shoaib,项目名称:Achievements,代码行数:27,代码来源:model.inc.php

示例9: SetUpLanguageAndLocale

    $language = $cfg['language'];
}
// blow away $cfg['language'] to ensure the language file(s) are loaded this time - it's our first anyhow.
unset($cfg['language']);
$language = SetUpLanguageAndLocale($language);
// SECURITY ==
// Include security file only for administration directory
$location = explode("/", $_SERVER['PHP_SELF']);
$php_src_is_admin_code = in_array("admin", $location);
if ($php_src_is_admin_code) {
    /*MARKER*/
    require_once BASE_PATH . '/admin/includes/security.inc.php';
}
// DATABASE ==
// All set! Now this statement will connect to the database
if (!$db->Open($cfg['db_name'], $cfg['db_host'], $cfg['db_user'], $cfg['db_pass'])) {
    $db->Kill($ccms['lang']['system']['error_database']);
}
// ENVIRONMENT ==
// Some variables to help this file orientate on its environment
$current = basename(filterParam4FullFilePath($_SERVER['REQUEST_URI']));
// [i_a] $curr_page was identical (enough) to $pagereq before
$pagereq = checkSpecialPageName(getGETparam4Filename('page'), SPG_GIVE_PAGENAME);
$ccms['pagereq'] = $pagereq;
$ccms['printing'] = getGETparam4boolYN('printing', 'N');
$preview = getGETparam4IdOrNumber('preview');
// in fact, it's a hash plus ID!
$preview = IsValidPreviewCode($preview);
$ccms['preview'] = $preview ? 'Y' : 'N';
//$ccms['responsecode'] = null; // default: 200 : OK
//$ccms['page_id'] = false;
开发者ID:GerHobbelt,项目名称:CompactCMS,代码行数:31,代码来源:sitemap.php


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