Overview

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • ActionLog
  • ActiveRecord
  • ActiveRecordProviderFactory
  • ActiveRecordProviderMySQL
  • ActiveRecordProviderSQLite
  • Article
  • ArticleComment
  • ArticleVote
  • BadRequest
  • BlacklistedClient
  • BlacklistedIP
  • Person
  • Rights
  • Tag

Interfaces

  • ActiveRecordProviderInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class ActiveRecordProviderMySQL

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

Alpha\Model\ActiveRecordProviderMySQL implements Alpha\Model\ActiveRecordProviderInterface
Namespace: Alpha\Model
Copyright: Copyright (c) 2015, John Collins (founder of Alpha Framework). All rights reserved. <pre> 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. </pre>
License: The BSD License
Author: John Collins <dev@alphaframework.org>
Since: 1.1
Located at Model/ActiveRecordProviderMySQL.php
Methods summary
public
# __construct( )

The constructor.

The constructor.

Since

1.1
public static mixed
# getConnection( )

(non-PHPdoc).

(non-PHPdoc).

Returns

mixed
mixed

See

Alpha\Model\ActiveRecordProviderInterface::getConnection()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getConnection()
public static
# disconnect( )

(non-PHPdoc).

(non-PHPdoc).

See

Alpha\Model\ActiveRecordProviderInterface::disconnect()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::disconnect()
public static string
# getLastDatabaseError( )

(non-PHPdoc).

(non-PHPdoc).

Returns

string
string

See

Alpha\Model\ActiveRecordProviderInterface::getLastDatabaseError()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getLastDatabaseError()
public array
# query( string $sqlQuery )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$sqlQuery
string $sqlQuery

Returns

array
array

Throws

Alpha\Exception\CustomQueryException
Alpha\Exception\CustomQueryException

See

Alpha\Model\ActiveRecordProviderInterface::query()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::query()
public
# load( integer $OID, integer $version = 0 )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$OID
int $OID The object ID of the record to load.
$version
int $version Optionaly, provide the version to load that version from the [tablename]_history table.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::load()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::load()
public array
# loadAllOldVersions( integer $OID )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$OID
int $OID The object ID of the record to load.

Returns

array
An array containing objects of this type of record object, order by version.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()
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 record by.
$value
string $value The value of the attribute to load the record by.
$ignoreClassType
bool $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

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of records to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the records by.
$order
string $order The order to sort the records by.
$ignoreClassType
bool $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 record object.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAll()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $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
bool $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

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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, array $constructorArgs = array() )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$attributes
array $atributes The attributes to load the records by.
$values
array $values The values of the attributes to load the records by.
$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of records to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the records by.
$order
string $order The order to sort the records by.
$ignoreClassType
bool $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 record object.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByAttributes()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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 records updated on, in the format 'YYYY-MM-DD'.
$start
int $start The start of the SQL LIMIT clause, useful for pagination.
$limit
int $limit The amount (limit) of records to load, useful for pagination.
$orderBy
string $orderBy The name of the field to sort the records by.
$order
string $order The order to sort the records by.
$ignoreClassType
bool $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 record object.

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllByDayUpdated()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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 records by.
$ignoreClassType
bool $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

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::loadAllFieldValuesByAttribute()
public
# save( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException
Alpha\Exception\LockingException
Alpha\Exception\LockingException
Alpha\Exception\ValidationException
Alpha\Exception\ValidationException

See

Alpha\Model\ActiveRecordProviderInterface::save()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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

Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException
Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException

See

Alpha\Model\ActiveRecordProviderInterface::saveAttribute()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::saveAttribute()
public
# saveHistory( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException

See

Alpha\Model\ActiveRecordProviderInterface::saveHistory()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::saveHistory()
public
# delete( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedDeleteException
Alpha\Exception\FailedDeleteException

See

Alpha\Model\ActiveRecordProviderInterface::delete()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::delete()
public integer
# getVersion( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer
int

Throws

Alpha\Exception\RecordFoundException
Alpha\Exception\RecordFoundException

See

