DataAccessMysqli

DataAccessMysqli handles connecting to and querying database using php mysqli_* functions

Summary
DataAccessMysqli handles connecting to and querying database using php mysqli_* functions
database connection resource
database name
DataAccessError
DataAccessMysql class constructor
given a hostname, username, password and database name makes a connection to the database and selects the database if the connection cannot be made or the database cannot be selected, throws DAOExcpetion
given an SQL string, queries the database and returns the result or throws DAOException
escape a value before using it in a query string
returns the number of rows affected by an insert, update or delete query
disconnect database connection

Variables

conn

protected $conn

database connection resource

db

protected $db

database name

error

private $error

DataAccessError

Functions

__construct

public function __construct($host,
$user,
$pass,
$db)

DataAccessMysql class constructor

parameters

hosthostname string
userusername string
passpassword string
dbdatabase name

connect

public function connect($host,
$user,
$pass,
$db)

given a hostname, username, password and database name makes a connection to the database and selects the database if the connection cannot be made or the database cannot be selected, throws DAOExcpetion

parameters

hosthostname string
userusername string
passpassword string
dbdatabase name

returns

boolean

query

public function query($sql)

given an SQL string, queries the database and returns the result or throws DAOException

parameters

sqlsql query string

returns

DataResultMysql object

escape

public function escape($val)

escape a value before using it in a query string

parameters

valvalue to escape

returns

escaped value

getAffectedRows

public function getAffectedRows()

returns the number of rows affected by an insert, update or delete query

returns

integer indicating number of row affected

disconnect

public function disconnect()

disconnect database connection

returns

boolean indicating if disconnect was successful

protected $conn
database connection resource
protected $db
database name
private $error
DataAccessError
public function __construct($host,
$user,
$pass,
$db)
DataAccessMysql class constructor
public function connect($host,
$user,
$pass,
$db)
given a hostname, username, password and database name makes a connection to the database and selects the database if the connection cannot be made or the database cannot be selected, throws DAOExcpetion
public function query($sql)
given an SQL string, queries the database and returns the result or throws DAOException
public function escape($val)
escape a value before using it in a query string
public function getAffectedRows()
returns the number of rows affected by an insert, update or delete query
public function disconnect()
disconnect database connection