Apex\Svc\Db

Description

SQL database driver.

Commonly Used Methods

  • public __construct(): Instantiate a new database connection object.
  • public delete(): Delete one or more records within a database table.
  • public getColumn(): Get a one dimensional array of a single column within a database table.
  • public getField(): Get value of a single column within the first row retrived.
  • public getHash(): Get an associative array of two columns within a database table.
  • public getIdObject(): Get a single row by the value of the table's id / primary key column mapped to an object.
  • public getIdRow(): Get a single row by value of the id / primary key column as an associative array.
  • public getObject(): Get the first row retrived mapped to an object.
  • public getRow(): Get the first row retrived as an associative array.
  • public insert(): Insert new record(s) into a database table.
  • public insertId(): Get value of the last auto incremented column generated during an insert.
  • public insertOrUpdate(): Insert or update a record into a database table.
  • public query(): Execute SQL statement against the database.
  • public update(): Update one or more records within a database table.


Additional Methods

  • public addTime(): Add a time period and interval to another time.
  • public beginTransaction(): Begin a database transaction.
  • public checkTable(): Check whether or not a database table exists.
  • public clearCache(): Upon retrieving table or column names, the results will be cached for future call to the functin during the request. Use this to clear that cache.
  • public closeCursors(): Close all currently open cursors within the database.
  • public commit(): Commit a database transaction.
  • public connect(): Used internally to lazy connect to the database upon first SQL statement being performed.
  • public dropAllTables(): Drop all tables within the database in proper order so as to not receive foreign key constraint errors.
  • public dropTable(): Drop database table including any child tables with foreign key constraints to the table.
  • public eval(): Evaluate SQL statement. Used to include SQL statement within queries (eg. now(), et al)
  • public executeSqlFile(): Execute all SQL code within a file on the on the local machine.
  • public fetchArray(): Get the next row of a query result as a numbered array.
  • public fetchAssoc(): Get he next row of a query result as an associative array with column names.
  • public fetchObject(): Get the next row of a query result mapped to an object.
  • public forceWrite(): Force all SQL queries to the master / write database connection, and never connect to the read-only connection.
  • public getColumnDetails(): Get details on all columns within a database table including type, whether it's primary or unique, allows null, et al.
  • public getColumnNames(): Get all column names within a database table, optionally with column type.
  • public getDatabaseSize(): Get the size of the database.
  • public getForeignKeys(): Get all foreign key constraints of a database table.
  • public getPrimaryKey(): Get the name of the primary key column of a database table.
  • public getReferencedForeignKeys(): Get the foreign key constraints that other database tables have on a given database table.
  • public getSelectCount(): Get total number of rows container within result of a select statement.
  • public getTableNames(): Get a list of all table names within the database.
  • public numRows(): Get the number of rows affected by a query result.
  • public rollback(): Rollback a database transaction.
  • public subtractTime(): Subtract a time period and interval from another time.
  • public truncate(): Delete all rows in a database table, and reset auto increment column.