本文整理汇总了PHP中mysqli::autocommit方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::autocommit方法的具体用法?PHP mysqli::autocommit怎么用?PHP mysqli::autocommit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::autocommit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rollback
/**
* rollback transaction
*/
public function rollback()
{
if ($this->connection === null) {
$this->open();
}
$this->connection->rollback();
$this->connection->autocommit(true);
}
示例2: __construct
/**
* Connection constructor.
*
* @param $config string[]
*/
public function __construct($config)
{
mysqli_report(MYSQLI_REPORT_STRICT);
// attempt to connect to the db
$this->mysqli = new \mysqli($config['host'], $config['user'], $config['password'], $config['database'], $config['port']);
// we will manually commit our sql changes
$this->mysqli->autocommit(false);
$this->statementCache = new Statement(500);
}
示例3: __construct
/**
* Class constructor
*
* @param string $readWriteMode "read", "write" or "admin"
* @throws ControllerException
*/
public function __construct($readWriteMode = 'write')
{
try {
$dbc = new DBConnection($readWriteMode);
$this->_dbh = $dbc->getConnection();
$this->_dbh->autocommit(TRUE);
} catch (Exception $e) {
throw new ControllerException('Problem connecting to database: ' . $this->_dbh->error);
}
}
示例4: instance
public function instance()
{
try {
$settings = $this->settings;
$host = Properties::string("host", $settings, false, "127.0.0.1");
$user = Properties::string("user", $settings, false);
$password = Properties::string("password", $settings, false);
$database = Properties::string("database", $settings, false, "");
$port = Properties::int("port", $settings, false, 3306);
$autoCommit = Properties::bool("autoCommit", $settings, false, true);
$charSet = Properties::string("charSet", $settings, false, "utf8");
//Turn off error reporting for MariaDB compliance.
$err_level = error_reporting(E_ALL ^ E_WARNING);
$mysql = new \mysqli($host, $user, $password, $database, $port);
error_reporting($err_level);
if ($mysql->connect_error) {
throw new DbException($mysql->connect_error, $mysql->connect_errno);
}
if (!$mysql->set_charset($charSet)) {
throw new DbException("Could not set charset {$charSet}");
}
if ($autoCommit !== null) {
if (!$mysql->autocommit($autoCommit)) {
throw new DbException("Could not set autoCommit to {$autoCommit}");
}
}
return $mysql;
} catch (PropertyException $e) {
throw new DbException("Missing setting property {$e->getProperty()}");
}
}
示例5: load_client_details_by_phone_number
public function load_client_details_by_phone_number($phone_number)
{
//$client_details = array("Error"=> "Data Not Found", "status"=>"false");
//return $client_details;
//Create a container object which will hold complete information required to display the complete order page
$container = new stdClass();
//Establish mysqli connection
$mysqli_connection = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if ($mysqli_connection->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli_connection->connect_errno . ") " . $mysqli_connection->connect_error;
//$container->show_failure_message = true;
return $container;
}
//Set auto-commit to FALSE explicitly
if (!$mysqli_connection->autocommit(FALSE)) {
return;
}
$access = new ClientDetailsAccess($mysqli_connection);
$client_details = $access->load_by_client_phone_number($phone_number);
//Validate whether order loading is successful or not.
if ($access->m_status == false || $access->m_status_code == STATUS_FETCH_NO_DATA) {
$container->show_failure_message = true;
//Close the connection
$mysqli_connection->close();
$client_details = array("Error" => "Data Not Found", "status" => "false");
}
return $client_details;
}
示例6: popTransaction
/**
* Removes a transaction from the current stack.
*/
private function popTransaction()
{
--$this->transactionCount;
if ($this->transactionCount == 0) {
@$this->mysqli->autocommit(true);
}
}
示例7: db_connect
/**
* Commonly used function
* @author Alex
*/
function db_connect($autocommit = true)
{
global $db_info;
global $connected;
global $connection;
// static $connection = null;
$retryCount = 3;
// if($connection) return $connection;
while (!$connected && $retryCount > 1) {
$connection = new mysqli($db_info['HOST'], $db_info['USER'], $db_info['PASSWORD'], $db_info['DATABASE']);
//print_r($connection);exit();
if ($connection && !mysqli_connect_errno()) {
$connection->autocommit($autocommit);
$connection->query("set names '" . $db_info['CHARSET'] . "'");
$connected = true;
} else {
usleep(500000);
$retryCount--;
}
}
if ($connected) {
return $connection;
} else {
print mysqli_connect_error();
}
}
示例8: __construct
/**
* Constructor. Get singleton instance via iveeCore\SDE::instance() instead.
*
* @param \mysqli $db is an optional reference to an existing DB connection object
*/
protected function __construct(\mysqli $db = null)
{
if (!isset($db)) {
$db = $this->connectDb();
if ($db->connect_error) {
exit('Fatal Error: ' . $db->connect_error . PHP_EOL);
}
} elseif (!$db instanceof \mysqli) {
exit('Fatal Error: parameter given is not a mysqli object' . PHP_EOL);
}
$this->db = $db;
//ivee uses transactions so turn off autocommit
$this->db->autocommit(false);
//eve runs on UTC time
$this->db->query("SET time_zone='+0:00';");
}
示例9: end_transaction
/**
* Ends a transaction.
*
* @return Boolean
*/
public function end_transaction()
{
$this->connect();
if ($this->connected === TRUE) {
return $this->mysqli->autocommit(TRUE);
}
return FALSE;
}
示例10: db_connect
function db_connect()
{
$result = new mysqli('localhost', 'food_galaxy', 'password', 'food_galaxy');
if (!$result) {
return false;
}
$result->autocommit(TRUE);
return $result;
}
示例11: db_connect
function db_connect()
{
$result = new mysqli('silo.soic.indiana.edu', 'shopping', '0', 'eggplants', 11006);
if (!$result) {
return false;
}
$result->autocommit(TRUE);
return $result;
}
示例12: db_connect
function db_connect()
{
// Set your Username, Password, And DB Name.
$result = new mysqli('localhost', '', '', '');
if (!$result) {
return false;
}
$result->autocommit(TRUE);
return $result;
}
示例13: insertOrder
/**
* Inserts a new order into the orders DB
*
* @param $orderinfo
* @param $cart
* @param $username
* @return order ID, or FALSE on failure
*/
function insertOrder($orderinfo, $cart, $username)
{
if (!$orderinfo || !$cart || !$username) {
return FALSE;
}
include 'db_info.php';
//include('userfunctions.php');
@($db = new mysqli($dbhost, $dbuser, $dbpassword, $dbname));
if (mysqli_connect_errno()) {
echo "<br><h2 style='color:red'>Database connection error.</h2><br>" . mysqli_connect_error();
return FALSE;
}
extract($orderinfo);
// $orderinfo["addr"] = $addr
// Only store the last 4 digits of cards in the db
$cardnumber = substr($cardnumber, -4);
$db->autocommit(FALSE);
// Partial commits are bad
$query = "INSERT INTO orders (shipping_addr, shipping_city, shipping_state, shipping_zip, creditcard, shipping_cost, ordertotal) VALUES \r\n\t\t ('" . addslashes($addr) . "', '" . addslashes($city) . "', '" . addslashes($state) . "', '" . addslashes($zip) . "', '" . $cardnumber . "', '" . $shipping . "', '" . $total . "');";
$result = $db->query($query);
if (!$result) {
return FALSE;
}
$orderid = $db->insert_id;
$query = "INSERT INTO user_orders (username, orderid) VALUES ('" . addslashes($username) . "', '" . $orderid . "');";
$result = $db->query($query);
if (!$result) {
return FALSE;
}
foreach ($cart as $pid => $qty) {
$product = getProductInfo($pid);
$curprice = $product["price"];
$query = "INSERT INTO product_orders (orderid, pid, qty, purchaseprice) VALUES \r\n\t\t\t\t('" . $orderid . "', '" . $pid . "', '" . $qty . "', '" . $curprice . "');";
$result = $db->query($query);
if (!$result) {
return FALSE;
}
}
$db->commit();
$db->autocommit(TRUE);
$db->close();
return $orderid;
}
示例14: connect
/**
*
*/
function connect()
{
$connect = new mysqli("localhost", "root", "copihue15", 'prod_pjud');
$connect->autocommit(true);
if ($connect->connect_errno) {
printf("Fall� la conexi�n: %s\n", $connect->connect_error);
exit;
}
return $connect;
}
示例15: setAutocommit
/**
* Set autocommit
* @param boolean $autocommit
* @throws MysqltcsException on error
*/
public function setAutocommit($autocommit)
{
if ($this->mysqliRef->autocommit($autocommit)) {
$this->log("autocommit set to " . ($autocommit ? "true" : "false"));
return;
}
$mex = "Mysql error: it is not possible set autocommit to " . ($autocommit ? "true" : "false") . " state. " . $this->mysqliRef->error;
$this->log($mex);
throw new MysqltcsException($mex);
}