/var/www/billing.premiumtires.ca/vendors/minphp/db/src/PdoConnection.php
/var/www/billing.premiumtires.ca/vendors/minphp/db/src/PdoConnection.php
/var/www/billing.premiumtires.ca/core/ServiceProviders/MinphpBridge.php
/var/www/billing.premiumtires.ca/vendors/pimple/pimple/src/Pimple/Container.php
/var/www/billing.premiumtires.ca/vendors/minphp/container/src/Container.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Model.php
/var/www/billing.premiumtires.ca/core/Util/Common/Classes/Model.php
/var/www/billing.premiumtires.ca/app/app_model.php
/var/www/billing.premiumtires.ca/app/models/currencies.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/helpers/currency_format/currency_format.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Loader.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Controller.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Controller.php
/var/www/billing.premiumtires.ca/core/Util/Common/Classes/Controller.php
/var/www/billing.premiumtires.ca/app/app_controller.php
/var/www/billing.premiumtires.ca/vendors/minphp/bridge/src/Lib/Dispatcher.php
/var/www/billing.premiumtires.ca/index.php
*
* @param int $fetchMode The PDO:FETCH_* constant (int) to fetch records
*/
public function setFetchMode($fetchMode)
{
$cur = $this->fetchMode;
$this->fetchMode = $fetchMode;
return $cur;
}
/**
* Get the last inserted ID
*
* @param string $name The name of the sequence object from which the ID should be returned
* @return string The last ID inserted, if available
*/
public function lastInsertId($name = null)
{
return $this->connect()->lastInsertId($name);
}
/**
* Sets the given value to the given attribute for this connection
*
* @param long $attribute The attribute to set
* @param int $value The value to assign to the attribute
* @return PdoConnection
*/
public function setAttribute($attribute, $value)
{
$this->connect()->setAttribute($attribute, $value);
return $this;
}
/**
* Query the Database using the given prepared statement and argument list
*
* @param string $sql The SQL to execute
* @param string $... Bound parameters [$param1, $param2, ..., $paramN]
* @return PDOStatement The resulting PDOStatement from the execution of this query
*/
public function query($sql)
{
$params = func_get_args();
// Shift the SQL parameter off of the list
array_shift($params);
// If 2nd param is an array, use it as the series of params, rather than
// the rest of the param list
if (isset($params[0]) && is_array($params[0])) {
$params = $params[0];
}
$this->connect();
// Store this statement in our PDO object for easy use later
$this->statement = $this->prepare($sql, $this->fetchMode);
// Execute the query
$this->statement->execute($params);
// Return the statement
return $this->statement;
}
/**
* Prepares an SQL statement to be executed by the PDOStatement::execute() method.
* Useful when executing the same query with different bound parameters.
*
* @param string $sql The SQL statement to prepare
* @param int $fetchMode The PDO::FETCH_* constant
* @return PDOStatement The resulting PDOStatement from the preparation of this query
* @see PDOStatement::execute()
*/
public function prepare($sql, $fetchMode = null)
{
if ($fetchMode === null) {
$fetchMode = $this->fetchMode;
}
$this->statement = $this->connect()->prepare($sql);
// Set the default fetch mode for this query
$this->statement->setFetchMode($fetchMode);
return $this->statement;
}
/**
* Begin a transaction
*
* @return boolean True if the transaction was successfully opened, false otherwise
*/
public function begin()
{
return $this->connect()->beginTransaction();
}
/**
* Rolls back and closes the transaction
*
* @return boolean True if the transaction was successfully rolled back and closed, false otherwise
*/
public function rollBack()
{
return $this->connect()->rollBack();
}
/**
* Commits a transaction
*
* @return boolean True if the transaction was successfully commited and closed, false otherwise
*/
public function commit()
{
return $this->connect()->commit();
}
/**
* Returns the connection's PDO object if a connection has been established, null otherwise.
*
* @return PDO The PDO connection object, null if no connection exists
*/
public function getConnection()
{
return $this->connection;
}
/**
* Set the PDO connection to use
*
* @param PDO $connection
* @return PdoConnection
*/
public function setConnection(PDO $connection)
{
$this->connection = $connection;
return $this;
}
/**
* Get the number of rows affected by the last query
*
* @param PDOStatement $statement The statement to count affected rows on,
* if null the last query() statement will be used.
* @return int The number of rows affected by the previous query
* @throws RuntimeException Thrown when not PDOStatement available
*/
public function affectedRows(PDOStatement $statement = null)
{
if ($statement === null) {
$statement = $this->statement;
}
if (!($statement instanceof PDOStatement)) {
throw new RuntimeException('Can not get affectedRows without a PDOStatement.');
}
return $statement->rowCount();
}
/**
* Build a DSN string using the given array of parameters
*
* @param array $db An array of parameters
* @return string The DSN string
* @throws InvalidArgumentException Thrown when $db contains invalid parameters
*/
public function makeDsn(array $db)
{
if (!isset($db['driver']) || !isset($db['database']) || !isset($db['host'])) {
throw new InvalidArgumentException(
sprintf('Required %s', "array('driver'=>,'database'=>,'host'=>)")
);
}
return isset($db['port'])
? $db['driver'] . ':host=' . $db['host'] . ';dbname=' . $db['database'] . ';port=' . $db['port']
: $db['driver'] . ':host=' . $db['host'] . ';dbname=' . $db['database'];
}
/**
* Establish a new PDO connection using the given array of information. If
* a connection already exists, no new connection will be created.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return \PDO The connection
*/
private function makeConnection($dsn, $username, $password, $options)
{
return new PDO($dsn, $username, $password, $options);
}
}