Skip to content

classes_essentials_model_driver_idatabasedriver.class

Daniel Spors edited this page Dec 19, 2023 · 3 revisions

Classes in file essentials/model/driver/idatabasedriver.class.php

interface IDatabaseDriver

Interface for database drivers. Although ScavixWDF uses PDO each database has it's specialities so we need a driver interface. The actual database drivers must imeplement this to be compatible with ScavixWDF.

createTable

Create a table from an objects schema. We are not sure if we will ever implement this side as we prefer to create our tables in the database.

Definition: public function createTable($objSchema)

Returns: void

Parameters:

  • \ScavixWDF\Model\TableSchema $objSchema Tableschema as specified by the Model

getDeleteStatement

Creates a valid statement to delete the given model from the database.

Definition: public function getDeleteStatement($model, $args)

Returns: bool|\ScavixWDF\Model\ResultSet SQL statement with argument placeholders to identify $model (see $args)

Parameters:

  • \ScavixWDF\Model\Model $model Model to delete

  • array $args OUT:The values extracted from $model to uniquely identify it (the primary key values)

getPagedStatement

Create a pages statement from an unpaged one.

Definition: public function getPagedStatement($sql, $page, $items_per_page)

Returns: \ScavixWDF\Model\ResultSet Paged SQL statement

Parameters:

  • string $sql The original statement

  • int $page The one-based page index

  • int $items_per_page Items per page

getPagingInfo

Returns paging informaton about a query.

Definition: public function getPagingInfo($sql, $input_arguments=null)

Returns: array An array containing: rows_per_page, current_page, total_pages, total_rows, offset

Parameters:

  • string $sql SQL statement to get information for

  • array $input_arguments Input parameters for the SQL statement

getSaveStatement

Creates a valid save statement to store an object into the database.

Definition: public function getSaveStatement($model, $args, $columns_to_update=false)

Returns: string SQL statement with argument placeholders for all change columns (see $args)

Parameters:

  • \ScavixWDF\Model\Model $model The model to store

  • array $args OUT:The values extracted from $model that have changed wince last save (or all if new object)

  • array $columns_to_update If given only these fields will be updated. If not Model tries to detect changed columns automatically.

getTableSchema

Returns the schema of a table.

Definition: public function getTableSchema($tablename)

Returns: \ScavixWDF\Model\TableSchema The tables schema

Parameters:

  • string $tablename The tables name

initDriver

Initializes the driver.

Definition: public function initDriver($datasource, $pdo)

Returns: void

Parameters:

  • \ScavixWDF\Model\DataSource $datasource The datasource object using this driver (it is called $this over there)

  • \ScavixWDF\Model\PdoLayer $pdo The PDO database connection

listColumns

Returns a list of all column names in a table.

Definition: public function listColumns($tablename)

Returns: array Array of column names

Parameters:

  • string $tablename Name of table to query

listTables

Returns a list of all tables.

Definition: public function listTables()

Returns: array List of tables

Now

Returns an SQL query to get the current datetime.

Definition: public function Now($seconds_to_add)

Returns: string Query to get now from the Db

Parameters:

  • int $seconds_to_add Offset to now in seconds (can also be negative)

PreprocessSql

Preprocesses an SQL statement. Some drivers need to perform some extra parameter specifier processing or stuff. Can be implemented here as this will be called with every query.

Definition: public function PreprocessSql($sql)

Returns: string Statement valid for this drivers database

Parameters:

  • string $sql RAW SQL statement

tableExists

Checks if a table exists.

Definition: public function tableExists($tablename)

Returns: bool true or false

Parameters:

  • string $tablename name of table to check for
Clone this wiki locally