Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • AlphaDAO
  • AlphaDAOProviderFactory
  • AlphaDAOProviderMySQL
  • AlphaDAOProviderSQLite
  • ArticleCommentObject
  • ArticleObject
  • ArticleVoteObject
  • BadRequestObject
  • BlacklistedClientObject
  • BlacklistedIPObject
  • PersonObject
  • RightsObject
  • TagObject

Interfaces

  • AlphaDAOProviderInterface
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class AlphaDAOProviderMySQL

MySQL DAO provider (uses the MySQLi native API in PHP).

AlphaDAOProviderMySQL implements AlphaDAOProviderInterface
Package: alpha::model
Copyright: Copyright (c) 2012, John Collins (founder of Alpha Framework). All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License: The BSD License
Author: John Collins <dev@alphaframework.org>
Version: $Id: AlphaDAOProviderMySQL.inc 1599 2012-11-29 12:31:15Z alphadevx $
Since: 1.1
Located at model/AlphaDAOProviderMySQL.inc
Methods summary
public
# __construct( )

The constructor

The constructor

Since

1.1
public static mysqli
# getConnection( )

(non-PHPdoc)

(non-PHPdoc)

Returns

mysqli

See

alpha/model/AlphaDAOProviderInterface::getConnection()

Implementation of

AlphaDAOProviderInterface::getConnection()
public static
# disconnect( )

(non-PHPdoc)

(non-PHPdoc)

See

alpha/model/AlphaDAOProviderInterface::disconnect()

Implementation of

AlphaDAOProviderInterface::disconnect()
public static string
# getLastDatabaseError( )

(non-PHPdoc)

(non-PHPdoc)

Returns

string

See

alpha/model/AlphaDAOProviderInterface::getLastDatabaseError()

Implementation of

AlphaDAOProviderInterface::getLastDatabaseError()
public array
# query( string $sqlQuery )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$sqlQuery
string
$sqlQuery

Returns

array

Throws

CustomQueryException

See

alpha/model/AlphaDAOProviderInterface::query()

Implementation of

AlphaDAOProviderInterface::query()
public
# load( integer $OID )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$OID
integer
$OID The object ID of the business object to load.

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::load()

Implementation of

AlphaDAOProviderInterface::load()
public
# loadByAttribute( string $attribute, string $value, boolean $ignoreClassType = false, array $loadAttributes = array() )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attribute
string
$atribute The name of the attribute to load the object by.
$value
string
$value The value of the attribute to load the object by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
$loadAttributes
array
$loadAttributes The attributes to load from the database to this object (leave blank to load all attributes)

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::loadByAttribute()

Implementation of

AlphaDAOProviderInterface::loadByAttribute()
public array
# loadAll( integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$start
integer
$start The start of the SQL LIMIT clause, useful for pagination.
$limit
integer
$limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string
$orderBy The name of the field to sort the objects by.
$order
string
$order The order to sort the objects by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::loadAll()

Implementation of

AlphaDAOProviderInterface::loadAll()
public array
# loadAllByAttribute( string $attribute, string $value, integer $start = 0, integer $limit = 0, string $orderBy = "OID", string $order = "ASC", boolean $ignoreClassType = false, array $constructorArgs = array() )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attribute
string
$atribute The attribute to load the objects by.
$value
string
$value The value of the attribute to load the objects by.
$start
integer
$start The start of the SQL LIMIT clause, useful for pagination.
$limit
integer
$limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string
$orderBy The name of the field to sort the objects by.
$order
string
$order The order to sort the objects by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.
$constructorArgs
array
$constructorArgs An optional array of contructor arguements to pass to the BOs that will be generated and returned. Supports a maximum of 5 arguements.

Returns

array
An array containing objects of this type of business object.

Throws

BONotFoundException
IllegalArguementException

See

alpha/model/AlphaDAOProviderInterface::loadAllByAttribute()

Implementation of

AlphaDAOProviderInterface::loadAllByAttribute()
public array
# loadAllByAttributes( array $attributes = array(), array $values = array(), integer $start = 0, integer $limit = 0, string $orderBy = 'OID', string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attributes
array
$atributes The attributes to load the objects by.
$values
array
$values The values of the attributes to load the objects by.
$start
integer
$start The start of the SQL LIMIT clause, useful for pagination.
$limit
integer
$limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string
$orderBy The name of the field to sort the objects by.
$order
string
$order The order to sort the objects by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

BONotFoundException
IllegalArguementException

See

alpha/model/AlphaDAOProviderInterface::loadAllByAttributes()

Implementation of

AlphaDAOProviderInterface::loadAllByAttributes()
public array
# loadAllByDayUpdated( string $date, integer $start = 0, integer $limit = 0, string $orderBy = "OID", string $order = "ASC", boolean $ignoreClassType = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$date
string
$date The date for which to load the objects updated on, in the format 'YYYY-MM-DD'.
$start
integer
$start The start of the SQL LIMIT clause, useful for pagination.
$limit
integer
$limit The amount (limit) of objects to load, useful for pagination.
$orderBy
string
$orderBy The name of the field to sort the objects by.
$order
string
$order The order to sort the objects by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type

