Class ParentModel
Class ParentModel connects to the database and provides useful functions (query, queryIndexed,
updateRow, getRow). See each one for more details.
Methods summary
public static
Core\ParentModel
|
#
singleton( )
Returns the class instance, creating it if it did not exist.
Returns the class instance, creating it if it did not exist.
Returns
|
public
PDO
|
#
query( string $query, array $params = array(), boolean $fetchAll = FALSE )
Runs a given $query string and returns the PDO object.
Runs a given $query string and returns the PDO object.
Parameters
- $query
- $params
- = array()
- $fetchAll
- = FALSE perform a fetchAll(PDO::FETCH_ASSOC) or simply return the PDO object
Returns
PDO
|
public
PDO
|
#
queryClass( string $query, array $params, string $className )
Runs a given $query string and returns the instance of the $className.
Runs a given $query string and returns the instance of the $className.
Parameters
- $query
- $params
- $className
Returns
PDO
|
public
PDO
|
#
queryIndexed( string $query, array $params = array(), boolean $unique = TRUE )
Runs a given $query string and returns the PDO object or the fetched results,
indexed by the first column.
Runs a given $query string and returns the PDO object or the fetched results,
indexed by the first column.
Parameters
- $query
- $params
- $unique
- = TRUE. If set to FALSE, each key will contain an array of values.
Returns
PDO
|
public
array
|
#
getRow( string $tableName, string $columnValue, string $columnName = 'id' )
Gets a single result from a given table name and a given column name
Gets a single result from a given table name and a given column name
Parameters
- $tableName
- $columnValue
- $columnName
- = 'id'
Returns
array with the fetched row
|
public
integer
|
#
updateRow( string $tableName, string $columnName, integer $id, mixed $value )
Updates a given row of a given table to a given value
Updates a given row of a given table to a given value
Parameters
- $tableName
- Name of the table to update
- $columnName
- Name of the column to update
- $id
- The ID to index results
- $value
- The value to set
Returns
integer The number of affected rows (1 or 0)
|
Properties summary
protected
PDO
|
$db
|
|
protected
Core\Providers\Config
|
$config
The instance of the Config class.
The instance of the Config class.
|
|
protected
string
|
$id
The project ID. Set from /app/config/config.ini.
The project ID. Set from /app/config/config.ini.
|
|