Alpha\Model\ActiveRecordProviderInterface::getVersion()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getVersion()
public
# makeTable( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::makeTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::makeTable()
public
# makeHistoryTable( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::makeHistoryTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::makeHistoryTable()
public
# rebuildTable( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::rebuildTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::dropTable()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::addProperty()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::addProperty()
public integer
# getMAX( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer
The maximum OID value in the class table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getMAX()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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
int

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getCount()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getCount()
public integer
# getHistoryCount( )

(non-PHPdoc).

(non-PHPdoc).

Returns

integer
int

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getHistoryCount()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getHistoryCount()
public
# setEnumOptions( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

Since

1.1

See

Alpha\Model\ActiveRecordProviderInterface::setEnumOptions()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::setEnumOptions()
public boolean
# checkTableExists( boolean $checkHistoryTable = false )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkTableExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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
bool $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException
Alpha\Exception\IllegalArguementException
Alpha\Exception\IllegalArguementException

See

Alpha\Model\ActiveRecordProviderInterface::checkBOTableExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkBOTableExists()
public boolean
# checkTableNeedsUpdate( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkTableNeedsUpdate()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkTableNeedsUpdate()
public array
# findMissingFields( )

(non-PHPdoc).

(non-PHPdoc).

Returns

array
An array of missing fields in the database table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::findMissingFields()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::findMissingFields()
public array
# getIndexes( )

(non-PHPdoc).

(non-PHPdoc).

Returns

array
An array of database indexes on this table.

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::getIndexes()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::getIndexes()
public
# createForeignIndex( string $attributeName, string $relatedClass, string $relatedClassAttribute, boolean $indexName = null )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$attributeName
string $attributeName The name of the attribute to apply the index on.
$relatedClass
string $relatedClass The fully-qualified name of the related class.
$relatedClassAttribute
string $relatedClassAttribute The name of the field to relate to on the related class.
$indexName
bool $allowNullValues For foreign key indexes that don't allow null values, set this to false (default is true).

Throws

Alpha\Exception\FailedIndexCreateException
Alpha\Exception\FailedIndexCreateException

See

Alpha\Model\ActiveRecordProviderInterface::createForeignIndex()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::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

Alpha\Exception\FailedIndexCreateException
Alpha\Exception\FailedIndexCreateException

See

Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex()
public
# reload( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::reload()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::reload()
public boolean
# checkRecordExists( integer $OID )

(non-PHPdoc).

(non-PHPdoc).

Parameters

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

Returns

boolean
bool

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::checkRecordExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkRecordExists()
public boolean
# isTableOverloaded( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean
bool

Throws

Alpha\Exception\BadBOTableNameException
Alpha\Exception\BadBOTableNameException

See

Alpha\Model\ActiveRecordProviderInterface::isTableOverloaded()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::isTableOverloaded()
public static
# begin( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::begin()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::begin()
public static
# commit( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\FailedSaveException
Alpha\Exception\FailedSaveException

See

Alpha\Model\ActiveRecordProviderInterface::commit()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::commit()
public static
# rollback( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::rollback()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::rollback()
public
# setBO( Alpha\Model\ActiveRecord $BO )

(non-PHPdoc).

(non-PHPdoc).

Parameters

$BO
Alpha\Model\ActiveRecord $BO

See

Alpha\Model\ActiveRecordProviderInterface::setBO()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::setBO()
public static boolean
# checkDatabaseExists( )

(non-PHPdoc).

(non-PHPdoc).

Returns

boolean
bool

See

Alpha\Model\ActiveRecordProviderInterface::checkDatabaseExists()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::checkDatabaseExists()
public static
# createDatabase( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::createDatabase()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::createDatabase()
public static
# dropDatabase( )

(non-PHPdoc).

(non-PHPdoc).

Throws

Alpha\Exception\AlphaException
Alpha\Exception\AlphaException

See

Alpha\Model\ActiveRecordProviderInterface::dropDatabase()

Implementation of

Alpha\Model\ActiveRecordProviderInterface::dropDatabase()
Alpha Framework 2.0.4 API Documentation API documentation generated by ApiGen 2.8.0