propel-util
[ class tree: propel-util ] [ index: propel-util ] [ all elements ]

Class: BasePeer

Source Location: /util/BasePeer.php

Class Overview


This is a utility class for all generated Peer classes in the system.


Author(s):

Version:

  • $Revision: 821 $

Constants

Methods



Class Details

[line 40]
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.




Tags:

author:  Kaspars Jaudzems <kaspars.jaudzems@inbox.lv> (Propel)
author:  Hans Lellelid <hans@xmpl.org> (Propel)
author:  Stephen Haberman <stephenh@chase3000.com> (Torque)
author:  Frank Y. Kim <frank.kim@clearink.com> (Torque)
author:  John D. McNally <jmcnally@collab.net> (Torque)
author:  Brett McLaughlin <bmclaugh@algx.net> (Torque)
version:  $Revision: 821 $


[ Top ]


Class Methods


static method createSelectSql [line 594]

static 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.




Tags:

throws:  PropelException Trouble creating the query string.
access:  public


Parameters:

Criteria   $criteria   Criteria for the SELECT query.
array   &$params   Parameters that are to be replaced in prepared statement.

[ Top ]

static method doDelete [line 114]

static int doDelete( Criteria $criteria, $con)

Method to perform deletes based on values and keys in a Criteria.



Tags:

return:  The number of rows affected by last statement execution. For most uses there is only one delete statement executed, so this number will correspond to the number of rows affected by the call to this method. Note that the return value does require that this information is returned (supported) by the PDO driver.
throws:  PropelException
access:  public


Parameters:

Criteria   $criteria   The criteria to use.
PDO   $con   A PDO connection object.

[ Top ]

static method doDeleteAll [line 192]

static int doDeleteAll( string $tableName, $con)

Method to deletes all contents of specified table.

This method is invoked from generated Peer classes like this:

  1.  public static function doDeleteAll($con null)
  2.  {
  3.    if ($con === null$con Propel::getConnection(self::DATABASE_NAME);
  4.    BasePeer::doDeleteAll(self::TABLE_NAME$con);
  5.  }




Tags:

return:  The number of rows affected by the statement. Note that the return value does require that this information is returned (supported) by the Creole db driver.
throws:  PropelException - wrapping SQLException caught from statement execution.
access:  public


Parameters:

string   $tableName   The name of the table to empty.
PDO   $con   A PDO connection object.

[ Top ]

static method doInsert [line 229]

static mixed doInsert( Criteria $criteria, $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.




Tags:

return:  The primary key for the new row if (and only if!) the primary key is auto-generated. Otherwise will return
  1. null
.
throws:  PropelException
access:  public


Parameters:

Criteria   $criteria   Object containing values to insert.
PDO   $con   A PDO connection.

[ Top ]

static method doSelect [line 404]

static ResultSet doSelect( Criteria $criteria, [ $con = null])

Executes query build by createSelectSql() and returns ResultSet.



Tags:

return:  The resultset.
see:  BasePeer::createSelectSql()
throws:  PropelException
access:  public


Parameters:

Criteria   $criteria   A Criteria.
PDO   $con   A PDO connection to use.

[ Top ]

static method doUpdate [line 332]

static int doUpdate( Criteria $selectCriteria, Criteria $updateValues, $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 some_column = some value AND could_have_another_column = another value AND so on.




Tags:

return:  The number of rows affected by last update statement. For most uses there is only one update statement executed, so this number will correspond to the number of rows affected by the call to this method. Note that the return value does require that this information is returned (supported) by the Creole db driver.
throws:  PropelException
access:  public


Parameters:

PDO   $con   The PDO connection object to use.
$selectCriteria   $selectCriteria   A Criteria object containing values used in where clause.
$updateValues   $updateValues   A Criteria object containing values used in set clause.

[ Top ]

static method doValidate [line 519]

static void doValidate( string $dbName, string $tableName, array $columns)

Applies any validators that were defined in the schema to the specified columns.



Tags:

access:  public


Parameters:

string   $dbName   The name of the database
string   $tableName   The name of the table
array   $columns   Array of column names as key and column values as value.

[ Top ]

static method getFieldnames [line 79]

static void getFieldnames( $classname, [ $type = self::TYPE_PHPNAME])



Tags:

access:  public


Parameters:

   $classname  
   $type  

[ Top ]

static method getValidator [line 889]

static Validator getValidator( string $classname)

This function searches for the given validator $name under propel/validator/$name.php, imports and caches it.



Tags:

return:  object or null if not able to instantiate validator class (and error will be logged in this case)
access:  public


Parameters:

string   $classname   The dot-path name of class (e.g. myapp.propel.MyValidator)

[ Top ]

static method translateFieldname [line 90]

static void translateFieldname( $classname, $fieldname, $fromType, $toType)



Tags:

access:  public


Parameters:

   $classname  
   $fieldname  
   $fromType  
   $toType  

[ Top ]


Class Constants

TYPE_COLNAME =  'colName'

[line 65]

column (peer) name type

e.g. 'book.AUTHOR_ID'



[ Top ]

TYPE_FIELDNAME =  'fieldName'

[line 71]

column fieldname type

e.g. 'author_id'



[ Top ]

TYPE_NUM =  'num'

[line 77]

num type

simply the numerical array index, e.g. 4



[ Top ]

TYPE_PHPNAME =  'phpName'

[line 53]

phpname type

e.g. 'AuthorId'



[ Top ]

TYPE_STUDLYPHPNAME =  'studlyPhpName'

[line 59]

studlyphpname type

e.g. 'authorId'



[ Top ]



Documentation generated on Thu, 22 Nov 2007 03:33:24 +0000 by phpDocumentor 1.4.0