Returns

array
An array containing objects of this type of business object.

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::loadAllByDayUpdated()

Implementation of

AlphaDAOProviderInterface::loadAllByDayUpdated()
public array
# loadAllFieldValuesByAttribute( string $attribute, string $value, string $returnAttribute, string $order = 'ASC', boolean $ignoreClassType = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attribute
string
$attribute The attribute name to load the field values by.
$value
string
$value The value of the attribute to load the field values by.
$returnAttribute
string
$returnAttribute The name of the attribute to return.
$order
string
$order The order to sort the BOs by.
$ignoreClassType
boolean
$ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.

Returns

array
An array of field values.

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::loadAllFieldValuesByAttribute()

Implementation of

AlphaDAOProviderInterface::loadAllFieldValuesByAttribute()
public
# save( )

(non-PHPdoc)

(non-PHPdoc)

Throws

FailedSaveException
LockingException
ValidationException

See

alpha/model/AlphaDAOProviderInterface::save()

Implementation of

AlphaDAOProviderInterface::save()
public
# saveAttribute( string $attribute, mixed $value )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attribute
string
$attribute The name of the attribute to save.
$value
mixed
$value The value of the attribute to save.

Throws

IllegalArguementException
FailedSaveException

See

alpha/model/AlphaDAOProviderInterface::saveAttribute()

Implementation of

AlphaDAOProviderInterface::saveAttribute()
public
# saveHistory( )

(non-PHPdoc)

(non-PHPdoc)

Throws

FailedSaveException

See

alpha/model/AlphaDAOProviderInterface::saveHistory()

Implementation of

AlphaDAOProviderInterface::saveHistory()
public
# delete( )

(non-PHPdoc)

(non-PHPdoc)

Throws

FailedDeleteException

See

alpha/model/AlphaDAOProviderInterface::delete()

Implementation of

AlphaDAOProviderInterface::delete()
public integer
# getVersion( )

(non-PHPdoc)

(non-PHPdoc)

Returns

integer

Throws

BONotFoundException

See

alpha/model/AlphaDAOProviderInterface::getVersion()

Implementation of

AlphaDAOProviderInterface::getVersion()
public
# makeTable( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::makeTable()

Implementation of

AlphaDAOProviderInterface::makeTable()
public
# makeHistoryTable( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::makeHistoryTable()

Implementation of

AlphaDAOProviderInterface::makeHistoryTable()
public
# rebuildTable( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::rebuildTable()

Implementation of

AlphaDAOProviderInterface::rebuildTable()
public
# dropTable( string $tableName = null )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$tableName
string
$tableName Optional table name, leave blank for the defined table for this class to be dropped

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::dropTable()

Implementation of

AlphaDAOProviderInterface::dropTable()
public
# addProperty( string $propName )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$propName
string
$propName The name of the new field to add to the database table.

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::addProperty()

Implementation of

AlphaDAOProviderInterface::addProperty()
public integer
# getMAX( )

(non-PHPdoc)

(non-PHPdoc)

Returns

integer
The maximum OID value in the class table.

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::getMAX()

Implementation of

AlphaDAOProviderInterface::getMAX()
public integer
# getCount( array $attributes = array(), array $values = array() )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attributes
array
$atributes The attributes to count the objects by (optional).
$values
array
$values The values of the attributes to count the objects by (optional).

Returns

integer

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::getCount()

Implementation of

AlphaDAOProviderInterface::getCount()
public integer
# getHistoryCount( )

(non-PHPdoc)

(non-PHPdoc)

Returns

integer

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::getHistoryCount()

Implementation of

AlphaDAOProviderInterface::getHistoryCount()
public
# setEnumOptions( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

Since

1.1

See

alpha/model/AlphaDAOProviderInterface::setEnumOptions()

Implementation of

AlphaDAOProviderInterface::setEnumOptions()
public boolean
# checkTableExists( boolean $checkHistoryTable = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$checkHistoryTable
boolean
$checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.

Returns

boolean

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::checkTableExists()

Implementation of

AlphaDAOProviderInterface::checkTableExists()
public static boolean
# checkBOTableExists( string $BOClassName, boolean $checkHistoryTable = false )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$BOClassName
string
$BOClassName The name of the business object class we are checking.
$checkHistoryTable
boolean
$checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.

Returns

boolean

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::checkBOTableExists()

Implementation of

AlphaDAOProviderInterface::checkBOTableExists()
public boolean
# checkTableNeedsUpdate( )

(non-PHPdoc)

(non-PHPdoc)

Returns

boolean

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::checkTableNeedsUpdate()

Implementation of

AlphaDAOProviderInterface::checkTableNeedsUpdate()
public array
# findMissingFields( )

