Connection
class Connection (View source)
The base class for database connection adapters.
Constants
DATETIME_TRANSLATE_FORMAT |
The DateTime format to use when translating other DateTime-compatible objects. NOTE!: The DateTime "format" used must not include a time-zone (name, abbreviation, etc) or offset. Including one will cause PHP to ignore the passed in time-zone in the 3rd argument. See bug: https://bugs.php.net/bug.php?id=61022 |
Properties
mixed | $connection | The PDO connection object. | |
string | $last_query | The last query run. | |
string | $protocol | The name of the protocol that is used. | |
static string | $date_format | Database's date format | |
static string | $datetime_format | Database's datetime format | |
static array | $PDO_OPTIONS | Default PDO options to set for each connection. | |
static string | $QUOTE_CHARACTER | The quote character for stuff like column and field names. | |
static int | $DEFAULT_PORT | Default port. |
Methods
Retrieve a database connection.
Use this for any adapters that can take connection info in the form below to set the adapters connection info.
Class Connection is a singleton. Access it via instance().
Retrieves column meta data for the specified table.
Escapes quotes in a string.
Retrieve the insert id of the last model saved.
Execute a raw SQL query on the database.
Execute a query that returns maximum of one row with one field and return it.
Returns all tables for the current database.
Starts a transaction.
Commits the current transaction.
Rollback a transaction.
Tells you if this adapter supports sequences or not.
Return a default sequence name for the specified table.
Return SQL for getting the next value in a sequence.
Quote a name like table names and field names.
Return a date time formatted into the database's datetime format.
Converts a string representation of a datetime into a DateTime object.
Adds a limit clause to the SQL query.
Query for column meta info and return statement handle.
Query for all tables in the current database. The result must only contain one column which has the name of the table.
Executes query to specify the character set for this connection.
No description
Specifies whether or not adapter can use LIMIT/ORDER clauses with DELETE & UPDATE operations
Details
at line 102
static Connection
instance(string $connection_string_or_connection_name = null)
Retrieve a database connection.
at line 176
static object
parse_connection_url(string $connection_url)
Use this for any adapters that can take connection info in the form below to set the adapters connection info.
protocol://username:password@host[:port]/dbname
protocol://urlencoded%20username:urlencoded%20password@host[:port]/dbname?decode=true
protocol://username:password@unix(/some/file/path)/dbname
Sqlite has a special syntax, as it does not need a database name or user authentication:
sqlite://file.db
sqlite://../relative/path/to/file.db
sqlite://unix(/absolute/path/to/file.db)
sqlite://windows(c%2A/absolute/path/to/file.db)
at line 246
protected Connection
__construct(array $info)
Class Connection is a singleton. Access it via instance().
at line 272
array
columns(string $table)
Retrieves column meta data for the specified table.
at line 290
string
escape(string $string)
Escapes quotes in a string.
at line 301
int
insert_id(string $sequence = null)
Retrieve the insert id of the last model saved.
at line 313
mixed
query(string $sql, array $values = array())
Execute a raw SQL query on the database.
at line 348
string
query_and_fetch_one(string $sql, array $values = array())
Execute a query that returns maximum of one row with one field and return it.
at line 361
query_and_fetch(string $sql, Closure $handler)
Execute a raw SQL query and fetch the results.
at line 374
array
tables()
Returns all tables for the current database.
at line 388
transaction()
Starts a transaction.
at line 397
commit()
Commits the current transaction.
at line 406
rollback()
Rollback a transaction.
at line 417
boolean
supports_sequences()
Tells you if this adapter supports sequences or not.
at line 429
string
get_sequence_name(string $table, string $column_name)
Return a default sequence name for the specified table.
at line 440
string
next_sequence_value(string $sequence_name)
Return SQL for getting the next value in a sequence.
at line 451
string
quote_name(string $string)
Quote a name like table names and field names.
at line 463
string
date_to_string(DateTime $datetime)
Return a date time formatted into the database's date format.
at line 474
string
datetime_to_string(DateTime $datetime)
Return a date time formatted into the database's datetime format.
at line 485
object
string_to_datetime(string $string)
Converts a string representation of a datetime into a DateTime object.
at line 510
abstract string
limit(string $sql, int $offset, int $limit)
Adds a limit clause to the SQL query.
at line 518
abstract PDOStatement
query_column_info(string $table)
Query for column meta info and return statement handle.
at line 526
abstract PDOStatement
query_for_tables()
Query for all tables in the current database. The result must only contain one column which has the name of the table.
at line 531
abstract
set_encoding($charset)
Executes query to specify the character set for this connection.
at line 537
abstract
native_database_types()
at line 545
accepts_limit_and_order_for_update_and_delete()
Specifies whether or not adapter can use LIMIT/ORDER clauses with DELETE & UPDATE operations