本文整理汇总了PHP中ADOLoadCode函数的典型用法代码示例。如果您正苦于以下问题:PHP ADOLoadCode函数的具体用法?PHP ADOLoadCode怎么用?PHP ADOLoadCode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ADOLoadCode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDb
function getDb()
{
static $dbcon;
if ($dbcon) {
return $dbcon;
}
ADOLoadCode('mysql');
$dbcon =& ADONewConnection('mysql');
if (!$dbcon->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
die('Connection to database ' . DB_NAME . ' was refused. Please check database_config file.');
}
return $dbcon;
}
示例2: ADONewConnection
/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function ADONewConnection($db = '')
{
global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
if (!defined('ADODB_ASSOC_CASE')) {
define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE);
}
$errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
if (($at = strpos($db, '://')) !== FALSE) {
$origdsn = $db;
$fakedsn = 'fake' . substr($origdsn, $at);
if (($at2 = strpos($origdsn, '@/')) !== FALSE) {
// special handling of oracle, which might not have host
$fakedsn = str_replace('@/', '@adodb-fakehost/', $fakedsn);
}
if (strpos($origdsn, 'sqlite') !== FALSE && stripos($origdsn, '%2F') === FALSE) {
// special handling for SQLite, it only might have the path to the database file.
// If you try to connect to a SQLite database using a dsn
// like 'sqlite:///path/to/database', the 'parse_url' php function
// will throw you an exception with a message such as "unable to parse url"
list($scheme, $path) = explode('://', $origdsn);
$dsna['scheme'] = $scheme;
if ($qmark = strpos($path, '?')) {
$dsn['query'] = substr($path, $qmark + 1);
$path = substr($path, 0, $qmark);
}
$dsna['path'] = '/' . urlencode($path);
} else {
$dsna = @parse_url($fakedsn);
}
if (!$dsna) {
return false;
}
$dsna['scheme'] = substr($origdsn, 0, $at);
if ($at2 !== FALSE) {
$dsna['host'] = '';
}
if (strncmp($origdsn, 'pdo', 3) == 0) {
$sch = explode('_', $dsna['scheme']);
if (sizeof($sch) > 1) {
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
if ($sch[1] == 'sqlite') {
$dsna['host'] = rawurlencode($sch[1] . ':' . rawurldecode($dsna['host']));
} else {
$dsna['host'] = rawurlencode($sch[1] . ':host=' . rawurldecode($dsna['host']));
}
$dsna['scheme'] = 'pdo';
}
}
$db = @$dsna['scheme'];
if (!$db) {
return false;
}
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'], 1)) : '';
# strip off initial /
if (isset($dsna['query'])) {
$opt1 = explode('&', $dsna['query']);
foreach ($opt1 as $k => $v) {
$arr = explode('=', $v);
$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
}
} else {
$opt = array();
}
}
/*
* phptype: Database backend used in PHP (mysql, odbc etc.)
* dbsyntax: Database used with regards to SQL syntax etc.
* protocol: Communication protocol to use (tcp, unix etc.)
* hostspec: Host specification (hostname[:port])
* database: Database to use on the DBMS server
* username: User name for login
* password: Password for login
*/
if (!empty($ADODB_NEWCONNECTION)) {
$obj = $ADODB_NEWCONNECTION($db);
}
if (empty($obj)) {
if (!isset($ADODB_LASTDB)) {
$ADODB_LASTDB = '';
}
if (empty($db)) {
$db = $ADODB_LASTDB;
}
if ($db != $ADODB_LASTDB) {
$db = ADOLoadCode($db);
}
if (!$db) {
if (isset($origdsn)) {
$db = $origdsn;
//.........这里部分代码省略.........
示例3: ADOLoadCode
}
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
// ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db =& ADONewConnection("ado_mssql");
$db->debug = 1;
print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
$myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER=JAGUAR\\VSDOTNET;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";
if (@$db->PConnect($myDSN, "", "", "")) {
testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
} else {
print "ERROR: MSSQL test 2 requires MS SQL 7";
}
}
ADOLoadCode("mssqlpo");
if (!empty($testmssql)) {
// MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection();
$db->debug = 1;
print "<h1>Connecting {$db->databaseType}...</h1>";
$db->PConnect('JAGUAR\\vsdotnet', 'adodb', 'natsoft', 'northwind');
if (true or @$db->PConnect("mangrove", "sa", "natsoft", "ai")) {
AutoDetect_MSSQL_Date_Order($db);
// $db->Execute('drop table adoxyz');
testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
} else {
print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='natsoft', database='ai'" . '<BR>' . $db->ErrorMsg();
}
}
if (!empty($testmssql) && !empty($testado)) {
示例4: ADOLoadCode
/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db = '')
{
global $ADODB_Database;
$rez = true;
if ($db) {
if ($ADODB_Database != $db) {
ADOLoadCode($db);
}
} else {
if (!empty($ADODB_Database)) {
ADOLoadCode($ADODB_Database);
} else {
$rez = false;
}
}
$errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
if (!$rez) {
if ($errorfn) {
// raise an error
$errorfn('ADONewConnection', 'ADONewConnection', -998, "could not load the database driver for '{$db}", $dbtype);
} else {
ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '{$db}'</p>", false);
}
return false;
}
$cls = 'ADODB_' . $ADODB_Database;
$obj = new $cls();
if ($errorfn) {
$obj->raiseErrorFn = $errorfn;
}
return $obj;
}
示例5: ADOLoadCode2
function ADOLoadCode2($d)
{
ADOLoadCode($d);
$c = ADONewConnection($d);
echo "Loaded {$d} ", $c ? 'ok' : 'extension not installed', "<br>";
}
示例6: Lim
<body>
<?php
/*
V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 8.
*/
#
# test connecting to 2 MySQL databases simultaneously and ensure that each connection
# is independant.
#
include "../tohtml.inc.php";
include "../adodb.inc.php";
ADOLoadCode('mysql');
$c1 = ADONewConnection('oci8');
if (!$c1->PConnect('', 'scott', 'tiger')) {
die("Cannot connect to server");
}
$c1->debug = 1;
$rs = $c1->Execute('select rownum, p1.firstname,p2.lastname,p2.firstname,p1.lastname from adoxyz p1, adoxyz p2');
print "Records=" . $rs->RecordCount() . "<br><pre>";
//$rs->_array = false;
//$rs->connection = false;
//print_r($rs);
rs2html($rs);
?>
</body>
示例7: die
die("Incomplete database configuration. Please contact your system administrator.");
}
} else {
die("Couldn't find a local site configuration file. Please contact your system administrator.");
}
if (!isset($ADODB_CACHE_DIR) || !is_dir($ADODB_CACHE_DIR) || !is_writable($ADODB_CACHE_DIR)) {
$ADODB_CACHE_DIR = AMP_urlFlip(AMP_LOCAL_PATH . '/cache');
}
if (!defined('AMP_BASE_PATH')) {
define('AMP_BASE_PATH', $_SERVER['DOCUMENT_ROOT']);
}
if (!defined('AMP_BASE_INCLUDE_PATH')) {
define('AMP_BASE_INCLUDE_PATH', $_SERVER['DOCUMENT_ROOT'] . '/include/');
}
// turn on APD debugger when set by config file
if (defined('AMP_DEBUG_MODE_APD') && AMP_DEBUG_MODE_APD && function_exists('apd_set_pprof_trace')) {
apd_set_pprof_trace();
}
// Connect to the database.
if (!defined('AMP_DB_TYPE')) {
define('AMP_DB_TYPE', 'mysql');
}
ADOLoadCode(AMP_DB_TYPE);
$dbcon = ADONewConnection(AMP_DB_TYPE);
if (!$dbcon->Connect(AMP_DB_HOST, AMP_DB_USER, AMP_DB_PASS, AMP_DB_NAME)) {
die('Connection to database ' . AMP_DB_NAME . ' was refused. Please check your site configuration file.');
}
require_once 'AMP/Registry.php';
//add the dbcon to the Registry
$registry = AMP_Registry::instance();
$registry->setDbcon($dbcon);
示例8: ADOLoadCode
/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db = '')
{
global $ADODB_Database;
if ($db) {
if ($ADODB_Database != $db) {
ADOLoadCode($db);
}
} else {
if (!empty($ADODB_Database)) {
ADOLoadCode($ADODB_Database);
} else {
print "<p>ADONewConnection: No database driver defined</p>";
}
}
$cls = 'ADODB_' . $ADODB_Database;
$obj = new $cls();
if (defined('ADODB_ERROR_HANDLER')) {
$obj->raiseErrorFn = ADODB_ERROR_HANDLER;
}
return $obj;
}
示例9: define
/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db = '')
{
global $ADODB_NEWCONNECTION, $ADODB_LASTDB;
if (!defined('ADODB_ASSOC_CASE')) {
define('ADODB_ASSOC_CASE', 2);
}
$errorfn = defined('ADODB_ERROR_HANDLER') ? ADODB_ERROR_HANDLER : false;
if (!empty($ADODB_NEWCONNECTION)) {
$obj = $ADODB_NEWCONNECTION($db);
if ($obj) {
if ($errorfn) {
$obj->raiseErrorFn = $errorfn;
}
return $obj;
}
}
if (!isset($ADODB_LASTDB)) {
$ADODB_LASTDB = '';
}
if (empty($db)) {
$db = $ADODB_LASTDB;
}
if ($db != $ADODB_LASTDB) {
$db = ADOLoadCode($db);
}
if (!$db) {
if ($errorfn) {
// raise an error
$ignore = false;
$errorfn('ADONewConnection', 'ADONewConnection', -998, "could not load the database driver for '{$db}", $db, false, $ignore);
} else {
ADOConnection::outp("<p>ADONewConnection: Unable to load database driver '{$db}'</p>", false);
}
return false;
}
$cls = 'ADODB_' . $db;
if (!class_exists($cls)) {
adodb_backtrace();
return false;
}
$obj =& new $cls();
if ($errorfn) {
$obj->raiseErrorFn = $errorfn;
}
return $obj;
}
示例10: ADOLoadCode
print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN='lensengine', userid='sa', password=''";
}
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
// ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db =& ADONewConnection("ado_mssql");
print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
$myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER=mangrove;DATABASE=ai;UID=sa;PWD=;";
if (@$db->PConnect($myDSN, "", "", "")) {
testdb($db, "create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
} else {
print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
}
}
ADOLoadCode("mssql");
if (!empty($testmssql)) {
// MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection();
print "<h1>Connecting {$db->databaseType}...</h1>";
if (@$db->PConnect("mangrove", "sa", "", "ai")) {
testdb($db, "create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
} else {
print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='sa', password='', database='ai'" . '<BR>' . $db->ErrorMsg();
}
}
if (!empty($testmssql) && !empty($testado)) {
// ADO ACCESS MSSQL with OLEDB provider
$db =& ADONewConnection("ado_mssql");
print "<h1>Connecting DSN-less OLEDB Provider {$db->databaseType}...</h1>";
$myDSN = "SERVER=mangrove;DATABASE=ai;";
示例11: preg_replace
<?php
require_once "adodb.inc.php";
// Istanziazione AdoDB
$HOSTNAME = "localhost";
//INDIRIZZO;
$DATABASE = "mysql:ceramichesofia";
//DATABASE;
$DBTYPE = preg_replace("/:.*\$/", "", $DATABASE);
$DATABASE = preg_replace("/^.*?:/", "", $DATABASE);
$USERNAME = "gambric";
//UTENTE;
$PASSWORD = "gambric";
//PASSWORD;
$LOCALE = "It";
ADOLoadCode($DBTYPE);
$db_conn =& ADONewConnection($DBTYPE);
$db_conn->PConnect($HOSTNAME, $USERNAME, $PASSWORD, $DATABASE, $LOCALE);
示例12: array
* You might still get database connection errors because you
* didn't configure PHPLENS_SESSION_* variables in
* phplens/config/phplens.config.inc.php.
*/
$rt = array('FirstName', 'LastName', 'Num');
$r0 = array('John', 'Lim', '1');
$r1 = array('Harry', 'Zee', '2');
$r2 = array('Larry', 'Aaron', '3');
$r3 = array('Baddy', 'Lim', '4');
$r4 = array('John', 'Lee', '5');
$r5 = array('Yee', 'Dee', '16');
$rend = array('Last', 'Record', '1000');
/* Create the 2 dimensional array */
$arr = array($r0, $r1, $r2, $r3, $r4, $r5, $r0, $r1, $r2, $r3, $r4, $r5, $r0, $r1, $r2, $r3, $r4, $r5, $rend);
/* load the 2D array into a text database */
ADOLoadCode('text');
$db =& ADONewConnection();
if (empty($db)) {
die("Cannot create ADONewConnection");
}
if (!$db->PConnect($arr, false, array('1stName', 'Surname', 'ID'))) {
print 'Error:' . $db->ErrorMsg();
}
/*
* The id is very important.
* All phpLens objects should have a different id
*/
$id = 'text_test';
$lens = new PHPLens($id, $db, 'select * from products');
if (empty($lens)) {
die("Cannot create lens object id={$id}");
示例13: ADOLoadCode
/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db = '')
{
global $ADODB_Database;
if ($db) {
if ($ADODB_Database != $db) {
ADOLoadCode($db);
}
} else {
if (!empty($ADODB_Database)) {
$db = $ADODB_Database;
} else {
print "<p>ADONewConnection: No database driver defined</p>";
}
}
$cls = 'ADODB_' . $db;
return new $cls();
}
示例14: AMP_load_site_command_line
function AMP_load_site_command_line()
{
$local_path_pattern = '/home/%s/public_html/';
#$local_path_pattern = '/home/%s/';
$site_folder = $_SERVER['argv'][1];
if (!$site_folder) {
trigger_error('Usage: login_link.php sitename');
return false;
}
define('AMP_LOCAL_PATH', sprintf($local_path_pattern, $site_folder));
#define( 'AMP_SYSTEM_CACHE', false );
$config_file_path = sprintf($local_path_pattern, $site_folder) . 'custom/';
$lib_file_path = sprintf($local_path_pattern, $site_folder) . 'lib/';
$include_path = sprintf($local_path_pattern, 'amp') . 'include/';
$include_path = '/home/amp/public_html/include/';
define('AMP_BASE_INCLUDE_PATH', $include_path);
$config_file1 = 'SiteConfig.php';
$config_file2 = 'config.php';
$incpath = ini_get('include_path');
// Search local paths for includes.
ini_set('include_path', $include_path . ':' . $config_file_path . ':' . $lib_file_path . ':' . ini_get('include_path'));
if (!file_exists($config_file_path . $config_file1) && !file_exists($config_file_path . $config_file2)) {
trigger_error('path not found: ' . $config_file_path . $config_file2);
return false;
}
require_once 'utility.system.functions.inc.php';
require_once 'utility.functions.inc.php';
require_once 'AMP/System/Flash.php';
if (file_exists($config_file_path . $config_file1)) {
require_once $config_file_path . $config_file1;
} else {
require_once $config_file_path . $config_file2;
if (isset($MM_DBTYPE)) {
define('AMP_DB_TYPE', $MM_DBTYPE);
}
define('AMP_DB_HOST', $MM_HOSTNAME);
define('AMP_DB_USER', $MM_USERNAME);
define('AMP_DB_PASS', $MM_PASSWORD);
define('AMP_DB_NAME', $MM_DATABASE);
}
require_once 'adodb/adodb.inc.php';
if (!defined('AMP_DB_TYPE')) {
define('AMP_DB_TYPE', 'mysql');
}
ADOLoadCode(AMP_DB_TYPE);
$dbcon = ADONewConnection(AMP_DB_TYPE);
if (!$dbcon->Connect(AMP_DB_HOST, AMP_DB_USER, AMP_DB_PASS, AMP_DB_NAME)) {
trigger_error('database connection failed');
return false;
}
require_once 'AMP/Registry.php';
$registry = AMP_Registry::instance();
$registry->setDbcon($dbcon);
//define( 'AMP_SYSTEM_CACHE', false );
define('AMP_SITE_CACHE_TIMEOUT', 0);
require_once 'AMP/System/Config.inc.php';
require_once 'AMP/System/Language/Config.php';
require_once 'AMP/Base/Debug.php';
//require_once( 'AMP/System/Cache/Config.inc.php');
AMP_config_load('cache');
require_once 'AMP/Base/Setup.php';
//require_once( 'AMP/System/User/Config.php');
AMP_config_load('tools');
require_once 'AMP/Base/Lookups.php';
AMP_config_load('site');
AMP_config_load('content');
require_once 'AMP/Content/Map.inc.php';
return $site_folder;
}
示例15: ADOLoadCode
print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='adodb', password='natsoft', database='ai'" . '<BR>' . $db->ErrorMsg();
}
}
ADOLoadCode('odbc_mssql');
if (!empty($testmssql)) {
// MS SQL Server via ODBC
$db = ADONewConnection();
print "<h1>Connecting {$db->databaseType}...</h1>";
$dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server={$server};Database=northwind;";
if ($db->PConnect($dsn, "adodb", "natsoft", "")) {
testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
} else {
print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
}
}
ADOLoadCode("ado_mssql");
if (!empty($testmssql) && !empty($testado)) {
// ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db = ADONewConnection("ado_mssql");
//$db->debug=1;
print "<h1>Connecting DSN-less {$db->databaseType}...</h1>";
$myDSN = "PROVIDER=MSDASQL;DRIVER={SQL Server};" . "SERVER={$server};DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";
if ($db->PConnect($myDSN, "", "", "")) {
testdb($db, "create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
} else {
print "ERROR: MSSQL test 2 requires MS SQL 7";
}
}
if (!empty($testmssql) && !empty($testado)) {
// ADO ACCESS MSSQL with OLEDB provider
$db = ADONewConnection("ado_mssql");