(non-PHPdoc)

(non-PHPdoc)

Returns

array
An array of missing fields in the database table.

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::findMissingFields()

Implementation of

AlphaDAOProviderInterface::findMissingFields()
public array
# getIndexes( )

(non-PHPdoc)

(non-PHPdoc)

Returns

array
An array of database indexes on this table.

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::getIndexes()

Implementation of

AlphaDAOProviderInterface::getIndexes()
private
# checkIndexes( )

Checks to see if all of the indexes are in place for the BO's table, creates those that are missing.

Checks to see if all of the indexes are in place for the BO's table, creates those that are missing.

Since

1.1
public
# createForeignIndex( string $attributeName, string $relatedClass, string $relatedClassAttribute )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attributeName
string
$attributeName The name of the attribute to apply the index on.
$relatedClass
string
$relatedClass The name of the related class in the format "NameObject".
$relatedClassAttribute
string
$relatedClassAttribute The name of the field to relate to on the related class.

Throws

FailedIndexCreateException

See

alpha/model/AlphaDAOProviderInterface::createForeignIndex()

Implementation of

AlphaDAOProviderInterface::createForeignIndex()
public
# createUniqueIndex( string $attribute1Name, string $attribute2Name = '', string $attribute3Name = '' )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$attribute1Name
string
$attribute1Name The first attribute to mark unique in the database.
$attribute2Name
string
$attribute2Name The second attribute to mark unique in the databse (optional, use only for composite keys).
$attribute3Name
string
$attribute3Name The third attribute to mark unique in the databse (optional, use only for composite keys).

Throws

FailedIndexCreateException

See

alpha/model/AlphaDAOProviderInterface::createUniqueIndex()

Implementation of

AlphaDAOProviderInterface::createUniqueIndex()
public
# reload( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::reload()

Implementation of

AlphaDAOProviderInterface::reload()
public boolean
# checkRecordExists( integer $OID )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$OID
integer
$OID The Object ID of the object we want to see whether it exists or not.

Returns

boolean

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::checkRecordExists()

Implementation of

AlphaDAOProviderInterface::checkRecordExists()
public boolean
# isTableOverloaded( )

(non-PHPdoc)

(non-PHPdoc)

Returns

boolean

Throws

BadBOTableNameException

See

alpha/model/AlphaDAOProviderInterface::isTableOverloaded()

Implementation of

AlphaDAOProviderInterface::isTableOverloaded()
public static
# begin( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::begin()

Implementation of

AlphaDAOProviderInterface::begin()
public static
# commit( )

(non-PHPdoc)

(non-PHPdoc)

Throws

FailedSaveException

See

alpha/model/AlphaDAOProviderInterface::commit()

Implementation of

AlphaDAOProviderInterface::commit()
public static
# rollback( )

(non-PHPdoc)

(non-PHPdoc)

Throws

AlphaException

See

alpha/model/AlphaDAOProviderInterface::rollback()

Implementation of

AlphaDAOProviderInterface::rollback()
public
# setBO( AlphaDAO $BO )

(non-PHPdoc)

(non-PHPdoc)

Parameters

$BO
AlphaDAO
$BO

See

alpha/model/AlphaDAOProviderInterface::setBO()

Implementation of

AlphaDAOProviderInterface::setBO()
private mysqli_stmt
# bindParams( mysqli_stmt $stmt, array $attributes = array(), array $values = array() )

Dynamically binds all of the attributes for the current BO to the supplied prepared statement parameters. If arrays of attribute names and values are provided, only those will be bound to the supplied statement.

Dynamically binds all of the attributes for the current BO to the supplied prepared statement parameters. If arrays of attribute names and values are provided, only those will be bound to the supplied statement.

Parameters

$stmt
mysqli_stmt
$stmt The SQL statement to bind to.
$attributes
array
Optional array of BO attributes.
$values
array
Optional array of BO values.

Returns

mysqli_stmt

Since

1.1
private array
# bindResult( mysqli_stmt $stmt )

Dynamically binds the result of the supplied prepared statement to a 2d array, where each element in the array is another array representing a database row.

Dynamically binds the result of the supplied prepared statement to a 2d array, where each element in the array is another array representing a database row.

Parameters

$stmt
mysqli_stmt
$stmt

Returns

array
A 2D array containing the query result.

Since

1.1
private
# findOffendingValue( string $error )

Parses a MySQL error for the value that violated a unique constraint.

Parses a MySQL error for the value that violated a unique constraint.

Parameters

$error
string
$error The MySQL error string.

Since

1.1
Properties summary
private static Logger $logger null
#

Trace logger

Trace logger

Since

1.1
private static mysqli $connection
#

Datebase connection

Datebase connection

Since

1.1
private AlphaDAO $BO
#

The business object that we are mapping back to

The business object that we are mapping back to

Since

1.1
Alpha Framework ${alpha.version.new} API Documentation API documentation generated by ApiGen 2.8.0