Documentation

Db
in package

Db class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
5.3.0

Table of Contents

$classToTable  : array<string|int, mixed>
Database connection class to table relationship
$db  : array<string|int, mixed>
Database connection(s)
addClassToTable()  : void
Add class-to-table relationship
check()  : mixed
Check the database connection
connect()  : AbstractAdapter
Method to connect to a database and return the database adapter object
db()  : AbstractAdapter
Get DB adapter (alias)
executeSql()  : void
Execute SQL
executeSqlFile()  : void
Execute SQL
getAll()  : array<string|int, mixed>
Get all DB adapters
getAvailableAdapters()  : array<string|int, mixed>
Get the available database adapters
getDb()  : AbstractAdapter
Get DB adapter
hasClassToTable()  : bool
Check if class-to-table relationship exists
hasDb()  : bool
Check for a DB adapter
isAvailable()  : bool
Determine if a database adapter is available
mysqlConnect()  : Mysql|AbstractAdapter
Method to connect to a MySQL database and return the MySQL database adapter object
pdoConnect()  : Pdo|AbstractAdapter
Method to connect to a PDO database and return the PDO database adapter object
pgsqlConnect()  : Pgsql|AbstractAdapter
Method to connect to a PostgreSQL database and return the PostgreSQL database adapter object
setDb()  : void
Set DB adapter
setDefaultDb()  : void
Set DB adapter
sqliteConnect()  : Sqlite|AbstractAdapter
Method to connect to a SQLite database and return the SQLite database adapter object
sqlsrvConnect()  : Sqlsrv|AbstractAdapter
Method to connect to a SQL Server database and return the SQL Server database adapter object

Properties

$classToTable

Database connection class to table relationship

protected static array<string|int, mixed> $classToTable = []

$db

Database connection(s)

protected static array<string|int, mixed> $db = ['default' => null]

Methods

addClassToTable()

Add class-to-table relationship

public static addClassToTable(string $class, string $table) : void
Parameters
$class : string
$table : string
Return values
void

check()

Check the database connection

public static check(string $adapter, array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : mixed
Parameters
$adapter : string
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Return values
mixed

connect()

Method to connect to a database and return the database adapter object

public static connect(string $adapter, array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : AbstractAdapter
Parameters
$adapter : string
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
AbstractAdapter

executeSql()

Execute SQL

public static executeSql(string $sql, mixed $adapter[, array<string|int, mixed> $options = [] ][, string $prefix = '\Pop\Db\Adapter\' ]) : void
Parameters
$sql : string
$adapter : mixed
$options : array<string|int, mixed> = []
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
void

executeSqlFile()

Execute SQL

public static executeSqlFile(string $sqlFile, mixed $adapter[, array<string|int, mixed> $options = [] ][, string $prefix = '\Pop\Db\Adapter\' ]) : void
Parameters
$sqlFile : string
$adapter : mixed
$options : array<string|int, mixed> = []
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
void

getAll()

Get all DB adapters

public static getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAvailableAdapters()

Get the available database adapters

public static getAvailableAdapters() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasClassToTable()

Check if class-to-table relationship exists

public static hasClassToTable(string $class) : bool
Parameters
$class : string
Return values
bool

hasDb()

Check for a DB adapter

public static hasDb([string $class = null ]) : bool
Parameters
$class : string = null
Return values
bool

isAvailable()

Determine if a database adapter is available

public static isAvailable(string $adapter) : bool
Parameters
$adapter : string
Return values
bool

mysqlConnect()

Method to connect to a MySQL database and return the MySQL database adapter object

public static mysqlConnect(array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : Mysql|AbstractAdapter
Parameters
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
Mysql|AbstractAdapter

pdoConnect()

Method to connect to a PDO database and return the PDO database adapter object

public static pdoConnect(array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : Pdo|AbstractAdapter
Parameters
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
Pdo|AbstractAdapter

pgsqlConnect()

Method to connect to a PostgreSQL database and return the PostgreSQL database adapter object

public static pgsqlConnect(array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : Pgsql|AbstractAdapter
Parameters
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
Pgsql|AbstractAdapter

setDb()

Set DB adapter

public static setDb(AbstractAdapter $db[, string $class = null ][, string $prefix = null ][, bool $isDefault = false ]) : void
Parameters
$db : AbstractAdapter
$class : string = null
$prefix : string = null
$isDefault : bool = false
Return values
void

setDefaultDb()

Set DB adapter

public static setDefaultDb(AbstractAdapter $db[, string $class = null ][, string $prefix = null ]) : void
Parameters
$db : AbstractAdapter
$class : string = null
$prefix : string = null
Return values
void

sqliteConnect()

Method to connect to a SQLite database and return the SQLite database adapter object

public static sqliteConnect(array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : Sqlite|AbstractAdapter
Parameters
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
Sqlite|AbstractAdapter

sqlsrvConnect()

Method to connect to a SQL Server database and return the SQL Server database adapter object

public static sqlsrvConnect(array<string|int, mixed> $options[, string $prefix = '\Pop\Db\Adapter\' ]) : Sqlsrv|AbstractAdapter
Parameters
$options : array<string|int, mixed>
$prefix : string = '\Pop\Db\Adapter\'
Tags
throws
Exception
Return values
Sqlsrv|AbstractAdapter

Search results