SearchManipulateCapture_SQLite3Database deprecated
class SearchManipulateCapture_SQLite3Database extends SQLite3Database (View source)
deprecated
Traits
Provides extensions to this object to integrate it with standard config API methods.
Constants
PARTIAL_QUERY |
|
FULL_QUERY |
|
ENV_PATH |
Global environment config for setting 'path' |
ENV_KEY |
Global environment config for setting 'key' |
Config options
optimistic_connect | bool | In cases where your environment does not have 'SHOW DATABASES' permission, you can set this to true. Then selectDatabase() will always connect without doing databaseExists() check. |
from Database |
database_extension | string | Extension added to every database name |
from SQLite3Database |
Properties
protected static | array | $whitelist_array | To use, call from _config.php Example:
|
from Database |
protected | DBConnector | $connector | Database connector object |
from Database |
protected | int | $queryCount | Amount of queries executed, for debugging purposes. |
from Database |
protected | SQLite3SchemaManager | $schemaManager | Database schema manager object |
from SQLite3Database |
protected | DBQueryBuilder | $queryBuilder | Query builder object |
from Database |
protected | $parameters | from SQLite3Database | ||
protected | $livesInMemory | from SQLite3Database | ||
protected | bool | $transactionNesting | from SQLite3Database | |
protected | array | $transactionSavepoints | from SQLite3Database | |
public static | array | $default_pragma | List of default pragma values |
from SQLite3Database |
public | $isManipulationCapture |
Methods
Execute the given SQL query.
Execute the given SQL parameterised query with the specified arguments
Determines if the query should be previewed, and thus interrupted silently.
Allows the display and benchmarking of queries as they are being run
Add the sql queries that need to be partially or fully matched
Get the sql queries that need to be partially or fully matched
Get the autogenerated ID from the previous INSERT query.
Determines if we are connected to a server AND have a valid database selected.
Returns an escaped string. This string won't be quoted, so would be suitable for appending to other quoted strings.
Escapes an identifier (table / database name). Typically the value is simply double quoted. Don't pass in already escaped identifiers in, as this will double escape the value!
Escapes unquoted columns keys in an associative array
Generates a WHERE clause for null comparison check
Generate a WHERE clause for text matching.
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime in a certain format
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime addition
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime subtraction
Returns true if this database supports collations
Can the database override timezone as a connection setting, or does it use the system timezone exclusively?
Get the database server type (e.g. mysql, postgresql).
Return the number of rows affected by the previous operation.
The core search engine configuration.
Determines if this database supports transactions
Does this database support savepoints in transactions By default it is assumed that they don't unless they are explicitly enabled.
Does this database support transaction modes?
Invoke $callback within a transaction
No description
Start a prepared transaction See http://developer.postgresql.org/pgdocs/postgres/sql-set-transaction.html for details on transaction isolation options
Create a savepoint that you can jump back to if you encounter problems
Rollback or revert to a savepoint if your queries encounter problems If you encounter a problem at any point during a transaction, you may need to rollback that particular query, or return to a savepoint
Commit everything inside this transaction so far
Determines if the used database supports application-level locks, which is different from table- or row-level locking.
Sets an application-level lock so that no two processes can run at the same time, also called a "cooperative advisory lock".
Remove an application-level lock file to allow another process to run (if the execution aborts (e.g. due to an error) all locks are automatically released).
Determine if the database with the specified name exists
Retrieves the list of all databases the user has access to
Change the connection to the specified database, optionally creating the database if it doesn't exist in the current schema.
Drop the database that this object is currently connected to.
Returns the name of the currently selected database
Return SQL expression used to represent the current date/time
Returns the database-specific version of the random() function
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Extension used to distinguish between sqllite database files and other files.
Check if a database name has a valid extension
Retrieve parameters used to connect to this SQLLite database
Fetch the name of the most recent savepoint
Indicate whether or not the current transaction is nested Returns false if there are no transactions, or the open transaction is the 'outer' transaction, i.e. not nested.
Increase the nested transaction level by one savepoint tracking is optional because BEGIN opens a transaction, but is not a named reference
Decrease the nested transaction level by one and reduce the savepoint tracking if we are nesting, as the last one is no longer valid
In error condition, set transactionNesting to zero
Details
DBConnector
getConnector()
Get the current connector
setConnector(DBConnector $connector)
Injector injection point for connector dependency
DBSchemaManager
getSchemaManager()
Returns the current schema manager
setSchemaManager(DBSchemaManager $schemaManager)
Injector injection point for schema manager
DBQueryBuilder
getQueryBuilder()
Returns the current query builder
setQueryBuilder(DBQueryBuilder $queryBuilder)
Injector injection point for schema manager
Query
query(string $sql, int $errorLevel = E_USER_ERROR)
Execute the given SQL query.
Query
preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)
Execute the given SQL parameterised query with the specified arguments
protected bool
previewWrite(string $sql)
Determines if the query should be previewed, and thus interrupted silently.
If so, this function also displays the query via the debugging system. Subclasess should respect the results of this call for each query, and not execute any queries that generate a true response.
protected mixed
benchmarkQuery(string $sql, callable $callback, array $parameters = [])
Allows the display and benchmarking of queries as they are being run
protected
displayQuery(mixed $query, float $endtime)
Display query message
static
setWhitelistQueryArray(array $whitelistArray)
Add the sql queries that need to be partially or fully matched
static array
getWhitelistQueryArray()
Get the sql queries that need to be partially or fully matched
int
getGeneratedID(string $table)
Get the autogenerated ID from the previous INSERT query.
bool
isActive()
Determines if we are connected to a server AND have a valid database selected.
string
escapeString(mixed $value)
Returns an escaped string. This string won't be quoted, so would be suitable for appending to other quoted strings.
string
quoteString(mixed $value)
Wrap a string into DB-specific quotes.
string
escapeIdentifier(string|array $value, string $separator = '.')
Escapes an identifier (table / database name). Typically the value is simply double quoted. Don't pass in already escaped identifiers in, as this will double escape the value!
protected array
escapeColumnKeys(array $fieldValues)
Escapes unquoted columns keys in an associative array
manipulate(array $manipulation)
Execute a complex manipulation on the database.
A manipulation is an array of insert / or update sequences. The keys of the array are table names, and the values are map containing 'command' and 'fields'. Command should be 'insert' or 'update', and fields should be a map of field names to field values, NOT including quotes.
The field values could also be in paramaterised format, such as array('MAX(?,?)' => array(42, 69)), allowing the use of raw SQL values such as array('NOW()' => array()).
quiet()
Enable suppression of database messages.
clearAllData()
Clear all data out of the database
clearTable(string $table)
Clear all data in a given table
string
nullCheckClause(string $field, bool $isNull)
Generates a WHERE clause for null comparison check
string
comparisonClause(string $field, string $value, bool $exact = false, bool $negate = false, bool $caseSensitive = null, bool $parameterised = false)
Generate a WHERE clause for text matching.
string
formattedDatetimeClause(string $date, string $format)
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime in a certain format
string
datetimeIntervalClause(string $date, string $interval)
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime addition
string
datetimeDifferenceClause(string $date1, string $date2)
function to return an SQL datetime expression that can be used with the adapter in use used for querying a datetime subtraction
string
concatOperator()
String operator for concatenation of strings
bool
supportsCollations()
Returns true if this database supports collations
bool
supportsTimezoneOverride()
Can the database override timezone as a connection setting, or does it use the system timezone exclusively?
string
getVersion()
Query for the version of the currently connected database
string
getDatabaseServer()
Get the database server type (e.g. mysql, postgresql).
This value is passed to the connector as the 'driver' argument when initiating a database connection
int
affectedRows()
Return the number of rows affected by the previous operation.
PaginatedList
searchEngine(array $classesToSearch, string $keywords, int $start, int $pageLength, string $sortBy = "Relevance DESC", string $extraFilter = "", bool $booleanSearch = false, string $alternativeFileFilter = "", bool $invertedMatch = false)
The core search engine configuration.
bool
supportsTransactions()
Determines if this database supports transactions
bool
supportsSavepoints()
Does this database support savepoints in transactions By default it is assumed that they don't unless they are explicitly enabled.
bool
supportsTransactionMode(string $mode)
Does this database support transaction modes?
SQLite doesn't support transaction modes.
withTransaction(callable $callback, callable $errorCallback = null, bool|string $transactionMode = false, bool $errorIfTransactionsUnsupported = false)
Invoke $callback within a transaction
supportsExtensions($extensions = array('partitions', 'tablespaces', 'clustering'))
No description
transactionStart($transaction_mode = false, $session_characteristics = false)
Start a prepared transaction See http://developer.postgresql.org/pgdocs/postgres/sql-set-transaction.html for details on transaction isolation options
transactionSavepoint(string $savepoint)
Create a savepoint that you can jump back to if you encounter problems
bool|null
transactionRollback(string|bool $savepoint = false)
Rollback or revert to a savepoint if your queries encounter problems If you encounter a problem at any point during a transaction, you may need to rollback that particular query, or return to a savepoint
bool|null
transactionEnd(bool $chain = false)
Commit everything inside this transaction so far
int
transactionDepth()
Return depth of current transaction
bool
supportsLocks()
Determines if the used database supports application-level locks, which is different from table- or row-level locking.
See getLock() for details.
bool
canLock(string $name)
Returns if the lock is available.
See supportsLocks() to check if locking is generally supported.
bool
getLock(string $name, int $timeout = 5)
Sets an application-level lock so that no two processes can run at the same time, also called a "cooperative advisory lock".
Return FALSE if acquiring the lock fails; otherwise return TRUE, if lock was acquired successfully. Lock is automatically released if connection to the database is broken (either normally or abnormally), making it less prone to deadlocks than session- or file-based locks. Should be accompanied by a releaseLock() call after the logic requiring the lock has completed. Can be called multiple times, in which case locks "stack" (PostgreSQL, SQL Server), or auto-releases the previous lock (MySQL).
Note that this might trigger the database to wait for the lock to be released, delaying further execution.
bool
releaseLock(string $name)
Remove an application-level lock file to allow another process to run (if the execution aborts (e.g. due to an error) all locks are automatically released).
connect(array $parameters)
Connect to a SQLite3 database.
bool
databaseExists(string $name)
Determine if the database with the specified name exists
array
databaseList()
Retrieves the list of all databases the user has access to
bool
selectDatabase(string $name, bool $create = false, int|bool $errorLevel = E_USER_ERROR)
Change the connection to the specified database, optionally creating the database if it doesn't exist in the current schema.
dropSelectedDatabase()
Drop the database that this object is currently connected to.
Use with caution.
string|null
getSelectedDatabase()
Returns the name of the currently selected database
string
now()
Return SQL expression used to represent the current date/time
string
random()
Returns the database-specific version of the random() function
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
stat(string $name)
deprecated
deprecated
Get inherited config value
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
$this
set_stat(string $name, mixed $value)
deprecated
deprecated
Update the config value for a given property
static string
database_extension()
Extension used to distinguish between sqllite database files and other files.
Required to handle multiple databases.
static bool
is_valid_database_name(string $name)
Check if a database name has a valid extension
array
getParameters()
Retrieve parameters used to connect to this SQLLite database
bool
getLivesInMemory()
Determine if this Db is in memory
string|null
getPath()
Get file path. If in memory this is null
setPragma(string $pragma, string $value)
Execute PRAGMA commands.
string
getPragma(string $pragma)
Gets pragma value.
protected string
getTransactionSavepointName()
Fetch the name of the most recent savepoint
protected bool
transactionIsNested()
Indicate whether or not the current transaction is nested Returns false if there are no transactions, or the open transaction is the 'outer' transaction, i.e. not nested.
protected
transactionDepthIncrease(string $savepoint = null)
Increase the nested transaction level by one savepoint tracking is optional because BEGIN opens a transaction, but is not a named reference
protected
transactionDepthDecrease()
Decrease the nested transaction level by one and reduce the savepoint tracking if we are nesting, as the last one is no longer valid
protected
resetTransactionNesting()
In error condition, set transactionNesting to zero
protected
inspectQuery(string $sql)
deprecated
deprecated
Inspect a SQL query prior to execution
__construct()
No description