phpPeanuts  2.2.0
phpPeanuts framework
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Data Fields
PntDao Class Reference

Inherited by PntMysqlDao, PntPdoDao, and PntSqliteDao.

Public Member Functions

 __construct ($connection=null)
 
 getDbmsName ()
 
 supportsSelectRowCount ()
 
 runQuery ($query='', $error="Query error")
 
 _runQuery ($error="Query error")
 
 getFieldNames ()
 
 getRowCount ()
 
 getColumnCount ()
 
 getError ()
 
 getErrNo ()
 
 dataSeek ($index)
 
 getSingleValue ($query='', $error="Query error")
 
 getInsertId ()
 
 prefixColumnNames ($colNames, $prefix)
 
 select_from ($columnNames, $tableName, $distinct=false)
 
 where_equals ($columnName, $value, $placeholder='?')
 
 limit ($rowCount, $offset=0)
 
 joinAllById ($tableMap, $baseTable)
 
 in ($columnName, $values)
 
 convertToSql ($value)
 
 convertConditionArgumentToSql ($value)
 
 quote ($string)
 
 setQueryToInsertObject_table_fieldMap ($anObject, $tableName, $fieldMap)
 
 setQueryToSaveObject_table_fieldMap ($anObject, $tableName, $fieldMap, $insert)
 
 setQueryToDeleteFrom_where_equals ($tableName, $columnName, $value)
 
 addSqlFromSpec ($spec, $groupBy=false)
 
 getAssocRows ($max=null)
 
 getAssocRow ()
 
 release ()
 
 getConnection ()
 
 setConnection ($value)
 
 setDefaultConnection ()
 
 connect ()
 
 beginTransaction ()
 
 commit ()
 
 rollBack ()
 
 param ($value, $placeholder='?')
 
 clearParams ()
 
 replacePlaceholders ()
 
 addFieldPropsTo_table ($obj, $tableName, $includeList=null)
 
 addFieldPropTo_row ($obj, $row)
 
 getPropertyType ($mySqlType)
 

Data Fields

 $connection
 
 $query = ''
 
 $rowCount =0
 
 $columnCount =0
 
 $result
 
 $insertId
 
 $error
 
 $errNo = 0
 
 $parameters
 
 $rowIndex
 
 $dbSource
 

Constructor & Destructor Documentation

__construct (   $connection = null)

Member Function Documentation

_runQuery (   $error = "Query error")
addFieldPropsTo_table (   $obj,
  $tableName,
  $includeList = null 
)

Probably only works with MySQL Adds fieldProperties to the object for the columns from the database. This method assumes column names to be equal to the names of their corresponding field properties.

Parameters
PntDbObject$objthe object to add fieldProperties to
String$tableNamethe name of the table whose columns to use.
array$includeListnames of properties to include If omitted, all columns will be used in the order they appear in the table, but if a fieldProperty is already defined it is left untouched.
Returns
array propertyDescriptors that where added, by property name
addFieldPropTo_row (   $obj,
  $row 
)
addSqlFromSpec (   $spec,
  $groupBy = false 
)

Add both the join clauses, the WHERE clause and eventual ORDER BY clause from the suppleid SQL spec. PntSqlSpec $spec Object that sepecifies the query and may generate the SQL

beginTransaction ( )
clearParams ( )
commit ( )
connect ( )

Database specific code to make a connection with the database. Sets the resulting dbSource on the connection and in $this->dbSource

convertConditionArgumentToSql (   $value)
convertToSql (   $value)
dataSeek (   $index)
getAssocRow ( )

Gets next row as associative array, or false if none

getAssocRows (   $max = null)

Gets rows starting at current pointer position !!Does no longer reset recordpointer

Parameters
number$maxThe maximum number of rows to get. If null all remaining rows are returned. Returns an array of associative row arrays (indexed[rowIndex][rowName])
getColumnCount ( )
getConnection ( )
Returns
DatabaseConnection on which queries will be executed.
getDbmsName ( )
getErrNo ( )
getError ( )

