Methods summary
public
DSchoenbauer\Sql\Command\Select
|
#
__construct( string $table, array $fields = [], DSchoenbauer\Sql\Where\WhereStatementInterface $where = null, integer $fetchStyle = DSchoenbauer\Sql\Command\PDO::FETCH_ASSOC, boolean $fetchFlat = false, mixed $defaultValue = [] )
retrieves data from a PDO connected resource
retrieves data from a PDO connected resource
Parameters
- $table
- name of the table that houses the data
- $fields
optional default value: empty array - defines which
fields are returned if no fields defined a star will be used
- $where
optional default value: null -
object used to limit the returned results
- $fetchStyle
optional default value: PDO::FETCH_ASSOC -
sets how the PDO statement will return records
- $fetchFlat
optional default value: false - true will
return one record, false will return all records
- $defaultValue
optional default value: empty array -
value to be returned on query failure
Returns
Since
v1.0.0
|
public
mixed
|
#
execute( PDO $pdo )
Runs a query and returns the result of the SQL
Runs a query and returns the result of the SQL
Parameters
- $pdo
- a PDO connection object
Returns
mixed with return the result set as defined by fetchStyle
Throws
Since
v1.0.0
Implementation of
|
protected
boolean
|
#
statementExecute( PDOStatement $stmt, array $whereData )
Runs the sql statement inserting the query's data
Runs the sql statement inserting the query's data
Parameters
- $stmt
- PDO statement of a prepared SQL statement
- $whereData
- data to be used to fill out a where statement
Returns
boolean true query succeeds, false there was an error executing the query
Since
v1.0.0
|
protected
array
|
#
fetchData( PDOStatement $stmt, boolean $fetchFlat, integer $fetchStyle )
Fetches the data from PDO resource
Fetches the data from PDO resource
Parameters
- $stmt
- PDO statement of a prepared SQL statement
- $fetchFlat
- true returns one record, false returns all records
- $fetchStyle
a \PDO::FETCH_* variable defining the format of
the returned object
Returns
array returns the results of the query
Since
v1.0.0
|
public
string
|
#
getSql( )
returns a PDO SQL string that has parameter syntax
returns a PDO SQL string that has parameter syntax
Returns
string
Since
v1.0.0
Implementation of
|
public
DSchoenbauer\Sql\Command\Select
|
#
setData( array $data )
acts as a cache to house ran queries
acts as a cache to house ran queries
Parameters
Returns
Since
v1.0.0
|
public
mixed
|
#
getData( )
Acts as a cache array that holds the data returned from a query
Acts as a cache array that holds the data returned from a query
Returns
mixed
Since
v1.0.0
Implementation of
|
public
string
|
#
getTable( )
retrieves the table with which you wish to select from
retrieves the table with which you wish to select from
Returns
string table with which you wish to select from
Since
v1.0.0
|
public
DSchoenbauer\Sql\Command\Select
|
#
setTable( string $table )
defines a table with which you wish to append to
defines a table with which you wish to append to
Parameters
- $table
- a table with which you wish to append to
Returns
Since
v1.0.0
|
public
array
|
#
getFields( )
Returns the fields to be returned, if no fields defined all fields are returned
Returns the fields to be returned, if no fields defined all fields are returned
Returns
array
Since
v1.0.0
|
public
DSchoenbauer\Sql\Command\Select
|
#
setFields( array $fields = null )
Defines the fields to be returned, if no fields defined all fields are returned
Defines the fields to be returned, if no fields defined all fields are returned
Parameters
Returns
Since
v1.0.0
|
public
integer
|
#
getFetchStyle( )
defines how data is returned
defines how data is returned
Returns
integer $fetchStyle one of the PDO::FETCH_*
Since
v1.0.0
|
public
DSchoenbauer\Sql\Command\Select
|
#
setFetchStyle( integer $fetchStyle )
used to define how data is returned
used to define how data is returned
Parameters
- $fetchStyle
- one of the PDO::FETCH_*
Returns
Since
v1.0.0
|
public
boolean
|
#
getFetchFlat( )
sets if one or many records will be returned.
sets if one or many records will be returned.
Returns
boolean true for one record, false for all records
Since
v1.0.0
|
public
DSchoenbauer\Sql\Command\Select
|
#
setFetchFlat( boolean $fetchFlat = true )
sets if one or many records will be returned.
sets if one or many records will be returned.
Parameters
- $fetchFlat
optional default value: false - true will
return one record, false will return all records
Returns
Since
v1.0.0
|
public
mixed
|
#
getDefaultValue( )
Value to be returned if no data is found or query fails
Value to be returned if no data is found or query fails
Returns
mixed return the value used when the query returns false
Since
v1.0.0
|
public
DSchoenbauer\Sql\Command\Select
|
#
setDefaultValue( mixed $defaultValue = [] )
Value to be returned if no data is found or query fails
Value to be returned if no data is found or query fails
Parameters
- $defaultValue
optional default value: empty array - value to
be returned on query failure
Returns
Since
v1.0.0
|