class BasePeer
This is a utility class for all generated Peer classes in the system.
Peer classes are responsible for isolating all of the database access for a specific business object. They execute all of the SQL against the database. Over time this class has grown to include utility methods which ease execution of cross-database queries and the implementation of concrete Peers.
Constants
TYPE_PHPNAME |
phpname type e.g. 'AuthorId' |
TYPE_STUDLYPHPNAME |
studlyphpname type e.g. 'authorId' |
TYPE_COLNAME |
column (peer) name type e.g. 'book.AUTHOR_ID' |
TYPE_RAW_COLNAME |
column part of the column peer name e.g. 'AUTHOR_ID' |
TYPE_FIELDNAME |
column fieldname type e.g. 'author_id' |
TYPE_NUM |
num type simply the numerical array index, e.g. 4 |
Methods
static |
getFieldnames($classname, $type = self::TYPE_PHPNAME)
|
|
static |
translateFieldname($classname, $fieldname, $fromType, $toType)
|
|
static int |
doDelete(Criteria $criteria, PropelPDO $con)
Method to perform deletes based on values and keys in a Criteria. |
|
static int |
doDeleteAll(string $tableName, PropelPDO $con, string $databaseName = null)
Method to deletes all contents of specified table. |
|
static mixed |
doInsert(Criteria $criteria, PropelPDO $con)
Method to perform inserts based on values and keys in a Criteria. |
|
static int |
doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con)
Method used to update rows in the DB. |
|
static PDOStatement |
doSelect(Criteria $criteria, PropelPDO $con = null)
Executes query build by createSelectSql() and returns the resultset statement. |
|
static PDOStatement |
doCount(Criteria $criteria, PropelPDO $con = null)
Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a sub-select of the SQL created by createSelectSql() and returns the statement. |
|
static ValidationFailed[]|bool |
doValidate(string $dbName, string $tableName, array $columns)
Applies any validators that were defined in the schema to the specified columns. |
|
static |
needsSelectAliases(Criteria $criteria)
Checks whether the Criteria needs to use column aliasing This is implemented in a service class rather than in Criteria itself in order to avoid doing the tests when it's not necessary (e.g. |
|
static string |
createSelectSql(Criteria $criteria, array $params)
Method to create an SQL query based on values in a Criteria. |
|
static Validator|null |
getValidator(string $classname)
This function searches for the given validator $name under propel/validator/$name.php, imports and caches it. |
Details
at line 75
static public
getFieldnames($classname, $type = self::TYPE_PHPNAME)
at line 85
static public
translateFieldname($classname, $fieldname, $fromType, $toType)
at line 110
static public int
doDelete(Criteria $criteria, PropelPDO $con)
Method to perform deletes based on values and keys in a Criteria.
at line 178
static public int
doDeleteAll(string $tableName, PropelPDO $con, string $databaseName = null)
Method to deletes all contents of specified table.
This method is invoked from generated Peer classes like this:
public static function doDeleteAll($con = null)
{
if ($con === null) $con = Propel::getConnection(self::DATABASENAME);
BasePeer::doDeleteAll(self::TABLENAME, $con, self::DATABASE_NAME);
}
at line 220
static public mixed
doInsert(Criteria $criteria, PropelPDO $con)
Method to perform inserts based on values and keys in a Criteria.
If the primary key is auto incremented the data in Criteria will be inserted and the auto increment value will be returned.
If the primary key is included in Criteria then that value will be used to insert the row.
If no primary key is included in Criteria then we will try to figure out the primary key from the database map and insert the row with the next available id using util.db.IDBroker.
If no primary key is defined for the table the values will be inserted as specified in Criteria and null will be returned.
at line 333
static public int
doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con)
Method used to update rows in the DB.
Rows are selected based on selectCriteria and updated using values in updateValues.
Use this method for performing an update of the kind:
WHERE somecolumn = some value AND couldhaveanothercolumn = another value AND so on.
at line 467
static public PDOStatement
doSelect(Criteria $criteria, PropelPDO $con = null)
Executes query build by createSelectSql() and returns the resultset statement.
at line 509
static public PDOStatement
doCount(Criteria $criteria, PropelPDO $con = null)
Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a sub-select of the SQL created by createSelectSql() and returns the statement.
at line 568
static public ValidationFailed[]|bool
doValidate(string $dbName, string $tableName, array $columns)
Applies any validators that were defined in the schema to the specified columns.
at line 628
static public
needsSelectAliases(Criteria $criteria)
Checks whether the Criteria needs to use column aliasing This is implemented in a service class rather than in Criteria itself in order to avoid doing the tests when it's not necessary (e.g.
for SELECTs)
at line 659
static public string
createSelectSql(Criteria $criteria, array $params)
Method to create an SQL query based on values in a Criteria.
This method creates only prepared statement SQL (using ? where values will go). The second parameter ($params) stores the values that need to be set before the statement is executed. The reason we do it this way is to let the PDO layer handle all escaping & value formatting.
at line 886
static public Validator|null
getValidator(string $classname)
This function searches for the given validator $name under propel/validator/$name.php, imports and caches it.