Class Model
This class establishes and maintains a connection to a PDO resource, and
provides methods for interacting with that resource
Indirect known subclasses
Accounts
,
ApiKeys
,
Currencies
,
EmailGroups
,
Emails
,
Encryption
,
GatewayManager
,
Invoices
,
InvoiceTemplateManager
,
Languages
,
Logs
,
Marketplace
,
CalendarEvents
,
ModuleClientMeta
,
ModuleManager
,
Navigation
,
PackageGroups
,
PackageOptionGroups
,
PackageOptions
,
Packages
,
Payments
,
Permissions
,
PluginManager
,
ClientGroups
,
Pricings
,
ReportManager
,
ServiceChanges
,
Services
,
Settings
,
Staff
,
StaffGroups
,
States
,
Taxes
,
Themes
,
Clients
,
Transactions
,
Users
,
Companies
,
Contacts
,
Countries
,
Coupons
,
CronTasks
Methods summary
public
|
#
__construct( array $db_info = null )
Creates a new Model object that establishes a new PDO connection using the
given database info, or the default configured info set in the database config
file if no info is given
Creates a new Model object that establishes a new PDO connection using the
given database info, or the default configured info set in the database config
file if no info is given
Parameters
- $db_info
array $db_info Database information for this connection
|
public
|
#
setFetchMode( mixed $fetch_mode )
Sets the fetch mode to the given value, returning the old value
Sets the fetch mode to the given value, returning the old value
Parameters
- $fetch_mode
mixed $fetch_mode The PDO:FETCH_* constant (int) to fetch records by, null to use
default setting
|
public
string
|
#
lastInsertId( string $name = null )
Get the last inserted ID
Parameters
- $name
string $name The name of the sequence object from which the ID should be returned
Returns
string The last ID inserted, if available
Throws
Exception
Thrown when no PDO connection has been established
|
public
|
#
setAttribute( long $attribute, integer $value )
Sets the given value to the given attribute for this connection
Sets the given value to the given attribute for this connection
Parameters
- $attribute
long $attribute The attribute to set
- $value
integer $value The value to assign to the attribute
Throws
Exception
Thrown when no PDO connection has been established
|
public
PDOStatement
|
#
query( string $sql )
Query the Database using the given prepared statement and argument list
Query the Database using the given prepared statement and argument list
Parameters
- $sql
string $sql The SQL to execute
Returns
PDOStatement
The resulting PDOStatement from the execution of this query
Throws
Exception
Thrown when no PDO connection has been established
|
public
PDOStatement
|
#
prepare( string $sql, integer $fetch_mode = null )
Prepares an SQL statement to be executed by the PDOStatement::execute()
method. Useful when executing the same query with different bound
parameters.
Prepares an SQL statement to be executed by the PDOStatement::execute()
method. Useful when executing the same query with different bound
parameters.
Parameters
- $sql
string $sql The SQL statement to prepare
- $fetch_mode
integer $fetch_mode The PDO::FETCH_* constant, defaults to "Database.fetch_mode" config
setting
Returns
PDOStatement
The resulting PDOStatement from the preparation of this query
See
|
public
boolean
|
#
begin( )
Begin a transaction
Returns
boolean True if the transaction was successfully opened, false otherwise
|
public
boolean
|
#
rollBack( )
Rolls back and closes the transaction
Rolls back and closes the transaction
Returns
boolean True if the transaction was successfully rolled back and closed, false otherwise
|
public
boolean
|
#
commit( )
Commits a transaction
Returns
boolean True if the transaction was successfully commited and closed, false otherwise
|
public
PDO
|
#
getConnection( )
Returns the connection's PDO object if a connection has been established,
null otherwise.
Returns the connection's PDO object if a connection has been established,
null otherwise.
Returns
PDO
The PDO connection object, null if no connection exists
|
public
integer
|
#
affectedRows( PDOStatement $statement = null )
Get the number of rows affected by the last query
Get the number of rows affected by the last query
Parameters
- $statement
PDOStatement
$statement The statement to count affected rows on, if null the last
Model::query() statement will be used.
Returns
integer The number of rows affected by the previous query
Throws
Exception
Thrown when called prior to Model::query()
|
public static
string
|
#
makeDSN( array $db )
Build a DSN string using the given array of parameters
Build a DSN string using the given array of parameters
Parameters
- $db
array $db An array of parameters
Returns
string The DSN string
Throws
Exception
Thrown when $db contains invalid parameters
|
Magic methods summary