本文整理汇总了PHP中DBConnection::getDBConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::getDBConnection方法的具体用法?PHP DBConnection::getDBConnection怎么用?PHP DBConnection::getDBConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::getDBConnection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_domain_service
/**
* Delete Domain Service
*
* Delete DomainServiceDBO from database
*/
function delete_domain_service()
{
$DB = DBConnection::getDBConnection();
$tld = $DB->quote_smart($this->get['dservice']->getTLD());
// Delete Domain Service DBO
delete_DomainServiceDBO($this->get['dservice']);
// Success - go back to web domain services page
$this->setMessage(array("type" => "[DOMAIN_SERVICE_DELETED]", "args" => array($this->session['domain_service_dbo']->getTLD())));
$this->gotoPage("services_domain_services");
}
示例2: createTables
/**
* Install cPanel Module Database Tables
*/
public function createTables()
{
$DB = DBConnection::getDBConnection();
// Wipe out old tables
$sql = "DROP TABLE IF EXISTS `cpanelserver`";
if (!mysql_query($sql, $DB->handle())) {
return false;
}
// Create new ones
$sql = "CREATE TABLE `cpanelserver` (" . "`serverid` int(10) unsigned NOT NULL default '0'," . "`username` varchar(255) NOT NULL default ''," . "`accesshash` text NOT NULL," . "PRIMARY KEY (`serverid`)" . ") TYPE=MyISAM;";
return mysql_query($sql, $DB->handle());
}
示例3: DBException
/**
* Load multiple CPanelServerDBO's from database
*
* @param string $filter A WHERE clause
* @param string $sortby Field name to sort results by
* @param string $sortdir Direction to sort in (ASEC or DESC)
* @param int $limit Limit the number of results
* @param int $start Record number to start the results at
* @return array Array of HostingServiceDBO's
*/
function &load_array_CPanelServerDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null)
{
$DB = DBConnection::getDBConnection();
// Build query
$sql = $DB->build_select_sql("cpanelserver", "*", $filter, $sortby, $sortdir, $limit, $start);
// Run query
if (!($result = @mysql_query($sql, $DB->handle()))) {
// Query error
throw new DBException(mysql_error($DB->handle()));
}
if (mysql_num_rows($result) == 0) {
// No services found
throw new DBNoRowsFoundException();
}
// Build an array of HostingServiceDBOs from the result set
$server_dbo_array = array();
while ($data = mysql_fetch_array($result)) {
// Create and initialize a new ServerDBO with the data from the DB
$dbo = new CPanelServerDBO();
$dbo->load($data);
// Add ServerDBO to array
$server_dbo_array[] = $dbo;
}
return $server_dbo_array;
}
示例4: count_all_OrderHostingDBO
/**
* Count OrderHostingDBO's
*
* Same as load_array_OrderHostingDBO, except this function just COUNTs the number
* of rows in the database.
*
* @param string $filter A WHERE clause
* @param string $sortby Field name to sort results by
* @param string $sortdir Direction to sort in (ASEC or DESC)
* @param int $limit Limit the number of results
* @param int $start Record number to start the results at
* @return array Array of OrderDBO's
*/
function count_all_OrderHostingDBO($filter = null)
{
$DB = DBConnection::getDBConnection();
// Build query
$sql = "SELECT COUNT(*) FROM orderhosting";
// Run query
if (!($result = @mysql_query($sql, $DB->handle()))) {
// SQL error
throw new DBException(mysql_error($DB->handle()));
}
// Make sure the number of rows returned is exactly 1
if (mysql_num_rows($result) != 1) {
// This must return 1 row
throw new DBException("Expected exactly one row from count query");
}
$data = mysql_fetch_array($result);
return $data[0];
}
示例5: ConfigParser
<?php
require_once 'ConfigParser.php';
require_once 'DBConnection.php';
new ConfigParser();
// Get the configuation details and store them as environment variables
if (isset($_REQUEST['userName']) && isset($_REQUEST['password'])) {
$DBConnection = new DBConnection(mysqlServerIP2, dbname, dbuser, dbpassword);
// Check to see if userName Already exist
$results = $DBConnection->queryDB("Select id from users Where username='" . $_REQUEST['userName'] . "'");
if ($results->num_rows > 0) {
// Username already exists
echo "Username already exists";
} else {
$DBConnection->queryDB("Insert into users (username,password) VALUES ('" . $_REQUEST['userName'] . "','" . $_REQUEST['password'] . "')");
if ($DBConnection->getDBConnection()->errno) {
echo "Error creating account for user";
} else {
echo "success";
}
}
} else {
echo "usernam and password required";
}
示例6: count_all_ProductPurchaseDBO
/**
* Count ProductPurchaseDBO's
*
* Same as load_array_ProductPurchaseDBO, except this function just COUNTs the
* number of rows in the database.
*
* @param string $filter A WHERE clause
* @return integer Number of ProductPurchase records
*/
function count_all_ProductPurchaseDBO($filter = null)
{
$DB = DBConnection::getDBConnection();
// Build query
$sql = $DB->build_select_sql("productpurchase", "COUNT(*)", $filter, null, null, null, null);
// Run query
if (!($result = @mysql_query($sql, $DB->handle()))) {
// SQL error
throw new DBException(mysql_error($DB->handle()));
}
// Make sure the number of rows returned is exactly 1
if (mysql_num_rows($result) != 1) {
// This must return 1 row
throw new DBException("Expected exactly one row from count query");
}
$data = mysql_fetch_array($result);
return $data[0];
}
示例7: saveTransaction
/**
* Save Transaction
*
* @param string $transactionID Authorize.net transaction ID
* @param string $lastDigits Last 4 digits of the card
* @return boolean True for success
*/
function saveTransaction($transactionID, $lastDigits)
{
$DB = DBConnection::getDBConnection();
if ($this->loadTransaction($transactionID)) {
// Update
$sql = $DB->build_update_sql("authorizeaim", "transid = " . $transactionID, array("lastdigits" => $lastDigits));
} else {
// Insert
$sql = $DB->build_insert_sql("authorizeaim", array("transid" => $transactionID, "lastdigits" => $lastDigits));
}
return mysql_query($sql, $DB->handle());
}
示例8: saveSetting
/**
* Save Module Setting
*
* @param string $name Setting name
* @param string $val Setting value
* @return boolean True on success
*/
function saveSetting($name, $value)
{
$DB = DBConnection::getDBConnection();
if (null == $this->loadSetting($name)) {
// Initialize setting in DB
$sql = $DB->build_insert_sql("modulesetting", array("name" => $name, "value" => $value, "modulename" => $this->getName()));
} else {
// Update setting in DB
$sql = $DB->build_update_sql("modulesetting", sprintf("name=%s AND modulename=%s", $DB->quote_smart($name), $DB->quote_smart($this->getName())), array("value" => $value));
}
if (!mysql_query($sql, $DB->handle())) {
throw new DBException("Could not insert/update module setting " . $name . ": " . mysql_error());
}
return true;
}
示例9: delete_UserDBO
/**
* Delete UserDBO from Database
*
* @param UserDBO &$dbo UserDBO to be deleted
* @return boolean True on success
*/
function delete_UserDBO(&$dbo)
{
$DB = DBConnection::getDBConnection();
// Build DELETE query
$sql = $DB->build_delete_sql("user", "username = " . $DB->quote_smart($dbo->getUsername()));
// Run query
if (!mysql_query($sql, $DB->handle())) {
throw new DBException(mysql_error($DB->handle()));
}
}
示例10: ContactDBO_update
/**
* Update ContactDBO in database
*
* @param ContactDBO &$dbo ContactDBO to update
*/
function ContactDBO_update(&$dbo)
{
$DB = DBConnection::getDBConnection();
// Build SQL
$sql = $DB->build_update_sql("contact", "id = " . intval($dbo->getID()), array("name" => $dbo->getName(), "businessname" => $dbo->getBusinessName(), "email" => $dbo->getEmail(), "address1" => $dbo->getAddress1(), "address2" => $dbo->getAddress2(), "address3" => $dbo->getAddress3(), "city" => $dbo->getCity(), "state" => $dbo->getState(), "country" => $dbo->getCountry(), "postalcode" => $dbo->getPostalCode(), "phone" => $dbo->getPhone(), "mobilephone" => $dbo->getMobilePhone(), "fax" => $dbo->getFax()));
// Run query
if (!mysql_query($sql, $DB->handle())) {
throw new DBException(mysql_error($DB->handle()));
}
}
示例11: getTaxRules
/**
* Get Tax Rules
*
* @return array An array of tax rules that apply to this purchase
*/
protected function getTaxRules()
{
$DB = DBConnection::getDBConnection();
$filter = "country=" . $DB->quote_smart($this->accountdbo->getCountry()) . " AND (" . "allstates=" . $DB->quote_smart("YES") . " OR " . "state=" . $DB->quote_smart($this->accountdbo->getState()) . ")";
try {
return load_array_TaxRuleDBO($filter);
} catch (DBNoRowsFoundException $e) {
return array();
}
}
示例12: calculateTaxes
/**
* Calculate Taxes for all OrderItems
*/
public function calculateTaxes()
{
$DB = DBConnection::getDBConnection();
if (!isset($this->orderitems)) {
// No items to tax
return;
}
// Load the tax rules that apply to the country and state provided
$taxQuery = sprintf("country=%s AND (allstates=%s OR state=%s)", $DB->quote_smart($this->getCountry()), $DB->quote_smart("YES"), $DB->quote_smart($this->getState()));
try {
$taxRuleDBOArray = load_array_TaxRuleDBO($taxQuery);
foreach ($this->orderitems as $orderItemDBO) {
$orderItemDBO->setTaxRules($taxRuleDBOArray);
}
} catch (DBNoRowsFoundException $e) {
}
}
示例13: update_setting
/**
* Update Setting
*
* Updates a single setting record
*
* @param string $key Key
* @param string $value New value
*/
function update_setting($key, $value)
{
$DB = DBConnection::getDBConnection();
$sql = $DB->build_select_sql("settings", null, "setting = '" . $key . "'");
if (!($result = mysql_query($sql, $DB->handle()))) {
throw new DBException(mysql_error($DB->handle()));
}
if (!mysql_fetch_row($result)) {
// Insert
$sql = $DB->build_insert_sql("settings", array("setting" => $key, "value" => $value));
} else {
// Update
$sql = $DB->build_update_sql("settings", "setting = " . $DB->quote_smart($key), array("value" => $value));
}
// Run query
if (!mysql_query($sql, $DB->handle())) {
throw new DBException(mysql_error($DB->handle()));
}
}
示例14: loadPaypalPaymentDBO
/**
* Load a Paypal Payment DBO
*
* Searches the database for a Paypal transaction by TX id (transaction1 field)
*
* @param string $tx Paypal's TX ID
*/
function loadPaypalPaymentDBO($tx)
{
$DB = DBConnection::getDBConnection();
try {
$paymentDBOArray = load_array_PaymentDBO(sprintf("transaction1=%s AND module=%s", $DB->quote_smart($tx), $DB->quote_smart($this->getName())));
} catch (DBNoRowsFoundException $e) {
}
if (count($paymentDBOArray) > 1) {
fatal_error("PaypalWPS::loadPaypalPaymentDBO", "Found duplicate Paypal transactions in the database. TX = " . $tx);
}
return $paymentDBOArray[0];
}