Return the error message or null if no error

getFieldNames ( )
getInsertId ( )

Return the id of the new record after an insert

getPropertyType (   $mySqlType)
getRowCount ( )

Number of affected rows with INSERT, UPDATE or DELETE. If supportsSelectRowCount returns number of selected rows

getSingleValue (   $query = '',
  $error = "Query error" 
)
in (   $columnName,
  $values 
)
joinAllById (   $tableMap,
  $baseTable 
)
limit (   $rowCount,
  $offset = 0 
)

append a SQL string to the query field. Return the added SQL.

Parameters
number$rowCountThe maximum number of rows to retrieve
number$offsetThe index of the first row to retrieve
param (   $value,
  $placeholder = '?' 
)

Add parameter value for later use with statement execute. Instead of a type parameter the actual type of $value will be used for correct binding. I.e. booleans will be bound as booleans, strings as strings etc. However, not all subclasses support type specific binding. (PntPdoDao binds all as string)

Parameters
mixed$valuevalue to add
string$placeholder,.default '?'
Returns
String placehoder
prefixColumnNames (   $colNames,
  $prefix 
)

Return an new array with prefixes added to the supplied columnNames separate prefix and columnname by the separarator appropriate for this database (usually a dot). Retain the keys so that if the columnNames array is a fielMap, the result will map the fields to prefixed columnNames

Parameters
$colNamesArray with columnnames as the values
$prefix,usuallythe table name
Returns
Array with prefixed columnNames
quote (   $string)
release ( )
replacePlaceholders ( )

Parameter binding emulation. Replace the placeolders by converted parameter values

Returns
string sql sets $this->error if wrong parameter count
rollBack ( )
runQuery (   $query = '',
  $error = "Query error" 
)
select_from (   $columnNames,
  $tableName,
  $distinct = false 
)

append a SQL string to the query field. Return the added SQL.

Parameters
columnNamesArray with columnNames. If the names need to be prefixed, they must already be prefixed.
tableNameString May also hold a String with a Join of tablenames
setConnection (   $value)

Sets the DatabaseConnection

Parameters
DatabaseConnection$value
setDefaultConnection ( )
setQueryToDeleteFrom_where_equals (   $tableName,
  $columnName,
  $value 
)

Set the query field to a SQL string that saves the specified object field values in the database.

Parameters
anObjectObject whose field values need to be saved String
columnMapArray
setQueryToInsertObject_table_fieldMap (   $anObject,
  $tableName,
  $fieldMap 
)

Set the query field to a SQL string that inserts the specified object field values in the database.

Parameters
$anObjectObject whose field values need to be saved
$tableNameString
$fieldMapAssociative Array mapping fieldName to columnName
setQueryToSaveObject_table_fieldMap (   $anObject,
  $tableName,
  $fieldMap,
  $insert 
)

Set the query field to a SQL string that saves the specified object field values in the database.

Parameters
anObjectObject whose field values need to be saved String
fieldMapAssociative Array mapping fieldName to columnName
insertwheather a record for the object should be inserted. If false the objects record will be updated
supportsSelectRowCount ( )
Returns
boolean wheather this does support rowcount for SELECT results For some drivers/dsbs this may actually depend on the cursor type used. If this function returns true, dataSeek should be supported too
where_equals (   $columnName,
  $value,
  $placeholder = '?' 
)

append a SQL string to the query field. Return the added SQL. As of version 2.1 this method assumes paramerized queries.

Parameters
stringcolumnName The name of the column. If the name needs to be prefixed, it must already be prefixed.
mixed$value
mixed$placeholderto use (parameterized queries)

Field Documentation

$columnCount =0
$connection
$dbSource

$dbSource cache, see PntDatabasenConnection::getDBSource()

$errNo = 0
$error
$insertId
$parameters
$query = ''
$result
$rowCount =0
$rowIndex

Index of current row (the one that can be fetched) in resultSet


The documentation for this class was generated from the following file: