Skip to content

Instantly share code, notes, and snippets.

@komapa
Created May 24, 2011 21:35
Show Gist options
  • Save komapa/989754 to your computer and use it in GitHub Desktop.
Save komapa/989754 to your computer and use it in GitHub Desktop.
Propel 1.6 phpDoc fixes
Index: propel/connection/DebugPDO.php
===================================================================
--- propel/connection/DebugPDO.php (revision 2294)
+++ propel/connection/DebugPDO.php (working copy)
@@ -13,90 +13,90 @@
*
* This class is ONLY intended for development use. This class is also a work in-progress
* and, as such, it should be expected that this class' API may change.
- *
+ *
* The following runtime configuration items affect the behaviour of this class:
- *
+ *
* - debugpdo.logging.enabled (default: true)
* Should any logging take place
- *
+ *
* - debugpdo.logging.innerglue (default: ": ")
* String to use for combining the title of a detail and its value
- *
+ *
* - debugpdo.logging.outerglue (default: " | ")
* String to use for combining details together on a log line
- *
+ *
* - debugpdo.logging.realmemoryusage (default: false)
- * Parameter to memory_get_usage() and memory_get_peak_usage() calls
- *
+ * Parameter to memory_get_usage() and memory_get_peak_usage() calls
+ *
* - debugpdo.logging.methods (default: DebugPDO::$defaultLogMethods)
* An array of method names ("Class::method") to be included in method call logging
- *
+ *
* - debugpdo.logging.onlyslow (default: false)
* Suppress logging of non-slow queries.
- *
+ *
* - debugpdo.logging.details.slow.enabled (default: false)
* Enables flagging of slow method calls
- *
+ *
* - debugpdo.logging.details.slow.threshold (default: 0.1)
- * Method calls taking more seconds than this threshold are considered slow
- *
+ * Method calls taking more seconds than this threshold are considered slow
+ *
* - debugpdo.logging.details.time.enabled (default: false)
* Enables logging of method execution times
- *
+ *
* - debugpdo.logging.details.time.precision (default: 3)
* Determines the precision of the execution time logging
- *
+ *
* - debugpdo.logging.details.time.pad (default: 10)
* How much horizontal space to reserve for the execution time on a log line
- *
+ *
* - debugpdo.logging.details.mem.enabled (default: false)
* Enables logging of the instantaneous PHP memory consumption
- *
+ *
* - debugpdo.logging.details.mem.precision (default: 1)
* Determines the precision of the memory consumption logging
- *
+ *
* - debugpdo.logging.details.mem.pad (default: 9)
* How much horizontal space to reserve for the memory consumption on a log line
- *
+ *
* - debugpdo.logging.details.memdelta.enabled (default: false)
* Enables logging differences in memory consumption before and after the method call
- *
+ *
* - debugpdo.logging.details.memdelta.precision (default: 1)
* Determines the precision of the memory difference logging
- *
+ *
* - debugpdo.logging.details.memdelta.pad (default: 10)
* How much horizontal space to reserve for the memory difference on a log line
- *
+ *
* - debugpdo.logging.details.mempeak.enabled (default: false)
* Enables logging the peak memory consumption thus far by the currently executing PHP script
- *
+ *
* - debugpdo.logging.details.mempeak.precision (default: 1)
* Determines the precision of the memory peak logging
- *
+ *
* - debugpdo.logging.details.mempeak.pad (default: 9)
* How much horizontal space to reserve for the memory peak on a log line
- *
+ *
* - debugpdo.logging.details.querycount.enabled (default: false)
* Enables logging of the number of queries performed by the DebugPDO instance thus far
- *
+ *
* - debugpdo.logging.details.querycount.pad (default: 2)
* How much horizontal space to reserve for the query count on a log line
- *
+ *
* - debugpdo.logging.details.method.enabled (default: false)
* Enables logging of the name of the method call
- *
+ *
* - debugpdo.logging.details.method.pad (default: 28)
* How much horizontal space to reserve for the method name on a log line
- *
+ *
* The order in which the logging details are enabled is significant, since it determines the order in
* which they will appear in the log file.
- *
+ *
* @example // Enable simple query profiling, flagging calls taking over 1.5 seconds as slow:
* $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
* $config->setParameter('debugpdo.logging.details.slow.enabled', true);
* $config->setParameter('debugpdo.logging.details.slow.threshold', 1.5);
* $config->setParameter('debugpdo.logging.details.time.enabled', true);
- *
+ *
* @author Francois Zaninotto
* @author Cameron Brunner <cameron.brunner@gmail.com>
* @author Hans Lellelid <hans@xmpl.org>
@@ -107,5 +107,8 @@
*/
class DebugPDO extends PropelPDO
{
+ /**
+ * @var boolean
+ */
public $useDebug = true;
}
Index: propel/connection/DebugPDOStatement.php
===================================================================
--- propel/connection/DebugPDOStatement.php (revision 2294)
+++ propel/connection/DebugPDOStatement.php (working copy)
@@ -20,21 +20,19 @@
*/
class DebugPDOStatement extends PDOStatement
{
-
/**
* The PDO connection from which this instance was created.
- *
- * @var PropelPDO
+ *
+ * @var PropelPDO
*/
protected $pdo;
-
+
/**
* Hashmap for resolving the PDO::PARAM_* class constants to their human-readable names.
- *
* This is only used in logging the binding of variables.
- *
- * @see self::bindValue()
- * @var array
+ *
+ * @see self::bindValue()
+ * @var array
*/
protected static $typeMap = array(
PDO::PARAM_BOOL => "PDO::PARAM_BOOL",
@@ -49,17 +47,21 @@
*/
protected $boundValues = array();
- /**
- * Construct a new statement class with reference to main DebugPDO object from
- * which this instance was created.
- *
- * @param DebugPDO $pdo Reference to the parent PDO instance.
- */
+ /**
+ * Construct a new statement class with reference to main DebugPDO object from
+ * which this instance was created.
+ *
+ * @param PropelPDO $pdo Reference to the parent PDO instance.
+ * @return DebugPDOStatement
+ */
protected function __construct(PropelPDO $pdo)
{
$this->pdo = $pdo;
}
+ /**
+ * @return string
+ */
public function getExecutedQueryString()
{
$sql = $this->queryString;
@@ -71,38 +73,39 @@
$sql = str_replace($pos, $this->boundValues[$pos], $sql);
}
}
-
+
return $sql;
}
- /**
- * Executes a prepared statement. Returns a boolean value indicating success.
- *
- * Overridden for query counting and logging.
- *
- * @return bool
- */
+ /**
+ * Executes a prepared statement. Returns a boolean value indicating success.
+ * Overridden for query counting and logging.
+ *
+ * @param string $input_parameters
+ * @return boolean
+ */
public function execute($input_parameters = null)
{
$debug = $this->pdo->getDebugSnapshot();
$return = parent::execute($input_parameters);
-
+
$sql = $this->getExecutedQueryString();
$this->pdo->log($sql, null, __METHOD__, $debug);
$this->pdo->setLastExecutedQuery($sql);
$this->pdo->incrementQueryCount();
-
+
return $return;
}
/**
* Binds a value to a corresponding named or question mark placeholder in the SQL statement
- * that was use to prepare the statement. Returns a boolean value indicating success.
+ * that was use to prepare the statement. Returns a boolean value indicating success.
*
- * @param int $pos Parameter identifier (for determining what to replace in the query).
- * @param mixed $value The value to bind to the parameter.
- * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
- * @return boolean
+ * @param integer $pos Parameter identifier (for determining what to replace in the query).
+ * @param mixed $value The value to bind to the parameter.
+ * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
+ *
+ * @return boolean
*/
public function bindValue($pos, $value, $type = PDO::PARAM_STR)
{
@@ -113,24 +116,26 @@
$msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);
$this->boundValues[$pos] = $valuestr;
-
+
$this->pdo->log($msg, null, __METHOD__, $debug);
-
+
return $return;
}
- /**
- * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement
- * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound
- * as a reference and will only be evaluated at the time that PDOStatement::execute() is called.
- * Returns a boolean value indicating success.
- *
- * @param int $pos Parameter identifier (for determining what to replace in the query).
- * @param mixed $value The value to bind to the parameter.
- * @param int $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
- * @param int $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.
- * @return boolean
- */
+ /**
+ * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement
+ * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound
+ * as a reference and will only be evaluated at the time that PDOStatement::execute() is called.
+ * Returns a boolean value indicating success.
+ *
+ * @param integer $pos Parameter identifier (for determining what to replace in the query).
+ * @param mixed $value The value to bind to the parameter.
+ * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
+ * @param integer $length Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.
+ * @param mixed $driver_options
+ *
+ * @return boolean
+ */
public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null)
{
$debug = $this->pdo->getDebugSnapshot();
@@ -140,7 +145,7 @@
$msg = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);
$this->boundValues[$pos] = $valuestr;
-
+
$this->pdo->log($msg, null, __METHOD__, $debug);
return $return;
Index: propel/connection/PropelPDO.php
===================================================================
--- propel/connection/PropelPDO.php (revision 2294)
+++ propel/connection/PropelPDO.php (working copy)
@@ -34,82 +34,82 @@
* Attribute to use to set whether to cache prepared statements.
*/
const PROPEL_ATTR_CACHE_PREPARES = -1;
-
+
const DEFAULT_SLOW_THRESHOLD = 0.1;
const DEFAULT_ONLYSLOW_ENABLED = false;
/**
* The current transaction depth.
- * @var int
+ * @var integer
*/
protected $nestedTransactionCount = 0;
/**
* Cache of prepared statements (PDOStatement) keyed by md5 of SQL.
*
- * @var array [md5(sql) => PDOStatement]
+ * @var array [md5(sql) => PDOStatement]
*/
protected $preparedStatements = array();
/**
* Whether to cache prepared statements.
*
- * @var boolean
+ * @var boolean
*/
protected $cachePreparedStatements = false;
-
+
/**
* Whether the final commit is possible
* Is false if a nested transaction is rolled back
*/
protected $isUncommitable = false;
-
+
/**
* Count of queries performed.
- *
- * @var int
+ *
+ * @var integer
*/
protected $queryCount = 0;
-
+
/**
* SQL code of the latest performed query.
- *
- * @var string
+ *
+ * @var string
*/
protected $lastExecutedQuery;
-
+
/**
* Whether or not the debug is enabled
- *
- * @var boolean
+ *
+ * @var boolean
*/
public $useDebug = false;
-
+
/**
* Configured BasicLogger (or compatible) logger.
*
- * @var BasicLogger
+ * @var BasicLogger
*/
protected $logger;
/**
* The log level to use for logging.
*
- * @var int
+ * @var integer
*/
private $logLevel = Propel::LOG_DEBUG;
-
+
/**
* The runtime configuration
*
* @var PropelConfiguration
*/
protected $configuration;
-
+
/**
* The default value for runtime config item "debugpdo.logging.methods".
*
- * @var array
+ * @var array
*/
protected static $defaultLogMethods = array(
'PropelPDO::exec',
@@ -124,40 +124,43 @@
* to the log with the state of this object just after its initialization.
* Add PropelPDO::__construct to $defaultLogMethods to see this message
*
- * @param string $dsn Connection DSN.
- * @param string $username (optional) The user name for the DSN string.
- * @param string $password (optional) The password for the DSN string.
- * @param array $driver_options (optional) A key=>value array of driver-specific connection options.
+ * @param string $dsn Connection DSN.
+ * @param string $username The user name for the DSN string.
+ * @param string $password The password for the DSN string.
+ * @param array $driver_options A key=>value array of driver-specific connection options.
+ *
* @throws PDOException if there is an error during connection initialization.
*/
public function __construct($dsn, $username = null, $password = null, $driver_options = array())
{
+ $debug = null;
+
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
-
+
parent::__construct($dsn, $username, $password, $driver_options);
-
+
if ($this->useDebug) {
- $this->configureStatementClass('DebugPDOStatement', $suppress = true);
+ $this->configureStatementClass('DebugPDOStatement', true);
$this->log('Opening connection', null, __METHOD__, $debug);
}
}
-
+
/**
* Inject the runtime configuration
*
- * @param PropelConfiguration $configuration
+ * @param PropelConfiguration $configuration
*/
public function setConfiguration($configuration)
{
$this->configuration = $configuration;
}
-
+
/**
* Get the runtime configuration
*
- * @return PropelConfiguration
+ * @return PropelConfiguration
*/
public function getConfiguration()
{
@@ -166,10 +169,11 @@
}
return $this->configuration;
}
-
+
/**
* Gets the current transaction depth.
- * @return int
+ *
+ * @return integer
*/
public function getNestedTransactionCount()
{
@@ -178,7 +182,7 @@
/**
* Set the current transaction depth.
- * @param int $v The new depth.
+ * @param int $v The new depth.
*/
protected function setNestedTransactionCount($v)
{
@@ -187,29 +191,31 @@
/**
* Is this PDO connection currently in-transaction?
- * This is equivalent to asking whether the current nested transaction count
- * is greater than 0.
- * @return boolean
+ * This is equivalent to asking whether the current nested transaction count is greater than 0.
+ *
+ * @return boolean
*/
public function isInTransaction()
{
return ($this->getNestedTransactionCount() > 0);
}
-
+
/**
* Check whether the connection contains a transaction that can be committed.
* To be used in an evironment where Propelexceptions are caught.
*
- * @return boolean True if the connection is in a committable transaction
+ * @return boolean True if the connection is in a committable transaction
*/
public function isCommitable()
{
return $this->isInTransaction() && !$this->isUncommitable;
}
-
+
/**
* Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction.
- */
+ *
+ * @return boolean
+ */
public function beginTransaction()
{
$return = true;
@@ -221,17 +227,21 @@
$this->isUncommitable = false;
}
$this->nestedTransactionCount++;
+
return $return;
}
/**
* Overrides PDO::commit() to only commit the transaction if we are in the outermost
* transaction nesting level.
- */
+ *
+ * @return boolean
+ */
public function commit()
{
$return = true;
$opcount = $this->nestedTransactionCount;
+
if ($opcount > 0) {
if ($opcount === 1) {
if ($this->isUncommitable) {
@@ -243,20 +253,24 @@
}
}
}
- $this->nestedTransactionCount--;
+
+ $this->nestedTransactionCount--;
}
+
return $return;
}
/**
* Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost
* transaction nesting level
- * @return boolean Whether operation was successful.
+ *
+ * @return boolean Whether operation was successful.
*/
public function rollBack()
{
$return = true;
$opcount = $this->nestedTransactionCount;
+
if ($opcount > 0) {
if ($opcount === 1) {
$return = parent::rollBack();
@@ -266,19 +280,23 @@
} else {
$this->isUncommitable = true;
}
+
$this->nestedTransactionCount--;
}
+
return $return;
}
/**
* Rollback the whole transaction, even if this is a nested rollback
* and reset the nested transaction count to 0.
- * @return boolean Whether operation was successful.
+ *
+ * @return boolean Whether operation was successful.
*/
public function forceRollBack()
{
$return = true;
+
if ($this->nestedTransactionCount) {
// If we're in a transaction, always roll it back
// regardless of nesting level.
@@ -292,17 +310,17 @@
$this->log('Rollback transaction', null, __METHOD__);
}
}
+
return $return;
}
-
+
/**
* Sets a connection attribute.
+ *
+ * This is overridden here to provide support for setting Propel-specific attributes too.
*
- * This is overridden here to provide support for setting Propel-specific attributes
- * too.
- *
- * @param int $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
- * @param mixed $value The attribute value.
+ * @param integer $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
+ * @param mixed $value The attribute value.
*/
public function setAttribute($attribute, $value)
{
@@ -318,11 +336,11 @@
/**
* Gets a connection attribute.
*
- * This is overridden here to provide support for setting Propel-specific attributes
- * too.
+ * This is overridden here to provide support for setting Propel-specific attributes too.
*
- * @param int $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
- */
+ * @param integer $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
+ * @return mixed
+ */
public function getAttribute($attribute)
{
switch($attribute) {
@@ -334,24 +352,27 @@
}
}
- /**
- * Prepares a statement for execution and returns a statement object.
- *
- * Overrides PDO::prepare() in order to:
- * - Add logging and query counting if logging is true.
- * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true.
- *
- * @param string $sql This must be a valid SQL statement for the target database server.
- * @param array One or more key => value pairs to set attribute values
- * for the PDOStatement object that this method returns.
- * @return PDOStatement
- */
+ /**
+ * Prepares a statement for execution and returns a statement object.
+ *
+ * Overrides PDO::prepare() in order to:
+ * - Add logging and query counting if logging is true.
+ * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true.
+ *
+ * @param string $sql This must be a valid SQL statement for the target database server.
+ * @param array $driver_options One $array or more key => value pairs to set attribute values
+ * for the PDOStatement object that this method returns.
+ *
+ * @return PDOStatement
+ */
public function prepare($sql, $driver_options = array())
{
+ $debug = null;
+
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
-
+
if ($this->cachePreparedStatements) {
if (!isset($this->preparedStatements[$sql])) {
$return = parent::prepare($sql, $driver_options);
@@ -362,70 +383,75 @@
} else {
$return = parent::prepare($sql, $driver_options);
}
-
+
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
}
-
+
return $return;
}
- /**
- * Execute an SQL statement and return the number of affected rows.
- *
- * Overrides PDO::exec() to log queries when required
- *
- * @return int
- */
+ /**
+ * Execute an SQL statement and return the number of affected rows.
+ * Overrides PDO::exec() to log queries when required
+ *
+ * @param string $sql
+ * @return integer
+ */
public function exec($sql)
{
+ $debug = null;
+
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
-
+
$return = parent::exec($sql);
-
+
if ($this->useDebug) {
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
-
+
return $return;
}
/**
* Executes an SQL statement, returning a result set as a PDOStatement object.
* Despite its signature here, this method takes a variety of parameters.
- *
+ *
* Overrides PDO::query() to log queries when required
- *
- * @see http://php.net/manual/en/pdo.query.php for a description of the possible parameters.
- * @return PDOStatement
+ *
+ * @see http://php.net/manual/en/pdo.query.php for a description of the possible parameters.
+ *
+ * @return PDOStatement
*/
public function query()
{
+ $debug = null;
+
if ($this->useDebug) {
$debug = $this->getDebugSnapshot();
}
-
+
$args = func_get_args();
if (version_compare(PHP_VERSION, '5.3', '<')) {
$return = call_user_func_array(array($this, 'parent::query'), $args);
} else {
$return = call_user_func_array('parent::query', $args);
}
-
+
if ($this->useDebug) {
$sql = $args[0];
$this->log($sql, null, __METHOD__, $debug);
$this->setLastExecutedQuery($sql);
$this->incrementQueryCount();
}
-
+
return $return;
}
-
+
/**
* Clears any stored prepared statements for this connection.
*/
@@ -434,12 +460,14 @@
$this->preparedStatements = array();
}
- /**
- * Configures the PDOStatement class for this connection.
- *
- * @param boolean $suppressError Whether to suppress an exception if the statement class cannot be set.
- * @throws PropelException if the statement class cannot be set (and $suppressError is false).
- */
+ /**
+ * Configures the PDOStatement class for this connection.
+ *
+ * @param string $class
+ * @param boolean $suppressError Whether to suppress an exception if the statement class cannot be set.
+ *
+ * @throws PropelException if the statement class cannot be set (and $suppressError is false).
+ */
protected function configureStatementClass($class = 'PDOStatement', $suppressError = true)
{
// extending PDOStatement is only supported with non-persistent connections
@@ -452,12 +480,12 @@
/**
* Returns the number of queries this DebugPDO instance has performed on the database connection.
- *
+ *
* When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances
* are counted as well.
- *
- * @return int
- * @throws PropelException if persistent connection is used (since unable to override PDOStatement in that case).
+ *
+ * @throws PropelException if persistent connection is used (since unable to override PDOStatement in that case).
+ * @return integer
*/
public function getQueryCount()
{
@@ -470,10 +498,10 @@
/**
* Increments the number of queries performed by this DebugPDO instance.
- *
+ *
* Returns the original number of queries (ie the value of $this->queryCount before calling this method).
- *
- * @return int
+ *
+ * @return integer
*/
public function incrementQueryCount()
{
@@ -482,33 +510,33 @@
/**
* Get the SQL code for the latest query executed by Propel
- *
+ *
* @return string Executable SQL code
*/
public function getLastExecutedQuery()
{
return $this->lastExecutedQuery;
}
-
+
/**
* Set the SQL code for the latest query executed by Propel
- *
- * @param string $query Executable SQL code
+ *
+ * @param string $query Executable SQL code
*/
public function setLastExecutedQuery($query)
{
$this->lastExecutedQuery = $query;
}
-
+
/**
* Enable or disable the query debug features
*
- * @var boolean $value True to enable debug (default), false to disable it
+ * @var boolean $value True to enable debug (default), false to disable it
*/
public function useDebug($value = true)
{
if ($value) {
- $this->configureStatementClass('DebugPDOStatement', $suppress = true);
+ $this->configureStatementClass('DebugPDOStatement', true);
} else {
// reset query logging
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));
@@ -518,11 +546,11 @@
$this->clearStatementCache();
$this->useDebug = $value;
}
-
+
/**
* Sets the logging level to use for logging method calls and SQL statements.
*
- * @param int $level Value of one of the Propel::LOG_* class constants.
+ * @param integer $level Value of one of the Propel::LOG_* class constants.
*/
public function setLogLevel($level)
{
@@ -531,10 +559,10 @@
/**
* Sets a logger to use.
- *
+ *
* The logger will be used by this class to log various method calls and their properties.
- *
- * @param BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log).
+ *
+ * @param BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log).
*/
public function setLogger($logger)
{
@@ -543,8 +571,8 @@
/**
* Gets the logger in use.
- *
- * @return BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log).
+ *
+ * @return BasicLogger A Logger with an API compatible with BasicLogger (or PEAR Log).
*/
public function getLogger()
{
@@ -553,14 +581,14 @@
/**
* Logs the method call or SQL using the Propel::log() method or a registered logger class.
- *
- * @uses self::getLogPrefix()
- * @see self::setLogger()
- *
- * @param string $msg Message to log.
- * @param int $level (optional) Log level to use; will use self::setLogLevel() specified level by default.
- * @param string $methodName (optional) Name of the method whose execution is being logged.
- * @param array $debugSnapshot (optional) Previous return value from self::getDebugSnapshot().
+ *
+ * @uses self::getLogPrefix()
+ * @see self::setLogger()
+ *
+ * @param string $msg Message to log.
+ * @param integer $level Log level to use; will use self::setLogLevel() specified level by default.
+ * @param string $methodName Name of the method whose execution is being logged.
+ * @param array $debugSnapshot Previous return value from self::getDebugSnapshot().
*/
public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null)
{
@@ -568,12 +596,12 @@
if (!$this->getLoggingConfig('enabled', true)) {
return;
}
-
+
// If the method being logged isn't one of the ones to be logged, bail
if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) {
return;
}
-
+
// If a logging level wasn't provided, use the default one
if ($level === null) {
$level = $this->logLevel;
@@ -584,17 +612,17 @@
$now = $this->getDebugSnapshot();
if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) return;
}
-
+
// If the necessary additional parameters were given, get the debug log prefix for the log line
if ($methodName && $debugSnapshot) {
$msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg;
}
-
+
// We won't log empty messages
if (!$msg) {
return;
}
-
+
// Delegate the actual logging forward
if ($this->logger) {
$this->logger->log($msg, $level);
@@ -602,11 +630,11 @@
Propel::log($msg, $level);
}
}
-
+
/**
* Returns a snapshot of the current values of some functions useful in debugging.
*
- * @return array
+ * @return array
*/
public function getDebugSnapshot()
{
@@ -620,33 +648,35 @@
throw new PropelException('Should not get debug snapshot when not debugging');
}
}
-
+
/**
* Returns a named configuration item from the Propel runtime configuration, from under the
* 'debugpdo.logging' prefix. If such a configuration setting hasn't been set, the given default
- * value will be returned.
+ * value will be returned.
*
- * @param string $key Key for which to return the value.
- * @param mixed $defaultValue Default value to apply if config item hasn't been set.
- * @return mixed
+ * @param string $key Key for which to return the value.
+ * @param mixed $defaultValue Default value to apply if config item hasn't been set.
+ *
+ * @return mixed
*/
protected function getLoggingConfig($key, $defaultValue)
{
return $this->getConfiguration()->getParameter("debugpdo.logging.$key", $defaultValue);
}
-
+
/**
* Returns a prefix that may be prepended to a log line, containing debug information according
* to the current configuration.
- *
+ *
* Uses a given $debugSnapshot to calculate how much time has passed since the call to self::getDebugSnapshot(),
* how much the memory consumption by PHP has changed etc.
*
- * @see self::getDebugSnapshot()
- *
- * @param string $methodName Name of the method whose execution is being logged.
- * @param array $debugSnapshot A previous return value from self::getDebugSnapshot().
- * @return string
+ * @see self::getDebugSnapshot()
+ *
+ * @param string $methodName Name of the method whose execution is being logged.
+ * @param array $debugSnapshot A previous return value from self::getDebugSnapshot().
+ *
+ * @return string
*/
protected function getLogPrefix($methodName, $debugSnapshot)
{
@@ -659,85 +689,86 @@
$now = $this->getDebugSnapshot();
$innerGlue = $this->getLoggingConfig('innerglue', ': ');
$outerGlue = $this->getLoggingConfig('outerglue', ' | ');
-
+
// Iterate through each detail that has been configured to be enabled
foreach ($logDetails as $detailName => $details) {
-
+
if (!$this->getLoggingConfig("details.$detailName.enabled", false)) {
continue;
}
-
+
switch ($detailName) {
-
+
case 'slow';
$value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig('details.slow.threshold', self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO';
break;
-
+
case 'time':
$value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig('details.time.precision', 3)) . ' sec';
$value = str_pad($value, $this->getLoggingConfig('details.time.pad', 10), ' ', STR_PAD_LEFT);
break;
-
+
case 'mem':
$value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig('details.mem.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mem.pad', 9), ' ', STR_PAD_LEFT);
break;
-
+
case 'memdelta':
$value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage'];
$value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig('details.memdelta.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.memdelta.pad', 10), ' ', STR_PAD_LEFT);
break;
-
+
case 'mempeak':
$value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig('details.mempeak.precision', 1));
$value = str_pad($value, $this->getLoggingConfig('details.mempeak.pad', 9), ' ', STR_PAD_LEFT);
break;
-
+
case 'querycount':
$value = str_pad($this->getQueryCount(), $this->getLoggingConfig('details.querycount.pad', 2), ' ', STR_PAD_LEFT);
break;
-
+
case 'method':
$value = str_pad($methodName, $this->getLoggingConfig('details.method.pad', 28), ' ', STR_PAD_RIGHT);
break;
-
+
default:
$value = 'n/a';
break;
-
+
}
-
+
$prefix .= $detailName . $innerGlue . $value . $outerGlue;
-
+
}
-
+
return $prefix;
}
-
+
/**
* Returns a human-readable representation of the given byte count.
*
- * @param int $bytes Byte count to convert.
- * @param int $precision How many decimals to include.
- * @return string
+ * @param integer $bytes Byte count to convert.
+ * @param integer $precision How many decimals to include.
+ *
+ * @return string
*/
protected function getReadableBytes($bytes, $precision)
{
$suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$total = count($suffix);
-
+
for ($i = 0; $bytes > 1024 && $i < $total; $i++)
$bytes /= 1024;
-
+
return number_format($bytes, $precision) . ' ' . $suffix[$i];
}
-
+
/**
* If so configured, makes an entry to the log of the state of this object just prior to its destruction.
* Add PropelPDO::__destruct to $defaultLogMethods to see this message
*
- * @see self::log()
+ * @see self::log()
*/
public function __destruct()
{
Index: propel/logger/BasicLogger.php
===================================================================
--- propel/logger/BasicLogger.php (revision 2294)
+++ propel/logger/BasicLogger.php (working copy)
@@ -27,65 +27,56 @@
/**
* A convenience function for logging an alert event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function alert($message);
/**
* A convenience function for logging a critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function crit($message);
/**
* A convenience function for logging an error event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function err($message);
/**
* A convenience function for logging a warning event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function warning($message);
/**
* A convenience function for logging an critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function notice($message);
/**
* A convenience function for logging an critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function info($message);
/**
* A convenience function for logging a debug event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function debug($message);
/**
* Primary method to handle logging.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
- * @param int $severity The numeric severity. Defaults to null so that no
+ * @param mixed $message String or Exception object containing the message to log.
+ * @param int $severity The numeric severity. Defaults to null so that no
* assumptions are made about the logging backend.
*/
public function log($message, $severity = null);
-
}
Index: propel/logger/MojaviLogAdapter.php
===================================================================
--- propel/logger/MojaviLogAdapter.php (revision 2294)
+++ propel/logger/MojaviLogAdapter.php (working copy)
@@ -17,7 +17,6 @@
*/
class MojaviLogAdapter implements BasicLogger
{
-
/**
* Instance of mojavi logger
*/
@@ -26,7 +25,7 @@
/**
* constructor for setting up Mojavi log adapter
*
- * @param ErrorLog $logger instance of Mojavi error log obtained by
+ * @param ErrorLog $logger Instance of Mojavi error log obtained by
* calling LogManager::getLogger();
*/
public function __construct($logger = null)
@@ -37,8 +36,7 @@
/**
* A convenience function for logging an alert event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function alert($message)
{
@@ -48,8 +46,7 @@
/**
* A convenience function for logging a critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function crit($message)
{
@@ -59,8 +56,7 @@
/**
* A convenience function for logging an error event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function err($message)
{
@@ -70,8 +66,7 @@
/**
* A convenience function for logging a warning event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function warning($message)
{
@@ -82,8 +77,7 @@
/**
* A convenience function for logging an critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function notice($message)
{
@@ -92,8 +86,7 @@
/**
* A convenience function for logging an critical event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function info($message)
{
@@ -103,8 +96,7 @@
/**
* A convenience function for logging a debug event.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
+ * @param mixed $message String or Exception object containing the message to log.
*/
public function debug($message)
{
@@ -114,10 +106,9 @@
/**
* Primary method to handle logging.
*
- * @param mixed $message String or Exception object containing the message
- * to log.
- * @param int $severity The numeric severity. Defaults to null so that no
- * assumptions are made about the logging backend.
+ * @param mixed $message String or Exception object containing the message to log.
+ * @param integer $severity The numeric severity. Defaults to null so that no
+ * assumptions are made about the logging backend.
*/
public function log($message, $severity = null)
{
Index: propel/adapter/MSSQL/MssqlPropelPDO.php
===================================================================
--- propel/adapter/MSSQL/MssqlPropelPDO.php (revision 2294)
+++ propel/adapter/MSSQL/MssqlPropelPDO.php (working copy)
@@ -20,7 +20,9 @@
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
- */
+ *
+ * @return integer
+ */
public function beginTransaction()
{
$return = true;
@@ -35,13 +37,15 @@
$this->nestedTransactionCount++;
return $return;
}
-
+
/**
* Commit a transaction.
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
- */
+ *
+ * @return integer
+ */
public function commit()
{
$return = true;
@@ -68,6 +72,8 @@
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
+ *
+ * @return integer
*/
public function rollBack()
{
@@ -93,6 +99,8 @@
*
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
+ *
+ * @return integer
*/
public function forceRollBack()
{
@@ -114,17 +122,28 @@
return $return;
}
+ /**
+ * @param string $seqname
+ * @return integer
+ */
public function lastInsertId($seqname = null)
{
$result = self::query('SELECT SCOPE_IDENTITY()');
return (int) $result->fetchColumn();
}
-
+
+ /**
+ * @param string $text
+ * @return string
+ */
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
-
+
+ /**
+ * @return boolean
+ */
public function useQuoteIdentifier()
{
return true;
Index: propel/adapter/DBMySQL.php
===================================================================
--- propel/adapter/DBMySQL.php (revision 2294)
+++ propel/adapter/DBMySQL.php (working copy)
@@ -18,14 +18,13 @@
* @version $Revision$
* @package propel.runtime.adapter
*/
-class DBMySQL extends DBAdapter
+class DBMySQL extends DBAdapter
{
-
/**
* This method is used to ignore case.
*
- * @param in The string to transform to upper case.
- * @return The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -35,8 +34,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string whose case to ignore.
- * @return The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -46,23 +45,25 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
return "CONCAT($s1, $s2)";
}
- /**
- * Returns SQL which extracts a substring.
- *
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
- */
+ /**
+ * Returns SQL which extracts a substring.
+ *
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
+ */
public function subString($s, $pos, $len)
{
return "SUBSTRING($s, $pos, $len)";
@@ -71,8 +72,8 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
@@ -83,10 +84,10 @@
/**
* Locks the specified table.
*
- * @param Connection $con The Propel connection to use.
- * @param string $table The name of the table to lock.
- * @throws PDOException No Statement could be created or
- * executed.
+ * @param PDO $con The Propel connection to use.
+ * @param string $table The name of the table to lock.
+ *
+ * @throws PDOException No Statement could be created or executed.
*/
public function lockTable(PDO $con, $table)
{
@@ -96,27 +97,33 @@
/**
* Unlocks the specified table.
*
- * @param PDO $con The PDO connection to use.
- * @param string $table The name of the table to unlock.
- * @throws PDOException No Statement could be created or
- * executed.
+ * @param PDO $con The PDO connection to use.
+ * @param string $table The name of the table to unlock.
+ *
+ * @throws PDOException No Statement could be created or executed.
*/
public function unlockTable(PDO $con, $table)
{
$statement = $con->exec("UNLOCK TABLES");
}
- /**
- * @see DBAdapter::quoteIdentifier()
- */
+ /**
+ * @see DBAdapter::quoteIdentifier()
+ *
+ * @param string $text
+ * @return string
+ */
public function quoteIdentifier($text)
{
return '`' . $text . '`';
}
- /**
- * @see DBAdapter::quoteIdentifierTable()
- */
+ /**
+ * @see DBAdapter::quoteIdentifierTable()
+ *
+ * @param string $table
+ * @return string
+ */
public function quoteIdentifierTable($table)
{
// e.g. 'database.table alias' should be escaped as '`database`.`table` `alias`'
@@ -124,16 +131,22 @@
}
/**
- * @see DBAdapter::useQuoteIdentifier()
- */
+ * @see DBAdapter::useQuoteIdentifier()
+ *
+ * @return boolean
+ */
public function useQuoteIdentifier()
{
return true;
}
- /**
- * @see DBAdapter::applyLimit()
- */
+ /**
+ * @see DBAdapter::applyLimit()
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ */
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
@@ -143,17 +156,28 @@
}
}
- /**
- * @see DBAdapter::random()
- */
+ /**
+ * @see DBAdapter::random()
+ *
+ * @param string $seed
+ * @return string
+ */
public function random($seed = null)
{
return 'rand('.((int) $seed).')';
}
-
- /**
- * @see DBAdapter::bindValue()
- */
+
+ /**
+ * @see DBAdapter::bindValue()
+ *
+ * @param PDOStatement $stmt
+ * @param string $parameter
+ * @param mixed $value
+ * @param ColumnMap $cMap
+ * @param null|integer $position
+ *
+ * @return boolean
+ */
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
$pdoType = $cMap->getPdoType();
@@ -173,5 +197,4 @@
return $stmt->bindValue($parameter, $value, $pdoType);
}
-
}
Index: propel/adapter/DBOracle.php
===================================================================
--- propel/adapter/DBOracle.php (revision 2294)
+++ propel/adapter/DBOracle.php (working copy)
@@ -22,14 +22,16 @@
*/
class DBOracle extends DBAdapter
{
- /**
- * This method is called after a connection was created to run necessary
- * post-initialization queries or code.
- * Removes the charset query and adds the date queries
- *
- * @param PDO A PDO connection instance.
- * @see parent::initConnection()
- */
+ /**
+ * This method is called after a connection was created to run necessary
+ * post-initialization queries or code.
+ * Removes the charset query and adds the date queries
+ *
+ * @see parent::initConnection()
+ *
+ * @param PDO $con
+ * @param array $settings A $PDO PDO connection instance
+ */
public function initConnection(PDO $con, array $settings)
{
$con->exec("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
@@ -42,12 +44,12 @@
}
}
}
-
+
/**
* This method is used to ignore case.
*
- * @param string $in The string to transform to upper case.
- * @return string The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -57,8 +59,8 @@
/**
* This method is used to ignore case.
*
- * @param string $in The string whose case to ignore.
- * @return string The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -68,9 +70,10 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
@@ -80,10 +83,11 @@
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public function subString($s, $pos, $len)
{
@@ -93,17 +97,22 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
return "LENGTH($s)";
}
- /**
- * @see DBAdapter::applyLimit()
- */
+ /**
+ * @see DBAdapter::applyLimit()
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ * @param null|Criteria $criteria
+ */
public function applyLimit(&$sql, $offset, $limit, $criteria = null)
{
if (BasePeer::needsSelectAliases($criteria)) {
@@ -125,11 +134,21 @@
}
}
+ /**
+ * @return int
+ */
protected function getIdMethod()
{
return DBAdapter::ID_METHOD_SEQUENCE;
}
+ /**
+ * @param PDO $con
+ * @param string $name
+ *
+ * @throws PropelException
+ * @return integer
+ */
public function getId(PDO $con, $name = null)
{
if ($name === null) {
@@ -142,6 +161,10 @@
return $row[0];
}
+ /**
+ * @param string $seed
+ * @return string
+ */
public function random($seed=NULL)
{
return 'dbms_random.value';
@@ -150,11 +173,11 @@
/**
* Ensures uniqueness of select column names by turning them all into aliases
* This is necessary for queries on more than one table when the tables share a column name
+ *
* @see http://propel.phpdb.org/trac/ticket/795
*
- * @param Criteria $criteria
- *
- * @return Criteria The input, with Select columns replaced by aliases
+ * @param Criteria $criteria
+ * @return Criteria The input, with Select columns replaced by aliases
*/
public function turnSelectColumnsToAliases(Criteria $criteria)
{
@@ -185,5 +208,4 @@
return $criteria;
}
-
}
Index: propel/adapter/DBPostgres.php
===================================================================
--- propel/adapter/DBPostgres.php (revision 2294)
+++ propel/adapter/DBPostgres.php (working copy)
@@ -24,8 +24,8 @@
/**
* This method is used to ignore case.
*
- * @param string $in The string to transform to upper case.
- * @return string The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -35,8 +35,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string whose case to ignore.
- * @return The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -46,9 +46,10 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
@@ -58,10 +59,11 @@
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public function subString($s, $pos, $len)
{
@@ -71,8 +73,8 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
@@ -81,15 +83,22 @@
/**
* @see DBAdapter::getIdMethod()
- */
+ *
+ * @return integer
+ */
protected function getIdMethod()
{
return DBAdapter::ID_METHOD_SEQUENCE;
}
- /**
- * Gets ID for specified sequence name.
- */
+ /**
+ * Gets ID for specified sequence name.
+ *
+ * @param PDO $con
+ * @param string $name
+ *
+ * @return integer
+ */
public function getId(PDO $con, $name = null)
{
if ($name === null) {
@@ -97,12 +106,13 @@
}
$stmt = $con->query("SELECT nextval(".$con->quote($name).")");
$row = $stmt->fetch(PDO::FETCH_NUM);
+
return $row[0];
}
/**
* Returns timestamp formatter string for use in date() function.
- * @return string
+ * @return string
*/
public function getTimestampFormatter()
{
@@ -111,16 +121,21 @@
/**
* Returns timestamp formatter string for use in date() function.
- * @return string
+ *
+ * @return string
*/
public function getTimeFormatter()
{
return "H:i:s O";
}
- /**
- * @see DBAdapter::applyLimit()
- */
+ /**
+ * @see DBAdapter::applyLimit()
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ */
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
@@ -130,18 +145,26 @@
$sql .= " OFFSET ".$offset;
}
}
-
- /**
- * @see DBAdapter::random()
- */
+
+ /**
+ * @see DBAdapter::random()
+ *
+ * @param string $seed
+ * @return string
+ */
public function random($seed=NULL)
{
return 'random()';
}
-
- /**
- * @see DBAdapter::getDeleteFromClause()
- */
+
+ /**
+ * @see DBAdapter::getDeleteFromClause()
+
+ * @param Criteria $criteria
+ * @param string $tableName
+ *
+ * @return string
+ */
public function getDeleteFromClause($criteria, $tableName)
{
$sql = 'DELETE ';
@@ -159,12 +182,16 @@
}
$sql .= 'FROM ' . $tableName;
}
+
return $sql;
}
- /**
- * @see DBAdapter::quoteIdentifierTable()
- */
+ /**
+ * @see DBAdapter::quoteIdentifierTable()
+ *
+ * @param string $table
+ * @return string
+ */
public function quoteIdentifierTable($table)
{
// e.g. 'database.table alias' should be escaped as '"database"."table" "alias"'
Index: propel/adapter/DBSQLSRV.php
===================================================================
--- propel/adapter/DBSQLSRV.php (revision 2294)
+++ propel/adapter/DBSQLSRV.php (working copy)
@@ -17,19 +17,27 @@
*/
class DBSQLSRV extends DBMSSQL
{
- /**
- * @see parent::initConnection()
- */
+ /**
+ * @see parent::initConnection()
+ *
+ * @param PDO $con
+ * @param array $settings
+ */
public function initConnection(PDO $con, array $settings)
{
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
+
parent::initConnection($con, $settings);
}
- /**
- * @see parent::setCharset()
- */
+ /**
+ * @see parent::setCharset()
+ * @throws PropelException
+ *
+ * @param PDO $con
+ * @param string $charset
+ */
public function setCharset(PDO $con, $charset)
{
switch (strtolower($charset)) {
@@ -44,9 +52,14 @@
}
}
- /**
- * @see parent::cleanupSQL()
- */
+ /**
+ * @see parent::cleanupSQL()
+ *
+ * @param string $sql
+ * @param array $params
+ * @param Criteria $values
+ * @param DatabaseMap $dbMap
+ */
public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap)
{
$i = 1;
@@ -66,10 +79,18 @@
$i++;
}
}
-
- /**
- * @see DBAdapter::bindValue()
- */
+
+ /**
+ * @see DBAdapter::bindValue()
+ *
+ * @param PDOStatement $stmt
+ * @param string $parameter
+ * @param mixed $value
+ * @param ColumnMap $cMap
+ * @param null|integer $position
+ *
+ * @return boolean
+ */
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
if ($cMap->isTemporal()) {
@@ -84,6 +105,7 @@
// would change on the next loop
$blob = "blob".$position;
$$blob = $value;
+
return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
}
Index: propel/adapter/DBMSSQL.php
===================================================================
--- propel/adapter/DBMSSQL.php (revision 2294)
+++ propel/adapter/DBMSSQL.php (working copy)
@@ -17,10 +17,14 @@
*/
class DBMSSQL extends DBAdapter
{
- /**
- * MS SQL Server does not support SET NAMES
- * @see DBAdapter::setCharset()
- */
+ /**
+ * MS SQL Server does not support SET NAMES
+ *
+ * @see DBAdapter::setCharset()
+ *
+ * @param PDO $con
+ * @param string $charset
+ */
public function setCharset(PDO $con, $charset)
{
}
@@ -28,8 +32,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string to transform to upper case.
- * @return The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -39,8 +43,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string whose case to ignore.
- * @return The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -50,9 +54,10 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
@@ -62,10 +67,11 @@
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public function subString($s, $pos, $len)
{
@@ -75,46 +81,63 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
return 'LEN(' . $s . ')';
}
- /**
- * @see DBAdapter::quoteIdentifier()
- */
+ /**
+ * @see DBAdapter::quoteIdentifier()
+ *
+ * @param string $text
+ * @return string
+ */
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
- /**
- * @see DBAdapter::quoteIdentifierTable()
- */
+ /**
+ * @see DBAdapter::quoteIdentifierTable()
+ *
+ * @param string $table
+ * @return string
+ */
public function quoteIdentifierTable($table)
{
// e.g. 'database.table alias' should be escaped as '[database].[table] [alias]'
return '[' . strtr($table, array('.' => '].[', ' ' => '] [')) . ']';
}
- /**
- * @see DBAdapter::random()
- */
+ /**
+ * @see DBAdapter::random()
+ *
+ * @param string $seed
+ * @return string
+ */
public function random($seed = null)
{
return 'RAND(' . ((int)$seed) . ')';
}
- /**
- * Simulated Limit/Offset
- * This rewrites the $sql query to apply the offset and limit.
- * some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform
- * @see DBAdapter::applyLimit()
- * @author Benjamin Runnels <kraven@kraven.org>
- */
+ /**
+ * Simulated Limit/Offset
+ *
+ * This rewrites the $sql query to apply the offset and limit.
+ * some of the ORDER BY logic borrowed from Doctrine MsSqlPlatform
+ *
+ * @see DBAdapter::applyLimit()
+ * @author Benjamin Runnels <kraven@kraven.org>
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ *
+ * @return void
+ */
public function applyLimit(&$sql, $offset, $limit)
{
// make sure offset and limit are numeric
@@ -231,12 +254,16 @@
//ROW_NUMBER() starts at 1 not 0
$sql = $outerSelect . ' (' . $innerSelect . ' ' . $fromStatement . ') AS derivedb WHERE RowNumber BETWEEN ' . ($offset + 1) . ' AND ' . ($limit + $offset);
- return;
}
- /**
- * @see parent::cleanupSQL()
- */
+ /**
+ * @see parent::cleanupSQL()
+ *
+ * @param string $sql
+ * @param array $params
+ * @param Criteria $values
+ * @param DatabaseMap $dbMap
+ */
public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap)
{
$i = 1;
Index: propel/adapter/DBNone.php
===================================================================
--- propel/adapter/DBNone.php (revision 2294)
+++ propel/adapter/DBNone.php (working copy)
@@ -20,9 +20,12 @@
class DBNone extends DBAdapter
{
- /**
- * @see DBAdapter::initConnection()
- */
+ /**
+ * @see DBAdapter::initConnection()
+ *
+ * @param PDO $con
+ * @param array $settings
+ */
public function initConnection(PDO $con, array $settings)
{
}
@@ -30,8 +33,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string to transform to upper case.
- * @return The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -41,8 +44,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string whose case to ignore.
- * @return The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -52,9 +55,10 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
@@ -64,10 +68,11 @@
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public function subString($s, $pos, $len)
{
@@ -77,17 +82,21 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
return strlen($s);
}
-
- /**
- * Modifies the passed-in SQL to add LIMIT and/or OFFSET.
- */
+
+ /**
+ * Modifies the passed-in SQL to add LIMIT and/or OFFSET.
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ */
public function applyLimit(&$sql, $offset, $limit)
{
}
@@ -95,10 +104,9 @@
/**
* Gets the SQL string that this adapter uses for getting a random number.
*
- * @param mixed $seed (optional) seed value for databases that support this
+ * @param string $seed (optional) seed value for databases that support this
*/
public function random($seed = null)
{
}
-
}
Index: propel/adapter/DBAdapter.php
===================================================================
--- propel/adapter/DBAdapter.php (revision 2294)
+++ propel/adapter/DBAdapter.php (working copy)
@@ -32,14 +32,13 @@
*/
abstract class DBAdapter
{
-
const ID_METHOD_NONE = 0;
const ID_METHOD_AUTOINCREMENT = 1;
const ID_METHOD_SEQUENCE = 2;
/**
* Propel driver to Propel adapter map.
- * @var array
+ * @var array
*/
private static $adapters = array(
'mysql' => 'DBMySQL',
@@ -57,10 +56,11 @@
* Creates a new instance of the database adapter associated
* with the specified Propel driver.
*
- * @param string $driver The name of the Propel driver to
- * create a new adapter instance for or a shorter form adapter key.
- * @return DBAdapter An instance of a Propel database adapter.
- * @throws PropelException if the adapter could not be instantiated.
+ * @param string $driver The name of the Propel driver to create a new adapter instance
+ * for or a shorter form adapter key.
+ *
+ * @throws PropelException If the adapter could not be instantiated.
+ * @return DBAdapter An instance of a Propel database adapter.
*/
public static function factory($driver) {
$adapterClass = isset(self::$adapters[$driver]) ? self::$adapters[$driver] : null;
@@ -81,9 +81,10 @@
*
* This base method runs queries specified using the "query" setting.
*
- * @param PDO A PDO connection instance.
- * @param array An array of settings.
- * @see setCharset()
+ * @see setCharset()
+ *
+ * @param PDO $con A PDO connection instance.
+ * @param array $settings An array of settings.
*/
public function initConnection(PDO $con, array $settings)
{
@@ -99,16 +100,17 @@
}
}
- /**
- * Sets the character encoding using SQL standard SET NAMES statement.
- *
- * This method is invoked from the default initConnection() method and must
- * be overridden for an RDMBS which does _not_ support this SQL standard.
- *
- * @param PDO A PDO connection instance.
- * @param string The charset encoding.
- * @see initConnection()
- */
+ /**
+ * Sets the character encoding using SQL standard SET NAMES statement.
+ *
+ * This method is invoked from the default initConnection() method and must
+ * be overridden for an RDMBS which does _not_ support this SQL standard.
+ *
+ * @see initConnection()
+ *
+ * @param PDO $con A $PDO PDO connection instance.
+ * @param string $charset The $string charset encoding.
+ */
public function setCharset(PDO $con, $charset)
{
$con->exec("SET NAMES '" . $charset . "'");
@@ -117,8 +119,8 @@
/**
* This method is used to ignore case.
*
- * @param string The string to transform to upper case.
- * @return string The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public abstract function toUpperCase($in);
@@ -127,7 +129,7 @@
* a piece of text used in a SQL statement (generally a single
* quote).
*
- * @return string The text delimeter.
+ * @return string The text delimeter.
*/
public function getStringDelimiter()
{
@@ -137,8 +139,8 @@
/**
* This method is used to ignore case.
*
- * @param string $in The string whose case to ignore.
- * @return string The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public abstract function ignoreCase($in);
@@ -148,8 +150,8 @@
* (Interbase for example) does not use the same SQL in ORDER BY
* and other clauses.
*
- * @param string $in The string whose case to ignore.
- * @return string The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCaseInOrderBy($in)
{
@@ -159,35 +161,37 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public abstract function concatString($s1, $s2);
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public abstract function subString($s, $pos, $len);
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public abstract function strLength($s);
/**
* Quotes database objec identifiers (table names, col names, sequences, etc.).
- * @param string $text The identifier to quote.
- * @return string The quoted identifier.
+ * @param string $text The identifier to quote.
+ * @return string The quoted identifier.
*/
public function quoteIdentifier($text)
{
@@ -199,8 +203,8 @@
* This doesn't take care of dots which separate schema names from table names. Adapters for RDBMs which support
* schemas have to implement that in the platform-specific way.
*
- * @param string $table The table name to quo
- * @return string The quoted table name
+ * @param string $table The table name to quo
+ * @return string The quoted table name
**/
public function quoteIdentifierTable($table) {
return implode(" ", array_map(array($this, "quoteIdentifier"), explode(" ", $table) ) );
@@ -208,7 +212,8 @@
/**
* Returns the native ID method for this RDBMS.
- * @return int one of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT.
+ *
+ * @return integer One of DBAdapter:ID_METHOD_SEQUENCE, DBAdapter::ID_METHOD_AUTOINCREMENT.
*/
protected function getIdMethod()
{
@@ -217,7 +222,8 @@
/**
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
- * @return boolean
+ *
+ * @return boolean
*/
public function isGetIdBeforeInsert()
{
@@ -226,17 +232,22 @@
/**
* Whether this adapter uses an ID generation system that requires getting ID _before_ performing INSERT.
- * @return boolean
+ *
+ * @return boolean
*/
public function isGetIdAfterInsert()
{
return ($this->getIdMethod() === DBAdapter::ID_METHOD_AUTOINCREMENT);
}
- /**
- * Gets the generated ID (either last ID for autoincrement or next sequence ID).
- * @return mixed
- */
+ /**
+ * Gets the generated ID (either last ID for autoincrement or next sequence ID).
+
+ * @param PDO $con
+ * @param string $name
+ *
+ * @return mixed
+ */
public function getId(PDO $con, $name = null)
{
return $con->lastInsertId($name);
@@ -244,15 +255,18 @@
/**
* Formats a temporal value brefore binding, given a ColumnMap object
- * @param mixed $value The temporal value
- * @param ColumnMap $cMap
+ *
+ * @param mixed $value The temporal value
+ * @param ColumnMap $cMap
*
- * @return string The formatted temporal value
+ * @return string The formatted temporal value
*/
protected function formatTemporalValue($value, ColumnMap $cMap)
{
- if($dt = PropelDateTime::newInstance($value)) {
- switch($cMap->getType()) {
+ /** @var $dt PropelDateTime */
+ if ($dt = PropelDateTime::newInstance($value)) {
+ switch($cMap->getType())
+ {
case PropelColumnTypes::TIMESTAMP:
case PropelColumnTypes::BU_TIMESTAMP:
$value = $dt->format($this->getTimestampFormatter());
@@ -264,14 +278,15 @@
case PropelColumnTypes::TIME:
$value = $dt->format($this->getTimeFormatter());
break;
- }
+ }
}
return $value;
}
-
+
/**
* Returns timestamp formatter string for use in date() function.
- * @return string
+ *
+ * @return string
*/
public function getTimestampFormatter()
{
@@ -280,7 +295,8 @@
/**
* Returns date formatter string for use in date() function.
- * @return string
+ *
+ * @return string
*/
public function getDateFormatter()
{
@@ -289,7 +305,8 @@
/**
* Returns time formatter string for use in date() function.
- * @return string
+ *
+ * @return string
*/
public function getTimeFormatter()
{
@@ -303,8 +320,9 @@
* it`s a workaround...!!!
*
* @todo should be abstract
- * @return boolean
- * @deprecated
+ * @deprecated
+ *
+ * @return boolean
*/
public function useQuoteIdentifier()
{
@@ -314,32 +332,39 @@
/**
* Allows manipulation of the query string before PDOStatement is instantiated.
*
- * @param string $sql The sql statement
- * @param array $params array('column' => ..., 'table' => ..., 'value' => ...)
- * @param Criteria $values
- * @param DatabaseMap $dbMap
+ * @param string $sql The sql statement
+ * @param array $params array('column' => ..., 'table' => ..., 'value' => ...)
+ * @param Criteria $values
+ * @param DatabaseMap $dbMap
*/
public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap $dbMap)
{
}
- /**
- * Modifies the passed-in SQL to add LIMIT and/or OFFSET.
- */
+ /**
+ * Modifies the passed-in SQL to add LIMIT and/or OFFSET.
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ */
public abstract function applyLimit(&$sql, $offset, $limit);
/**
* Gets the SQL string that this adapter uses for getting a random number.
*
- * @param mixed $seed (optional) seed value for databases that support this
+ * @param mixed $seed (optional) seed value for databases that support this
*/
public abstract function random($seed = null);
- /**
- * Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.
- * @return string
- * @author Niklas Närhinen <niklas@narhinen.net>
- */
+ /**
+ * Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.
+ *
+ * @param Criteria $criteria
+ * @param string $tableName
+ *
+ * @return string
+ */
public function getDeleteFromClause($criteria, $tableName)
{
$sql = 'DELETE ';
@@ -360,11 +385,17 @@
return $sql;
}
- /**
- * Builds the SELECT part of a SQL statement based on a Criteria
- * taking into account select columns and 'as' columns (i.e. columns aliases)
- * Move from BasePeer to DBAdapter and turn from static to non static
- */
+ /**
+ * Builds the SELECT part of a SQL statement based on a Criteria
+ * taking into account select columns and 'as' columns (i.e. columns aliases)
+ * Move from BasePeer to DBAdapter and turn from static to non static
+ *
+ * @param Criteria $criteria
+ * @param array $fromClause
+ * @param boolean $aliasAll
+ *
+ * @return string
+ */
public function createSelectSqlPart(Criteria $criteria, &$fromClause, $aliasAll = false)
{
$selectClause = array();
@@ -430,12 +461,12 @@
/**
* Ensures uniqueness of select column names by turning them all into aliases
* This is necessary for queries on more than one table when the tables share a column name
- * @see http://propel.phpdb.org/trac/ticket/795
- * Move from BasePeer to DBAdapter and turn from static to non static
+ * Moved from BasePeer to DBAdapter and turned from static to non static
+ *
+ * @see http://propel.phpdb.org/trac/ticket/795
*
- * @param Criteria $criteria
- *
- * @return Criteria The input, with Select columns replaced by aliases
+ * @param Criteria $criteria
+ * @return Criteria The input, with Select columns replaced by aliases
*/
public function turnSelectColumnsToAliases(Criteria $criteria)
{
@@ -483,9 +514,9 @@
* $stmt->execute();
* </code>
*
- * @param PDOStatement $stmt
- * @param array $params array('column' => ..., 'table' => ..., 'value' => ...)
- * @param DatabaseMap $dbMap
+ * @param PDOStatement $stmt
+ * @param array $params array('column' => ..., 'table' => ..., 'value' => ...)
+ * @param DatabaseMap $dbMap
*/
public function bindValues(PDOStatement $stmt, array $params, DatabaseMap $dbMap)
{
@@ -507,18 +538,18 @@
$this->bindValue($stmt, $parameter, $value, $cMap, $position);
}
}
-
+
/**
* Binds a value to a positioned parameted in a statement,
* given a ColumnMap object to infer the binding type.
*
- * @param PDOStatement $stmt The statement to bind
- * @param string $parameter Parameter identifier
- * @param mixed $value The value to bind
- * @param ColumnMap $cMap The ColumnMap of the column to bind
- * @param integer $position The position of the parameter to bind
+ * @param PDOStatement $stmt The statement to bind
+ * @param string $parameter Parameter identifier
+ * @param mixed $value The value to bind
+ * @param ColumnMap $cMap The ColumnMap of the column to bind
+ * @param null|integer $position The position of the parameter to bind
*
- * @return Boolean TRUE on success or FALSE on failure.
+ * @return boolean
*/
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
@@ -532,5 +563,4 @@
return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
}
-
}
Index: propel/adapter/DBSQLite.php
===================================================================
--- propel/adapter/DBSQLite.php (revision 2294)
+++ propel/adapter/DBSQLite.php (working copy)
@@ -22,9 +22,10 @@
* For SQLite this method has no effect, since SQLite doesn't support specifying a character
* set (or, another way to look at it, it doesn't require a single character set per DB).
*
- * @param PDO A PDO connection instance.
- * @param string The charset encoding.
- * @throws PropelException If the specified charset doesn't match sqlite_libencoding()
+ * @param PDO $con A PDO connection instance.
+ * @param string $charset The charset encoding.
+ *
+ * @throws PropelException If the specified charset doesn't match sqlite_libencoding()
*/
public function setCharset(PDO $con, $charset)
{
@@ -33,8 +34,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string to transform to upper case.
- * @return The upper case string.
+ * @param string $in The string to transform to upper case.
+ * @return string The upper case string.
*/
public function toUpperCase($in)
{
@@ -44,8 +45,8 @@
/**
* This method is used to ignore case.
*
- * @param in The string whose case to ignore.
- * @return The string in a case that can be ignored.
+ * @param string $in The string whose case to ignore.
+ * @return string The string in a case that can be ignored.
*/
public function ignoreCase($in)
{
@@ -55,9 +56,10 @@
/**
* Returns SQL which concatenates the second string to the first.
*
- * @param string String to concatenate.
- * @param string String to append.
- * @return string
+ * @param string $s1 String to concatenate.
+ * @param string $s2 String to append.
+ *
+ * @return string
*/
public function concatString($s1, $s2)
{
@@ -67,10 +69,11 @@
/**
* Returns SQL which extracts a substring.
*
- * @param string String to extract from.
- * @param int Offset to start from.
- * @param int Number of characters to extract.
- * @return string
+ * @param string $s String to extract from.
+ * @param integer $pos Offset to start from.
+ * @param integer $len Number of characters to extract.
+ *
+ * @return string
*/
public function subString($s, $pos, $len)
{
@@ -80,25 +83,32 @@
/**
* Returns SQL which calculates the length (in chars) of a string.
*
- * @param string String to calculate length of.
- * @return string
+ * @param string $s String to calculate length of.
+ * @return string
*/
public function strLength($s)
{
return "length($s)";
}
- /**
- * @see DBAdapter::quoteIdentifier()
- */
+ /**
+ * @see DBAdapter::quoteIdentifier()
+ *
+ * @param string $text
+ * @return string
+ */
public function quoteIdentifier($text)
{
return '[' . $text . ']';
}
- /**
- * @see DBAdapter::applyLimit()
- */
+ /**
+ * @see DBAdapter::applyLimit()
+ *
+ * @param string $sql
+ * @param integer $offset
+ * @param integer $limit
+ */
public function applyLimit(&$sql, $offset, $limit)
{
if ( $limit > 0 ) {
@@ -108,9 +118,12 @@
}
}
- public function random($seed=NULL)
+ /**
+ * @param string $seed
+ * @return string
+ */
+ public function random($seed = NULL)
{
return 'random()';
}
-
}
Index: propel/formatter/PropelStatementFormatter.php
===================================================================
--- propel/formatter/PropelStatementFormatter.php (revision 2294)
+++ propel/formatter/PropelStatementFormatter.php (working copy)
@@ -18,11 +18,19 @@
*/
class PropelStatementFormatter extends PropelFormatter
{
+ /**
+ * @param PDOStatement $stmt
+ * @return PDOStatement
+ */
public function format(PDOStatement $stmt)
{
return $stmt;
}
-
+
+ /**
+ * @param PDOStatement $stmt
+ * @return null|PDOStatement
+ */
public function formatOne(PDOStatement $stmt)
{
if ($stmt->rowCount() == 0) {
@@ -31,15 +39,22 @@
return $stmt;
}
}
-
+
+ /**
+ * @param mixed $record
+ * @throws PropelException
+ */
public function formatRecord($record = null)
{
throw new PropelException('The Statement formatter cannot transform a record into a statement');
}
+ /**
+ * @return boolean
+ */
public function isObjectFormatter()
{
return false;
}
-}
\ No newline at end of file
+}
Index: propel/formatter/PropelOnDemandFormatter.php
===================================================================
--- propel/formatter/PropelOnDemandFormatter.php (revision 2294)
+++ propel/formatter/PropelOnDemandFormatter.php (working copy)
@@ -21,36 +21,50 @@
{
protected $collectionName = 'PropelOnDemandCollection';
protected $isSingleTableInheritance = false;
-
+
+ /**
+ * @param ModelCriteria $criteria
+ * @return PropelOnDemandFormatter
+ */
public function init(ModelCriteria $criteria)
{
parent::init($criteria);
$this->isSingleTableInheritance = $criteria->getTableMap()->isSingleTableInheritance();
-
+
return $this;
}
-
+
+ /**
+ * @param PDOStatement $stmt
+ *
+ * @throws PropelException
+ * @return PropelOnDemandCollection
+ */
public function format(PDOStatement $stmt)
{
$this->checkInit();
if ($this->isWithOneToMany()) {
throw new PropelException('PropelOnDemandFormatter cannot hydrate related objects using a one-to-many relationship. Try removing with() from your query.');
}
+
$class = $this->collectionName;
+
+ /** @var $collection PropelOnDemandCollection */
$collection = new $class();
$collection->setModel($this->class);
$collection->initIterator($this, $stmt);
-
+
return $collection;
}
-
+
/**
* Hydrates a series of objects from a result row
* The first object to hydrate is the model of the Criteria
- * The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one
+ * The following objects (the ones added by way of ModelCriteria::with())
+ * are linked to the first one
*
- * @param array $row associative array indexed by column number,
- * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
+ * @param array $row Associative array indexed by column number,
+ * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
*
* @return BaseObject
*/
@@ -60,7 +74,14 @@
// main object
$class = $this->isSingleTableInheritance ? call_user_func(array($this->peer, 'getOMClass'), $row, $col, false) : $this->class;
$obj = $this->getSingleObjectFromRow($row, $class, $col);
- // related objects using 'with'
+
+ $hydrationChain = array();
+
+ /**
+ * Related objects using 'with'
+ *
+ * @var $modelWith ModelWith
+ */
foreach ($this->getWith() as $modelWith) {
if ($modelWith->isSingleTableInheritance()) {
$class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col, false);
@@ -68,7 +89,7 @@
if ($refl->isAbstract()) {
$col += constant($class . 'Peer::NUM_COLUMNS');
continue;
- }
+ }
} else {
$class = $modelWith->getModelName();
}
@@ -82,18 +103,17 @@
}
continue;
}
- if (isset($hydrationChain)) {
- $hydrationChain[$modelWith->getRightPhpName()] = $endObject;
- } else {
- $hydrationChain = array($modelWith->getRightPhpName() => $endObject);
- }
+
+ $hydrationChain[$modelWith->getRightPhpName()] = $endObject;
+
call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject);
}
foreach ($this->getAsColumns() as $alias => $clause) {
$obj->setVirtualColumn($alias, $row[$col]);
$col++;
}
+
return $obj;
}
-
-}
\ No newline at end of file
+
+}
Index: propel/formatter/ModelWith.php
===================================================================
--- propel/formatter/ModelWith.php (revision 2294)
+++ propel/formatter/ModelWith.php (working copy)
@@ -27,19 +27,22 @@
protected $initMethod = '';
protected $leftPhpName;
protected $rightPhpName;
-
+
+ /**
+ * @param ModelJoin|null $join
+ */
public function __construct(ModelJoin $join = null)
{
if (null !== $join) {
$this->init($join);
}
}
-
+
/**
* Define the joined hydration schema based on a join object.
* Fills the ModelWith properties using a ModelJoin as source
*
- * @param ModelJoin $join
+ * @param ModelJoin $join
*/
public function init(ModelJoin $join)
{
@@ -63,118 +66,184 @@
$this->leftPhpName = $join->hasLeftTableAlias() ? $join->getLeftTableAlias() : $join->getPreviousJoin()->getRelationMap()->getName();
}
}
-
+
// DataObject getters & setters
-
+
+ /**
+ * @param string $modelName
+ */
public function setModelName($modelName)
{
$this->modelName = $modelName;
}
-
+
+ /**
+ * @return string
+ */
public function getModelName()
{
return $this->modelName;
}
-
+
+ /**
+ * @param string $modelPeerName
+ */
public function setModelPeerName($modelPeerName)
{
$this->modelPeerName = $modelPeerName;
}
-
+
+ /**
+ * @return string
+ */
public function getModelPeerName()
{
return $this->modelPeerName;
}
-
+
+ /**
+ * @param boolean $isSingleTableInheritance
+ */
public function setIsSingleTableInheritance($isSingleTableInheritance)
{
$this->isSingleTableInheritance = $isSingleTableInheritance;
}
-
+
+ /**
+ * @return boolean
+ */
public function isSingleTableInheritance()
{
return $this->isSingleTableInheritance;
}
-
+
+ /**
+ * @param boolean $isAdd
+ */
public function setIsAdd($isAdd)
{
$this->isAdd = $isAdd;
}
-
+
+ /**
+ * @return boolean
+ */
public function isAdd()
{
return $this->isAdd;
}
+ /**
+ * @param boolean $isWithOneToMany
+ */
public function setIsWithOneToMany($isWithOneToMany)
{
$this->isWithOneToMany = $isWithOneToMany;
}
-
+
+ /**
+ * @return boolean
+ */
public function isWithOneToMany()
{
return $this->isWithOneToMany;
}
-
+
+ /**
+ * @param string $relationName
+ */
public function setRelationName($relationName)
{
$this->relationName = $relationName;
}
-
+
+ /**
+ * @return string
+ */
public function getRelationName()
{
return $this->relationName;
}
-
+
+ /**
+ * @param string $relationMethod
+ */
public function setRelationMethod($relationMethod)
{
$this->relationMethod = $relationMethod;
}
+ /**
+ * @return string
+ */
public function getRelationMethod()
{
return $this->relationMethod;
}
+ /**
+ * @param string $initMethod
+ */
public function setInitMethod($initMethod)
{
$this->initMethod = $initMethod;
}
+ /**
+ * @return string
+ */
public function getInitMethod()
{
return $this->initMethod;
}
-
+
+ /**
+ * @param string $leftPhpName
+ */
public function setLeftPhpName($leftPhpName)
{
$this->leftPhpName = $leftPhpName;
}
-
+
+ /**
+ * @return string
+ */
public function getLeftPhpName()
{
return $this->leftPhpName;
}
+ /**
+ * @param string $rightPhpName
+ */
public function setRightPhpName($rightPhpName)
{
$this->rightPhpName = $rightPhpName;
}
-
+
+ /**
+ * @return string
+ */
public function getRightPhpName()
{
return $this->rightPhpName;
}
-
+
// Utility methods
-
+
+ /**
+ * @return boolean
+ */
public function isPrimary()
{
return null === $this->leftPhpName;
}
-
+
+ /**
+ * @return string
+ */
public function __toString()
{
return sprintf("modelName: %s, relationName: %s, relationMethod: %s, leftPhpName: %s, rightPhpName: %s", $this->modelName, $this->relationName, $this->relationMethod, $this->leftPhpName, $this->rightPhpName);
}
-}
\ No newline at end of file
+}
Index: propel/formatter/PropelObjectFormatter.php
===================================================================
--- propel/formatter/PropelObjectFormatter.php (revision 2294)
+++ propel/formatter/PropelObjectFormatter.php (working copy)
@@ -19,11 +19,18 @@
class PropelObjectFormatter extends PropelFormatter
{
protected $collectionName = 'PropelObjectCollection';
-
+
+ /**
+ * @param PDOStatement $stmt
+ *
+ * @throws PropelException
+ * @return array|PropelObjectCollection
+ */
public function format(PDOStatement $stmt)
{
$this->checkInit();
- if($class = $this->collectionName) {
+ if ($class = $this->collectionName) {
+ /** @var $collection PropelObjectCollection */
$collection = new $class();
$collection->setModel($this->class);
$collection->setFormatter($this);
@@ -50,10 +57,14 @@
}
}
$stmt->closeCursor();
-
+
return $collection;
}
-
+
+ /**
+ * @param PDOStatement $stmt
+ * @return BaseObject|null
+ */
public function formatOne(PDOStatement $stmt)
{
$this->checkInit();
@@ -62,10 +73,13 @@
$result = $this->getAllObjectsFromRow($row);
}
$stmt->closeCursor();
-
+
return $result;
}
-
+
+ /**
+ * @return boolean
+ */
public function isObjectFormatter()
{
return true;
@@ -73,11 +87,12 @@
/**
* Hydrates a series of objects from a result row
+ *
* The first object to hydrate is the model of the Criteria
* The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one
*
- * @param array $row associative array indexed by column number,
- * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
+ * @param array $row Associative array indexed by column number,
+ * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
*
* @return BaseObject
*/
@@ -85,8 +100,14 @@
{
// main object
list($obj, $col) = call_user_func(array($this->peer, 'populateObject'), $row);
-
- // related objects added using with()
+
+ $hydrationChain = array();
+
+ /**
+ * Related objects added using with()
+ *
+ * @var $modelWith ModelWith
+ */
foreach ($this->getWith() as $modelWith) {
list($endObject, $col) = call_user_func(array($modelWith->getModelPeerName(), 'populateObject'), $row, $col);
$startObject = $modelWith->isPrimary() ? $obj : $hydrationChain[$modelWith->getLeftPhpName()];
@@ -98,15 +119,12 @@
}
continue;
}
- if (isset($hydrationChain)) {
- $hydrationChain[$modelWith->getRightPhpName()] = $endObject;
- } else {
- $hydrationChain = array($modelWith->getRightPhpName() => $endObject);
- }
-
+
+ $hydrationChain = array($modelWith->getRightPhpName() => $endObject);
+
call_user_func(array($startObject, $modelWith->getRelationMethod()), $endObject);
}
-
+
// columns added using withColumn()
foreach ($this->getAsColumns() as $alias => $clause) {
$obj->setVirtualColumn($alias, $row[$col]);
@@ -114,5 +132,4 @@
}
return $obj;
}
-
-}
\ No newline at end of file
+}
Index: propel/formatter/PropelSimpleArrayFormatter.php
===================================================================
--- propel/formatter/PropelSimpleArrayFormatter.php (revision 2294)
+++ propel/formatter/PropelSimpleArrayFormatter.php (working copy)
@@ -17,47 +17,72 @@
* @version $Revision$
* @package propel.runtime.formatter
*/
-class PropelSimpleArrayFormatter extends PropelFormatter {
+class PropelSimpleArrayFormatter extends PropelFormatter
+{
protected $collectionName = 'PropelArrayCollection';
- public function format(PDOStatement $stmt) {
+ /**
+ * @param PDOStatement $stmt
+ *
+ * @throws PropelException
+ * @return PropelArrayCollection
+ */
+ public function format(PDOStatement $stmt)
+ {
$this->checkInit ();
if ($class = $this->collectionName) {
+ /** @var $collection PropelArrayCollection */
$collection = new $class();
- $collection->setModel ($this->class );
- $collection->setFormatter ($this);
+ $collection->setModel($this->class );
+ $collection->setFormatter($this);
} else {
$collection = array();
}
- if ($this->isWithOneToMany () && $this->hasLimit) {
+ if ($this->isWithOneToMany() && $this->hasLimit) {
throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.');
}
while ($row = $stmt->fetch (PDO::FETCH_NUM)) {
- if ($rowArray = $this->getStructuredArrayFromRow ($row)) {
+ if ($rowArray = $this->getStructuredArrayFromRow($row)) {
$collection[] = $rowArray;
}
}
- $stmt->closeCursor ();
+ $stmt->closeCursor();
+
return $collection;
}
- public function formatOne(PDOStatement $stmt) {
- $this->checkInit ();
+ /**
+ * @param PDOStatement $stmt
+ * @return array|null
+ */
+ public function formatOne(PDOStatement $stmt)
+ {
+ $this->checkInit();
$result = null;
- while ($row = $stmt->fetch (PDO::FETCH_NUM)) {
- if ($rowArray = $this->getStructuredArrayFromRow ($row)) {
+ while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
+ if ($rowArray = $this->getStructuredArrayFromRow($row)) {
$result = $rowArray;
}
}
- $stmt->closeCursor ();
+ $stmt->closeCursor();
+
return $result;
}
- public function isObjectFormatter() {
+ /**
+ * @return bool
+ */
+ public function isObjectFormatter()
+ {
return false;
}
- public function getStructuredArrayFromRow($row) {
+ /**
+ * @param array $row
+ * @return array
+ */
+ public function getStructuredArrayFromRow($row)
+ {
$columnNames = array_keys($this->getAsColumns ());
if (count($columnNames) > 1 && count($row) > 1) {
$finalRow = array();
Index: propel/formatter/PropelArrayFormatter.php
===================================================================
--- propel/formatter/PropelArrayFormatter.php (revision 2294)
+++ propel/formatter/PropelArrayFormatter.php (working copy)
@@ -21,11 +21,18 @@
protected $collectionName = 'PropelArrayCollection';
protected $alreadyHydratedObjects = array();
protected $emptyVariable;
-
+
+ /**
+ * @throws PropelException
+ * @param PDOStatement $stmt
+ *
+ * @return array
+ */
public function format(PDOStatement $stmt)
{
$this->checkInit();
- if($class = $this->collectionName) {
+ if ($class = $this->collectionName) {
+ /** @var $collection PropelArrayCollection */
$collection = new $class();
$collection->setModel($this->class);
$collection->setFormatter($this);
@@ -43,10 +50,14 @@
$this->currentObjects = array();
$this->alreadyHydratedObjects = array();
$stmt->closeCursor();
-
+
return $collection;
}
+ /**
+ * @param PDOStatement $stmt
+ * @return BaseObject
+ */
public function formatOne(PDOStatement $stmt)
{
$this->checkInit();
@@ -59,41 +70,43 @@
$this->currentObjects = array();
$this->alreadyHydratedObjects = array();
$stmt->closeCursor();
+
return $result;
}
/**
* Formats an ActiveRecord object
*
- * @param BaseObject $record the object to format
- *
- * @return array The original record turned into an array
+ * @param BaseObject $record The object to format
+ * @return array The original record turned into an array
*/
public function formatRecord($record = null)
{
return $record ? $record->toArray() : array();
}
-
+
+ /**
+ * @return boolean
+ */
public function isObjectFormatter()
{
return false;
}
-
/**
* Hydrates a series of objects from a result row
* The first object to hydrate is the model of the Criteria
* The following objects (the ones added by way of ModelCriteria::with()) are linked to the first one
*
- * @param array $row associative array indexed by column number,
- * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
+ * @param array $row Associative array indexed by column number,
+ * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
*
- * @return Array
+ * @return array
*/
public function &getStructuredArrayFromRow($row)
{
$col = 0;
-
+
// hydrate main object or take it from registry
$mainObjectIsNew = false;
$mainKey = call_user_func(array($this->peer, 'getPrimaryKeyHashFromRow'), $row);
@@ -104,12 +117,16 @@
$this->alreadyHydratedObjects[$this->class][$mainKey] = $obj->toArray();
$mainObjectIsNew = true;
}
-
+
$hydrationChain = array();
-
- // related objects added using with()
+
+ /**
+ * Related objects added using with()
+ *
+ * @var $modelWith ModelWith
+ */
foreach ($this->getWith() as $relAlias => $modelWith) {
-
+
// determine class to use
if ($modelWith->isSingleTableInheritance()) {
$class = call_user_func(array($modelWith->getModelPeerName(), 'getOMClass'), $row, $col, false);
@@ -117,31 +134,31 @@
if ($refl->isAbstract()) {
$col += constant($class . 'Peer::NUM_COLUMNS');
continue;
- }
+ }
} else {
$class = $modelWith->getModelName();
}
-
+
// hydrate related object or take it from registry
$key = call_user_func(array($modelWith->getModelPeerName(), 'getPrimaryKeyHashFromRow'), $row, $col);
// we hydrate the main object even in case of a one-to-many relationship
// in order to get the $col variable increased anyway
$secondaryObject = $this->getSingleObjectFromRow($row, $class, $col);
if (!isset($this->alreadyHydratedObjects[$relAlias][$key])) {
-
+
if ($secondaryObject->isPrimaryKeyNull()) {
$this->alreadyHydratedObjects[$relAlias][$key] = array();
} else {
$this->alreadyHydratedObjects[$relAlias][$key] = $secondaryObject->toArray();
}
}
-
+
if ($modelWith->isPrimary()) {
$arrayToAugment = &$this->alreadyHydratedObjects[$this->class][$mainKey];
} else {
$arrayToAugment = &$hydrationChain[$modelWith->getLeftPhpName()];
}
-
+
if ($modelWith->isAdd()) {
if (!isset($arrayToAugment[$modelWith->getRelationName()]) || !in_array($this->alreadyHydratedObjects[$relAlias][$key], $arrayToAugment[$modelWith->getRelationName()])) {
$arrayToAugment[$modelWith->getRelationName()][] = &$this->alreadyHydratedObjects[$relAlias][$key];
@@ -149,16 +166,16 @@
} else {
$arrayToAugment[$modelWith->getRelationName()] = &$this->alreadyHydratedObjects[$relAlias][$key];
}
-
+
$hydrationChain[$modelWith->getRightPhpName()] = &$this->alreadyHydratedObjects[$relAlias][$key];
}
-
+
// columns added using withColumn()
foreach ($this->getAsColumns() as $alias => $clause) {
$this->alreadyHydratedObjects[$this->class][$mainKey][$alias] = $row[$col];
$col++;
}
-
+
if ($mainObjectIsNew) {
return $this->alreadyHydratedObjects[$this->class][$mainKey];
} else {
@@ -166,5 +183,4 @@
return $emptyVariable;
}
}
-
-}
\ No newline at end of file
+}
Index: propel/formatter/PropelFormatter.php
===================================================================
--- propel/formatter/PropelFormatter.php (revision 2294)
+++ propel/formatter/PropelFormatter.php (working copy)
@@ -1,4 +1,4 @@
-<?php
+<?php
/**
* This file is part of the Propel package.
@@ -21,25 +21,32 @@
$dbName,
$class,
$peer,
- $with = array(),
- $asColumns = array(),
- $hasLimit = false,
- $currentObjects = array();
-
+ $asColumns = array(),
+ $hasLimit = false;
+
+ /**
+ * @var BaseObject[]
+ */
+ protected $currentObjects = array();
+
+ /**
+ * @var ModelWith[]
+ */
+ protected $with = array();
+
public function __construct(ModelCriteria $criteria = null)
{
if (null !== $criteria) {
$this->init($criteria);
}
}
-
+
/**
* Define the hydration schema based on a query object.
* Fills the Formatter's properties using a Criteria as source
*
- * @param ModelCriteria $criteria
- *
- * @return PropelFormatter The current formatter object
+ * @param ModelCriteria $criteria
+ * @return PropelFormatter The current formatter object
*/
public function init(ModelCriteria $criteria)
{
@@ -48,105 +55,156 @@
$this->setWith($criteria->getWith());
$this->asColumns = $criteria->getAsColumns();
$this->hasLimit = $criteria->getLimit() != 0;
-
+
return $this;
}
-
+
// DataObject getters & setters
+ /**
+ * @param string $dbName
+ */
public function setDbName($dbName)
{
$this->dbName = $dbName;
}
-
+
+ /**
+ * @return string
+ */
public function getDbName()
{
return $this->dbName;
}
-
+
+ /**
+ * @param string $class
+ */
public function setClass($class)
{
$this->class = $class;
$this->peer = constant($this->class . '::PEER');
}
-
+
+ /**
+ * @return string
+ */
public function getClass()
{
return $this->class;
}
-
+
+ /**
+ * @param string $peer
+ */
public function setPeer($peer)
{
$this->peer = $peer;
}
-
+
+ /**
+ * @return string
+ */
public function getPeer()
{
return $this->peer;
}
-
+
+ /**
+ * @param array $withs
+ */
public function setWith($withs = array())
{
$this->with = $withs;
}
-
+
+ /**
+ * @return array
+ */
public function getWith()
{
return $this->with;
}
+ /**
+ * @param array $asColumns
+ */
public function setAsColumns($asColumns = array())
{
$this->asColumns = $asColumns;
}
-
+
+ /**
+ * @return array
+ */
public function getAsColumns()
{
return $this->asColumns;
}
+ /**
+ * @param boolean $hasLimit
+ */
public function setHasLimit($hasLimit = false)
{
$this->hasLimit = $hasLimit;
}
-
+
+ /**
+ * @return boolean
+ */
public function hasLimit()
{
return $this->hasLimit;
}
-
+
/**
* Formats an ActiveRecord object
*
- * @param BaseObject $record the object to format
- *
- * @return BaseObject The original record
+ * @param BaseObject $record The object to format
+ * @return BaseObject The original record
*/
public function formatRecord($record = null)
{
return $record;
}
-
+
+ /**
+ * @param PDOStatement $stmt
+ */
abstract public function format(PDOStatement $stmt);
+ /**
+ * @param PDOStatement $stmt
+ */
abstract public function formatOne(PDOStatement $stmt);
-
+
abstract public function isObjectFormatter();
-
+
+ /**
+ * @throws PropelException
+ */
public function checkInit()
{
if (null === $this->peer) {
throw new PropelException('You must initialize a formatter object before calling format() or formatOne()');
}
}
-
+
+ /**
+ * @return TableMap
+ */
public function getTableMap()
{
return Propel::getDatabaseMap($this->dbName)->getTableByPhpName($this->class);
}
-
+
+ /**
+ * @return boolean
+ */
protected function isWithOneToMany()
{
+ /** @var $modelWith ModelWith */
foreach ($this->with as $modelWith) {
if ($modelWith->isWithOneToMany()) {
return true;
@@ -154,17 +212,17 @@
}
return false;
}
-
+
/**
* Gets the worker object for the class.
* To save memory, we don't create a new object for each row,
* But we keep hydrating a single object per class.
* The column offset in the row is used to index the array of classes
* As there may be more than one object of the same class in the chain
- *
- * @param int $col Offset of the object in the list of objects to hydrate
- * @param string $class Propel model object class
- *
+ *
+ * @param integer $col Offset of the object in the list of objects to hydrate
+ * @param string $class Propel model object class
+ *
* @return BaseObject
*/
protected function getWorkerObject($col, $class)
@@ -174,16 +232,17 @@
} else {
$this->currentObjects[$col] = new $class();
}
+
return $this->currentObjects[$col];
}
-
+
/**
* Gets a Propel object hydrated from a selection of columns in statement row
*
- * @param array $row associative array indexed by column number,
- * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
- * @param string $class The classname of the object to create
- * @param int $col The start column for the hydration (modified)
+ * @param array $row Associative array indexed by column number,
+ * as returned by PDOStatement::fetch(PDO::FETCH_NUM)
+ * @param string $class The classname of the object to create
+ * @param integer $col The start column for the hydration (modified)
*
* @return BaseObject
*/
@@ -191,9 +250,7 @@
{
$obj = $this->getWorkerObject($col, $class);
$col = $obj->hydrate($row, $col);
-
+
return $obj;
}
-
-
}
Index: propel/config/PropelConfiguration.php
===================================================================
--- propel/config/PropelConfiguration.php (revision 2294)
+++ propel/config/PropelConfiguration.php (working copy)
@@ -16,7 +16,7 @@
* configuration can also be retrieved as a nested arrays, flat array or as a
* PropelConfiguration instance.
*
- * @author Veikko Mäkinen <veikko@veikko.fi>
+ * @author Veikko Mäkinen <veikko@veikko.fi>
* @version $Revision$
* @package propel.runtime.config
*/
@@ -26,51 +26,58 @@
const TYPE_ARRAY_FLAT = 2;
const TYPE_OBJECT = 3;
- /**
- * @var array An array of parameters
- */
protected $parameters = array();
-
protected $flattenedParameters = array();
protected $isFlattened = false;
/**
* Construct a new configuration container
*
- * @param array $parameters
+ * @param array $parameters
*/
public function __construct(array $parameters = array())
{
$this->parameters = $parameters;
}
- /**
- * @see http://www.php.net/ArrayAccess
- */
+ /**
+ * @see http://www.php.net/ArrayAccess
+ *
+ * @param integer $offset
+ * @return boolean
+ */
public function offsetExists($offset)
{
return array_key_exists($offset, $this->parameters);
}
- /**
- * @see http://www.php.net/ArrayAccess
- */
+ /**
+ * @see http://www.php.net/ArrayAccess
+ *
+ * @param integer $offset
+ * @param mixed $value
+ */
public function offsetSet($offset, $value)
{
- $this->parameter[$offset] = $value;
+ $this->parameters[$offset] = $value;
}
- /**
- * @see http://www.php.net/ArrayAccess
- */
+ /**
+ * @see http://www.php.net/ArrayAccess
+ *
+ * @param integer $offset
+ * @return array
+ */
public function offsetGet($offset)
{
return $this->parameters[$offset];
}
- /**
- * @see http://www.php.net/ArrayAccess
- */
+ /**
+ * @see http://www.php.net/ArrayAccess
+ *
+ * @param integer $offset
+ */
public function offsetUnset($offset)
{
unset($this->parameters[$offset]);
@@ -79,10 +86,10 @@
/**
* Get parameter value from the container
*
- * @param string $name Parameter name
- * @param mixed $default Default value to be used if the
- * requested value is not found
- * @return mixed Parameter value or the default
+ * @param string $name Parameter name
+ * @param mixed $default Default value to be used if the requested value is not found
+ *
+ * @return mixed Parameter value or the default
*/
public function getParameter($name, $default = null)
{
@@ -96,8 +103,8 @@
/**
* Store a value to the container
*
- * @param string $name Configuration item name (name.space.name)
- * @param mixed $value Value to be stored
+ * @param string $name Configuration item name (name.space.name)
+ * @param mixed $value Value to be stored
*/
public function setParameter($name, $value)
{
@@ -111,10 +118,10 @@
}
/**
- *
- *
- * @param int $type
- * @return mixed
+ * @throws PropelException
+ *
+ * @param integer $type
+ * @return mixed
*/
public function getParameters($type = PropelConfiguration::TYPE_ARRAY)
{
@@ -130,6 +137,9 @@
}
}
+ /**
+ * @return array
+ */
public function getFlattenedParameters()
{
if (!$this->isFlattened) {
@@ -151,5 +161,4 @@
}
$this->flattenedParameters = array_merge($this->flattenedParameters, $result);
}
-
}
Index: propel/config/PropelConfigurationIterator.php
===================================================================
--- propel/config/PropelConfigurationIterator.php (revision 2294)
+++ propel/config/PropelConfigurationIterator.php (working copy)
@@ -12,7 +12,7 @@
* PropelConfigurationIterator is used internally by PropelConfiguration to
* build a flat array from nesting configuration arrays.
*
- * @author Veikko Mäkinen <veikko@veikko.fi>
+ * @author Veikko Mäkinen <veikko@veikko.fi>
* @version $Revision$
* @package propel.runtime.config
*/
@@ -31,21 +31,21 @@
/**
* Namespace stack when recursively iterating the configuration tree
*
- * @var array
+ * @var array
*/
protected $namespaceStack = array();
/**
* Current node type. Possible values: null (undefined), self::NODE_PARENT or self::NODE_ITEM
*
- * @var int
+ * @var integer
*/
protected $nodeType = null;
/**
* Get current namespace
*
- * @return string
+ * @return string
*/
public function getNamespace()
{
@@ -55,8 +55,8 @@
/**
* Get current node type.
*
- * @see http://www.php.net/RecursiveIteratorIterator
- * @return int
+ * @see http://www.php.net/RecursiveIteratorIterator
+ * @return integer
* - null (undefined)
* - self::NODE_PARENT
* - self::NODE_ITEM
@@ -69,8 +69,8 @@
/**
* Get the current element
*
- * @see http://www.php.net/RecursiveIteratorIterator
- * @return mixed
+ * @see http://www.php.net/RecursiveIteratorIterator
+ * @return mixed
*/
public function current()
{
@@ -89,7 +89,7 @@
/**
* Called after current child iterator is invalid and right before it gets destructed.
*
- * @see http://www.php.net/RecursiveIteratorIterator
+ * @see http://www.php.net/RecursiveIteratorIterator
*/
public function endChildren()
{
@@ -97,5 +97,4 @@
array_pop($this->namespaceStack);
}
}
-
}
Index: propel/query/Criterion.php
===================================================================
--- propel/query/Criterion.php (revision 2294)
+++ propel/query/Criterion.php (working copy)
@@ -19,15 +19,14 @@
*/
class Criterion
{
-
const UND = " AND ";
const ODER = " OR ";
/** Value of the CO. */
protected $value;
- /** Comparison value.
- * @var SqlEnum
+ /**
+ * @var SqlEnum Comparison value.
*/
protected $comparison;
@@ -40,7 +39,7 @@
/** Column name. */
protected $column;
- /** flag to ignore case in comparison */
+ /** @var boolean flag to ignore case in comparison */
protected $ignoreStringCase = false;
/**
@@ -49,23 +48,31 @@
*/
protected $db;
- /**
- * other connected criteria and their conjunctions.
- */
+ /**
+ * @var array|Criterion[] Other connected criteria and their conjunctions.
+ */
protected $clauses = array();
+
+ /**
+ * @var array
+ */
protected $conjunctions = array();
- /** "Parent" Criteria class */
+ /**
+ * @var Criteria "Parent" Criteria class
+ */
protected $parent;
- /**
- * Create a new instance.
- *
- * @param Criteria $parent The outer class (this is an "inner" class).
- * @param string $column TABLE.COLUMN format.
- * @param mixed $value
- * @param string $comparison
- */
+ /**
+ * Create a new instance.
+ *
+ * @param Criteria $outer The outer class (this is an "inner" class).
+ * @param string $column TABLE.COLUMN format.
+ * @param mixed $value
+ * @param string $comparison
+ *
+ * @return Criterion
+ */
public function __construct(Criteria $outer, $column, $value, $comparison = null)
{
$this->value = $value;
@@ -84,7 +91,8 @@
/**
* Init some properties with the help of outer class
- * @param Criteria $criteria The outer class
+ *
+ * @param Criteria $criteria The outer class
*/
public function init(Criteria $criteria)
{
@@ -101,13 +109,12 @@
// init $this->realtable
$realtable = $criteria->getTableForAlias($this->table);
$this->realtable = $realtable ? $realtable : $this->table;
-
}
/**
- * Get the column name.
+ * Get a String with the column name.
*
- * @return string A String with the column name.
+ * @return string
*/
public function getColumn()
{
@@ -117,8 +124,8 @@
/**
* Set the table name.
*
- * @param name A String with the table name.
- * @return void
+ * @param string $name A String with the table name.
+ * @return void
*/
public function setTable($name)
{
@@ -126,9 +133,9 @@
}
/**
- * Get the table name.
+ * Get a String with the table name.
*
- * @return string A String with the table name.
+ * @return string
*/
public function getTable()
{
@@ -138,7 +145,7 @@
/**
* Get the comparison.
*
- * @return string A String with the comparison.
+ * @return string
*/
public function getComparison()
{
@@ -146,9 +153,9 @@
}
/**
- * Get the value.
+ * Get an Object with the value.
*
- * @return mixed An Object with the value.
+ * @return mixed
*/
public function getValue()
{
@@ -157,9 +164,9 @@
/**
* Get the value of db.
- * The DBAdapter which might be used to get db specific
- * variations of sql.
- * @return DBAdapter value of db.
+ * The DBAdapter which might be used to get db specific variations of sql.
+ *
+ * @return DBAdapter
*/
public function getDB()
{
@@ -169,13 +176,13 @@
/**
* Set the value of db.
* The DBAdapter might be used to get db specific variations of sql.
- * @param DBAdapter $v Value to assign to db.
- * @return void
+ *
+ * @param DBAdapter $v Value to assign to db.
*/
public function setDB(DBAdapter $v)
{
$this->db = $v;
- foreach ( $this->clauses as $clause ) {
+ foreach ($this->clauses as $clause) {
$clause->setDB($v);
}
}
@@ -183,8 +190,8 @@
/**
* Sets ignore case.
*
- * @param boolean $b True if case should be ignored.
- * @return Criterion A modified Criterion object.
+ * @param boolean $b True if case should be ignored.
+ * @return Criterion
*/
public function setIgnoreCase($b)
{
@@ -195,7 +202,7 @@
/**
* Is ignore case on or off?
*
- * @return boolean True if case is ignored.
+ * @return boolean
*/
public function isIgnoreCase()
{
@@ -204,57 +211,65 @@
/**
* Get the list of clauses in this Criterion.
- * @return array
+ *
+ * @return array
*/
- private function getClauses()
+ public function getClauses()
{
return $this->clauses;
}
/**
* Get the list of conjunctions in this Criterion
- * @return array
+ *
+ * @return array
*/
public function getConjunctions()
{
return $this->conjunctions;
}
- /**
- * Append an AND Criterion onto this Criterion's list.
- */
+ /**
+ * Append an AND Criterion onto this Criterion's list.
+ *
+ * @param Criterion $criterion
+ * @return Criterion
+ */
public function addAnd(Criterion $criterion)
{
$this->clauses[] = $criterion;
$this->conjunctions[] = self::UND;
+
return $this;
}
- /**
- * Append an OR Criterion onto this Criterion's list.
- * @return Criterion
- */
+ /**
+ * Append an OR Criterion onto this Criterion's list.
+ *
+ * @param Criterion $criterion
+ * @return Criterion
+ */
public function addOr(Criterion $criterion)
{
$this->clauses[] = $criterion;
$this->conjunctions[] = self::ODER;
+
return $this;
}
/**
- * Appends a Prepared Statement representation of the Criterion
- * onto the buffer.
+ * Appends a Prepared Statement representation of the Criterion onto the buffer.
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
- * @return void
- * @throws PropelException - if the expression builder cannot figure out how to turn a specified
- * expression into proper SQL.
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
+ *
+ * @throws PropelException if the expression builder cannot figure out how to turn a specified
+ * expression into proper SQL.
*/
public function appendPsTo(&$sb, array &$params)
{
$sb .= str_repeat ( '(', count($this->clauses) );
-
+
$this->dispatchPsHandling($sb, $params);
foreach ($this->clauses as $key => $clause) {
@@ -263,14 +278,14 @@
$sb .= ')';
}
}
-
+
/**
- * Figure out which Criterion method to use
+ * Figure out which Criterion method to use
* to build the prepared statement and parameters using to the Criterion comparison
* and call it to append the prepared statement and the parameters of the current clause
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function dispatchPsHandling(&$sb, array &$params)
{
@@ -296,13 +311,13 @@
$this->appendBasicToPs($sb, $params);
}
}
-
+
/**
* Appends a Prepared Statement representation of the Criterion onto the buffer
* For custom expressions with no binding, e.g. 'NOW() = 1'
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function appendCustomToPs(&$sb, array &$params)
{
@@ -315,8 +330,8 @@
* Appends a Prepared Statement representation of the Criterion onto the buffer
* For IN expressions, e.g. table.column IN (?, ?) or table.column NOT IN (?, ?)
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function appendInToPs(&$sb, array &$params)
{
@@ -341,8 +356,8 @@
* Appends a Prepared Statement representation of the Criterion onto the buffer
* For LIKE expressions, e.g. table.column LIKE ? or table.column NOT LIKE ? (or ILIKE for Postgres)
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function appendLikeToPs(&$sb, array &$params)
{
@@ -361,9 +376,9 @@
$field = $db->ignoreCase($field);
}
}
-
+
$params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value);
-
+
$sb .= $field . $this->comparison;
// If selection is case insensitive use SQL UPPER() function
@@ -377,10 +392,10 @@
/**
* Appends a Prepared Statement representation of the Criterion onto the buffer
- * For traditional expressions, e.g. table.column = ? or table.column >= ? etc.
+ * For traditional expressions, e.g. table.column = ? or table.column >= ? etc.
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function appendBasicToPs(&$sb, array &$params)
{
@@ -388,14 +403,12 @@
// NULL VALUES need special treatment because the SQL syntax is different
// i.e. table.column IS NULL rather than table.column = null
if ($this->value !== null) {
-
// ANSI SQL functions get inserted right into SQL (not escaped, etc.)
if ($this->value === Criteria::CURRENT_DATE || $this->value === Criteria::CURRENT_TIME || $this->value === Criteria::CURRENT_TIMESTAMP) {
$sb .= $field . $this->comparison . $this->value;
} else {
-
$params[] = array('table' => $this->realtable, 'column' => $this->column, 'value' => $this->value);
-
+
// default case, it is a normal col = value expression; value
// will be replaced w/ '?' and will be inserted later using PDO bindValue()
if ($this->ignoreStringCase) {
@@ -403,10 +416,8 @@
} else {
$sb .= $field . $this->comparison . ':p'.count($params);
}
-
}
} else {
-
// value is null, which means it was either not specified or specifically
// set to null.
if ($this->comparison === Criteria::EQUAL || $this->comparison === Criteria::ISNULL) {
@@ -417,15 +428,16 @@
// for now throw an exception, because not sure how to interpret this
throw new PropelException("Could not build SQL for expression: $field " . $this->comparison . " NULL");
}
-
}
}
-
- /**
- * This method checks another Criteria to see if they contain
- * the same attributes and hashtable entries.
- * @return boolean
- */
+
+ /**
+ * This method checks another Criterion to see if they contain
+ * the same attributes and hashtable entries.
+ *
+ * @param Criterion $obj
+ * @return boolean
+ */
public function equals($obj)
{
// TODO: optimize me with early outs
@@ -465,7 +477,9 @@
/**
* Returns a hash code value for the object.
- */
+ *
+ * @return integer
+ */
public function hashCode()
{
$h = crc32(serialize($this->value)) ^ crc32($this->comparison);
@@ -487,7 +501,7 @@
$params = array();
$clause->appendPsTo($sb,$params);
$h ^= crc32(serialize(array($sb,$params)));
- unset ( $sb, $params );
+ unset ($sb, $params);
}
return $h;
@@ -495,7 +509,8 @@
/**
* Get all tables from nested criterion objects
- * @return array
+ *
+ * @return array
*/
public function getAllTables()
{
@@ -504,11 +519,13 @@
return $tables;
}
- /**
- * method supporting recursion through all criterions to give
- * us a string array of tables from each criterion
- * @return void
- */
+ /**
+ * Method supporting recursion through all criterions to give
+ * us a string array of tables from each criterion
+ *
+ * @param Criterion $c
+ * @param array $s
+ */
private function addCriterionTable(Criterion $c, array &$s)
{
$s[] = $c->getTable();
@@ -516,21 +533,25 @@
$this->addCriterionTable($clause, $s);
}
}
-
+
/**
- * get an array of all criterion attached to this
+ * Get an array of all criterion attached to this
* recursing through all sub criterion
- * @return array Criterion[]
+ *
+ * @return array|Criterion[]
*/
public function getAttachedCriterion()
{
$criterions = array($this);
+
+ /** @var $criterion Criterion */
foreach ($this->getClauses() as $criterion) {
$criterions = array_merge($criterions, $criterion->getAttachedCriterion());
}
+
return $criterions;
}
-
+
/**
* Ensures deep cloning of attached objects
*/
@@ -540,4 +561,4 @@
$this->clauses[$key] = clone $criterion;
}
}
-}
\ No newline at end of file
+}
Index: propel/query/Join.php
===================================================================
--- propel/query/Join.php (revision 2294)
+++ propel/query/Join.php (working copy)
@@ -30,7 +30,7 @@
// default comparison type
const EQUAL = "=";
const INNER_JOIN = 'INNER JOIN';
-
+
// the left parts of the join condition
protected $left = array();
@@ -39,23 +39,27 @@
// the comparison operators for each pair of columns in the join condition
protected $operator = array();
-
+
// the type of the join (LEFT JOIN, ...)
protected $joinType;
-
+
// the number of conditions in the join
protected $count = 0;
-
- // the database adapter
+
+ /**
+ * The database adapter
+ *
+ * @var DBAdapter
+ */
protected $db;
protected $leftTableName;
protected $rightTableName;
protected $leftTableAlias;
protected $rightTableAlias;
-
+
protected $joinCondition;
-
+
/**
* Constructor
* Use it preferably with no arguments, and then use addCondition() and setJoinType()
@@ -83,25 +87,25 @@
$this->setJoinType($joinType);
}
}
-
+
/**
- * Join condition definition.
+ * Join condition definition.
* Warning: doesn't support table aliases. Use the explicit methods to use aliases.
*
* @param string $left The left column of the join condition
* (may contain an alias name)
* @param string $right The right column of the join condition
* (may contain an alias name)
- * @param string $operator The comparison operator of the join condition, default Join::EQUAL
+ * @param string $operator The comparison operator of the join condition, default Join::EQUAL
*/
public function addCondition($left, $right, $operator = self::EQUAL)
{
- if ($pos = strrpos($left, '.')) {
+ if (strrpos($left, '.')) {
list($this->leftTableName, $this->left[]) = explode('.', $left);
} else {
$this->left[] = $left;
}
- if ($pos = strrpos($right, '.')) {
+ if (strrpos($right, '.')) {
list($this->rightTableName, $this->right[]) = explode('.', $right);
} else {
$this->right[] = $right;
@@ -115,7 +119,7 @@
*
* @param array $lefts The left columns of the join condition
* @param array $rights The right columns of the join condition
- * @param array $operators The comparison operators of the join condition, default Join::EQUAL
+ * @param array $operators The comparison operators of the join condition, default Join::EQUAL
*/
public function addConditions($lefts, $rights, $operators = array())
{
@@ -128,7 +132,7 @@
}
/**
- * Join condition definition.
+ * Join condition definition.
* @example
* <code>
* $join = new Join();
@@ -144,7 +148,7 @@
* @param string $rightTableName
* @param string $rightColumnName
* @param string $rightTableAlias
- * @param string $operator The comparison operator of the join condition, default Join::EQUAL
+ * @param string $operator The comparison operator of the join condition, default Join::EQUAL
*/
public function addExplicitCondition($leftTableName, $leftColumnName, $leftTableAlias = null, $rightTableName, $rightColumnName, $rightTableAlias = null, $operator = self::EQUAL)
{
@@ -157,7 +161,7 @@
$this->operator []= $operator;
$this->count++;
}
-
+
/**
* Retrieve the number of conditions in the join
*
@@ -167,7 +171,7 @@
{
return $this->count;
}
-
+
/**
* Return an array of the join conditions
*
@@ -178,7 +182,7 @@
$conditions = array();
for ($i=0; $i < $this->count; $i++) {
$conditions[] = array(
- 'left' => $this->getLeftColumn($i),
+ 'left' => $this->getLeftColumn($i),
'operator' => $this->getOperator($i),
'right' => $this->getRightColumn($i)
);
@@ -193,20 +197,21 @@
{
$this->operator []= $operator;
}
-
+
/**
- * @return the comparison operator for the join condition
+ * @param integer $index
+ * @return string
*/
public function getOperator($index = 0)
{
return $this->operator[$index];
}
-
+
public function getOperators()
{
return $this->operator;
}
-
+
/**
* Set the join type
*
@@ -218,7 +223,7 @@
{
$this->joinType = $joinType;
}
-
+
/**
* Get the join type
*
@@ -244,7 +249,7 @@
{
$this->left []= $left;
}
-
+
/**
* Get the fully qualified name of the left column of the join condition
*
@@ -254,12 +259,12 @@
* echo $join->getLeftColumn(); // 'book.AUTHOR_ID'
* </code>
* @param integer $index The number of the condition to use
- * @return string
+ * @return string
*/
public function getLeftColumn($index = 0)
{
$tableName = $this->getLeftTableAliasOrName();
-
+
return $tableName ? $tableName . '.' . $this->left[$index] : $this->left[$index];
}
@@ -272,13 +277,13 @@
* echo $join->getLeftColumnName(); // 'AUTHOR_ID'
* </code>
* @param integer $index The number of the condition to use
- * @return string
+ * @return string
*/
public function getLeftColumnName($index = 0)
{
return $this->left[$index];
}
-
+
/**
* Get the list of all the names of left columns of the join condition
* @return array
@@ -295,10 +300,10 @@
public function setLeftTableName($leftTableName)
{
$this->leftTableName = $leftTableName;
-
+
return $this;
}
-
+
public function getLeftTableName()
{
return $this->leftTableName;
@@ -307,20 +312,20 @@
public function setLeftTableAlias($leftTableAlias)
{
$this->leftTableAlias = $leftTableAlias;
-
+
return $this;
}
-
+
public function getLeftTableAlias()
{
return $this->leftTableAlias;
}
-
+
public function hasLeftTableAlias()
{
return null !== $this->leftTableAlias;
}
-
+
public function getLeftTableAliasOrName()
{
return $this->leftTableAlias ? $this->leftTableAlias : $this->leftTableName;
@@ -345,7 +350,7 @@
{
$this->right []= $right;
}
-
+
/**
* Get the fully qualified name of the right column of the join condition
*
@@ -355,12 +360,12 @@
* echo $join->getLeftColumn(); // 'author.ID'
* </code>
* @param integer $index The number of the condition to use
- * @return string
+ * @return string
*/
public function getRightColumn($index = 0)
{
$tableName = $this->getRightTableAliasOrName();
-
+
return $tableName ? $tableName . '.' . $this->right[$index] : $this->right[$index];
}
@@ -373,13 +378,13 @@
* echo $join->getLeftColumn(); // 'ID'
* </code>
* @param integer $index The number of the condition to use
- * @return string
+ * @return string
*/
public function getRightColumnName($index = 0)
{
return $this->right[$index];
}
-
+
/**
* @return all right columns of the join condition
*/
@@ -395,10 +400,10 @@
public function setRightTableName($rightTableName)
{
$this->rightTableName = $rightTableName;
-
+
return $this;
}
-
+
public function getRightTableName()
{
return $this->rightTableName;
@@ -407,15 +412,15 @@
public function setRightTableAlias($rightTableAlias)
{
$this->rightTableAlias = $rightTableAlias;
-
+
return $this;
}
-
+
public function getRightTableAlias()
{
return $this->rightTableAlias;
}
-
+
public function hasRightTableAlias()
{
return null !== $this->rightTableAlias;
@@ -425,12 +430,12 @@
{
return $this->rightTableAlias ? $this->rightTableAlias : $this->rightTableName;
}
-
+
public function getRightTableWithAlias()
{
return $this->rightTableAlias ? $this->rightTableName . ' ' . $this->rightTableAlias : $this->rightTableName;
}
-
+
/**
* Get the value of db.
* The DBAdapter which might be used to get db specific
@@ -452,10 +457,10 @@
{
$this->db = $db;
}
-
+
/**
* Set a custom join condition
- *
+ *
* @param Criterion $joinCondition a Join condition
*/
public function setJoinCondition(Criterion $joinCondition)
@@ -465,14 +470,14 @@
/**
* Get the custom join condition, if previously set
- *
+ *
* @return Criterion
*/
public function getJoinCondition()
{
return $this->joinCondition;
}
-
+
/**
* Set the custom join condition Criterion based on the conditions of this join
*
@@ -491,7 +496,7 @@
}
$this->joinCondition = $joinCondition;
}
-
+
/**
* Get the join clause for this Join.
* If the join condition needs binding, uses the passed params array.
@@ -503,7 +508,7 @@
* echo $j->getClause($params);
* // 'LEFT JOIN author ON (book.AUTHOR_ID=author.ID)'
* </code>
- *
+ *
* @param array &$params
*
* @return string SQL join clause with join condition
@@ -520,7 +525,7 @@
$joinCondition = '';
$this->getJoinCondition()->appendPsTo($joinCondition, $params);
}
-
+
$rightTableName = $this->getRightTableWithAlias();
if (null !== $this->db && $this->db->useQuoteIdentifier()) {
@@ -534,28 +539,31 @@
);
}
+ /**
+ * @param Join $join
+ * @return boolean
+ */
public function equals($join)
{
- return $join !== null
+ return $join !== null
&& $join instanceof Join
&& $this->joinType == $join->getJoinType()
&& $this->getConditions() == $join->getConditions();
}
-
+
/**
* Returns a String representation of the class,
*
- * @return string A String representation of the class
+ * @return string
*/
public function toString()
{
$params = array();
return $this->getClause($params);
}
-
+
public function __toString()
{
return $this->toString();
}
}
-
\ No newline at end of file
Index: propel/query/ModelCriterion.php
===================================================================
--- propel/query/ModelCriterion.php (revision 2294)
+++ propel/query/ModelCriterion.php (working copy)
@@ -19,15 +19,17 @@
{
protected $clause = '';
- /**
- * Create a new instance.
- *
- * @param Criteria $parent The outer class (this is an "inner" class).
- * @param ColumnMap $column A Column object to help escaping the value
- * @param mixed $value
- * @param string $comparison, among ModelCriteria::MODEL_CLAUSE
- * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?'
- */
+ /**
+ * Create a new instance.
+ *
+ * @param Criteria $outer
+ * @param ColumnMap $column A Column object to help escaping the value
+ * @param mixed $value
+ * @param string $comparison
+ * @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?'
+ *
+ * @return ModelCriterion
+ */
public function __construct(Criteria $outer, $column, $value = null, $comparison = ModelCriteria::MODEL_CLAUSE, $clause)
{
$this->value = $value;
@@ -49,22 +51,22 @@
$this->clause = $clause;
$this->init($outer);
}
-
+
public function getClause()
{
return $this->clause;
}
-
+
/**
- * Figure out which MocelCriterion method to use
+ * Figure out which MocelCriterion method to use
* to build the prepared statement and parameters using to the Criterion comparison
* and call it to append the prepared statement and the parameters of the current clause.
* For performance reasons, this method tests the cases of parent::dispatchPsHandling()
* first, and that is not possible through inheritance ; that's why the parent
* code is duplicated here.
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
protected function dispatchPsHandling(&$sb, array &$params)
{
@@ -112,8 +114,8 @@
* Appends a Prepared Statement representation of the ModelCriterion onto the buffer
* For regular model clauses, e.g. 'book.TITLE = ?'
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
public function appendModelClauseToPs(&$sb, array &$params)
{
@@ -130,8 +132,8 @@
* For LIKE model clauses, e.g. 'book.TITLE LIKE ?'
* Handles case insensitivity for VARCHAR columns
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
public function appendModelClauseLikeToPs(&$sb, array &$params)
{
@@ -142,13 +144,13 @@
}
$this->appendModelClauseToPs($sb, $params);
}
-
+
/**
* Appends a Prepared Statement representation of the ModelCriterion onto the buffer
* For ternary model clauses, e.G 'book.ID BETWEEN ? AND ?'
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
public function appendModelClauseSeveralToPs(&$sb, array &$params)
{
@@ -170,8 +172,8 @@
* Appends a Prepared Statement representation of the ModelCriterion onto the buffer
* For IN or NOT IN model clauses, e.g. 'book.TITLE NOT IN ?'
*
- * @param string &$sb The string that will receive the Prepared Statement
- * @param array $params A list to which Prepared Statement parameters will be appended
+ * @param string &$sb The string that will receive the Prepared Statement
+ * @param array $params A list to which Prepared Statement parameters will be appended
*/
public function appendModelClauseArrayToPs(&$sb, array &$params)
{
@@ -190,12 +192,14 @@
}
unset ( $value, $valuesLength );
}
-
- /**
- * This method checks another Criteria to see if they contain
- * the same attributes and hashtable entries.
- * @return boolean
- */
+
+ /**
+ * This method checks another Criterion to see if they contain
+ * the same attributes and hashtable entries.
+ *
+ * @param ModelCriterion $obj
+ * @return boolean
+ */
public function equals($obj)
{
// TODO: optimize me with early outs
@@ -207,6 +211,7 @@
return false;
}
+ /** @var $crit ModelCriterion */
$crit = $obj;
$isEquiv = ( ( ($this->table === null && $crit->getTable() === null)
@@ -236,7 +241,9 @@
/**
* Returns a hash code value for the object.
- */
+ *
+ * @return integer
+ */
public function hashCode()
{
$h = crc32(serialize($this->value)) ^ crc32($this->comparison) ^ crc32($this->clause);
@@ -263,12 +270,17 @@
return $h;
}
-
- /**
- * Replace only once
- * taken from http://www.php.net/manual/en/function.str-replace.php
- *
- */
+
+ /**
+ * Replace only once
+ * taken from http://www.php.net/manual/en/function.str-replace.php
+ *
+ * @param string $search
+ * @param string $replace
+ * @param string $subject
+ *
+ * @return string
+ */
protected static function strReplaceOnce($search, $replace, $subject)
{
$firstChar = strpos($subject, $search);
@@ -279,5 +291,5 @@
} else {
return $subject;
}
- }
-}
\ No newline at end of file
+ }
+}
Index: propel/query/ModelJoin.php
===================================================================
--- propel/query/ModelJoin.php (revision 2294)
+++ propel/query/ModelJoin.php (working copy)
@@ -16,10 +16,22 @@
*/
class ModelJoin extends Join
{
+ /** @var RelationMap */
protected $relationMap;
+
+ /** @var TableMap */
protected $tableMap;
+
+ /** @var ModelJoin */
protected $previousJoin;
-
+
+ /**
+ * @param RelationMap $relationMap
+ * @param string $leftTableAlias
+ * @param string $relationAlias
+ *
+ * @return ModelJoin
+ */
public function setRelationMap(RelationMap $relationMap, $leftTableAlias = null, $relationAlias = null)
{
$leftCols = $relationMap->getLeftColumns();
@@ -32,10 +44,10 @@
Criteria::EQUAL);
}
$this->relationMap = $relationMap;
-
+
return $this;
}
-
+
public function getRelationMap()
{
return $this->relationMap;
@@ -43,21 +55,20 @@
/**
* Sets the right tableMap for this join
- *
- * @param TableMap $tableMap The table map to use
- *
- * @return ModelJoin The current join object, for fluid interface
+ *
+ * @param TableMap $tableMap The table map to use
+ * @return ModelJoin
*/
public function setTableMap(TableMap $tableMap)
{
$this->tableMap = $tableMap;
-
+
return $this;
}
/**
* Gets the right tableMap for this join
- *
+ *
* @return TableMap The table map
*/
public function getTableMap()
@@ -68,19 +79,19 @@
}
return $this->tableMap;
}
-
+
public function setPreviousJoin(ModelJoin $join)
{
$this->previousJoin = $join;
-
+
return $this;
}
-
+
public function getPreviousJoin()
{
return $this->previousJoin;
}
-
+
public function isPrimary()
{
return null === $this->previousJoin;
@@ -90,26 +101,27 @@
{
return $this->setRightTableAlias($relationAlias);
}
-
+
public function getRelationAlias()
{
return $this->getRightTableAlias();
}
-
+
public function hasRelationAlias()
{
return $this->hasRightTableAlias();
}
+
/**
* This method returns the last related, but already hydrated object up until this join
- * Starting from $startObject and continuously calling the getters to get
+ * Starting from $startObject and continuously calling the getters to get
* to the base object for the current join.
- *
+ *
* This method only works if PreviousJoin has been defined,
* which only happens when you provide dotted relations when calling join
- *
- * @param Object $startObject the start object all joins originate from and which has already hydrated
- * @return Object the base Object of this join
+ *
+ * @param Object $startObject the start object all joins originate from and which has already hydrated
+ * @return BaseObject
*/
public function getObjectToRelate($startObject)
{
@@ -123,6 +135,10 @@
}
}
+ /**
+ * @param ModelJoin $join
+ * @return boolean
+ */
public function equals($join)
{
return parent::equals($join)
@@ -130,7 +146,7 @@
&& $this->previousJoin == $join->getPreviousJoin()
&& $this->rightTableAlias == $join->getRightTableAlias();
}
-
+
public function __toString()
{
return parent::toString()
@@ -140,4 +156,3 @@
. ' relationAlias: ' . $this->rightTableAlias;
}
}
-
\ No newline at end of file
Index: propel/query/Criteria.php
===================================================================
--- propel/query/Criteria.php (revision 2294)
+++ propel/query/Criteria.php (working copy)
@@ -62,7 +62,7 @@
/** Comparison for array column types */
const CONTAINS_NONE = "CONTAINS_NONE";
-
+
/** PostgreSQL comparison type */
const ILIKE = " ILIKE ";
@@ -128,119 +128,124 @@
/** logical OR operator */
const LOGICAL_OR = "OR";
-
+
/** logical AND operator */
const LOGICAL_AND = "AND";
-
+
protected $ignoreCase = false;
protected $singleRecord = false;
-
+
/**
* Storage of select data. Collection of column names.
- * @var array
+ * @var array
*/
protected $selectColumns = array();
-
+
/**
* Storage of aliased select data. Collection of column names.
- * @var array
+ * @var array
*/
protected $asColumns = array();
-
+
/**
* Storage of select modifiers data. Collection of modifier names.
- * @var array
+ * @var array
*/
protected $selectModifiers = array();
-
+
/**
* Storage of conditions data. Collection of Criterion objects.
- * @var array
+ * @var array|Criterion[]
*/
protected $map = array();
-
+
/**
* Storage of ordering data. Collection of column names.
- * @var array
+ * @var array
*/
protected $orderByColumns = array();
-
+
/**
* Storage of grouping data. Collection of column names.
- * @var array
+ * @var array
*/
protected $groupByColumns = array();
-
+
/**
* Storage of having data.
- * @var Criterion
+ * @var Criterion
*/
protected $having = null;
-
+
/**
* Storage of join data. colleciton of Join objects.
- * @var array
+ * @var array|ModelJoin[]
*/
protected $joins = array();
protected $selectQueries = array();
/**
* The name of the database.
- * @var string
+ * @var string
*/
protected $dbName;
/**
* The primary table for this Criteria.
- * Useful in cases where there are no select or where
- * columns.
- * @var string
+ * Useful in cases where there are no select or where columns.
+ *
+ * @var string
*/
protected $primaryTableName;
- /** The name of the database as given in the contructor. */
+ /**
+ * The name of the database as given in the contructor.
+ */
protected $originalDbName;
/**
- * To limit the number of rows to return. <code>0</code> means return all
- * rows.
+ * To limit the number of rows to return. <code>0</code> means return all rows.
*/
protected $limit = 0;
- /** To start the results at a row other than the first one. */
+ /**
+ * To start the results at a row other than the first one.
+ */
protected $offset = 0;
/**
* Comment to add to the SQL query
- * @var string
+ *
+ * @var string
*/
protected $queryComment;
-
+
// flag to note that the criteria involves a blob.
protected $blobFlag = null;
protected $aliases = array();
protected $useTransaction = false;
-
+
/**
* Storage for Criterions expected to be combined
- * @var array
+ * @var array
*/
protected $namedCriterions = array();
-
+
/**
* Default operator for combination of criterions
- * @see addUsingOperator
- * @var string Criteria::LOGICAL_AND or Criteria::LOGICAL_OR
+ *
+ * @see addUsingOperator
+ * @var string Criteria::LOGICAL_AND or Criteria::LOGICAL_OR
*/
protected $defaultCombineOperator = Criteria::LOGICAL_AND;
-
+
/**
* Creates a new instance with the default capacity which corresponds to
* the specified database.
*
- * @param dbName The dabase name.
+ * @param string $dbName The dabase name.
*/
public function __construct($dbName = null)
{
@@ -249,9 +254,11 @@
}
/**
- * Implementing SPL IteratorAggregate interface. This allows
+ * Implementing SPL IteratorAggregate interface. This allows
* you to foreach () over a Criteria object.
- */
+ *
+ * @return CriterionIterator
+ */
public function getIterator()
{
return new CriterionIterator($this);
@@ -259,7 +266,8 @@
/**
* Get the criteria map, i.e. the array of Criterions
- * @return array
+ *
+ * @return array
*/
public function getMap()
{
@@ -270,7 +278,8 @@
* Brings this criteria back to its initial state, so that it
* can be reused as if it was new. Except if the criteria has grown in
* capacity, it is left at the current capacity.
- * @return void
+ *
+ * @return void
*/
public function clear()
{
@@ -301,37 +310,38 @@
* Criteria myCrit = new Criteria();
* myCrit->addAsColumn("alias", "ALIAS(".MyPeer::ID.")");
* </code>
+ *
+ * If the name already exists, it is replaced by the new clause.
*
- * @param string $name Wanted Name of the column (alias).
- * @param string $clause SQL clause to select from the table
+ * @param string $name Wanted Name of the column (alias).
+ * @param string $clause SQL clause to select from the table
*
- * If the name already exists, it is replaced by the new clause.
- *
- * @return Criteria A modified Criteria object.
+ * @return Criteria A modified Criteria object.
*/
public function addAsColumn($name, $clause)
{
$this->asColumns[$name] = $clause;
+
return $this;
}
/**
- * Get the column aliases.
+ * Get the column aliases which map the column alias names
+ * to the alias clauses.
*
- * @return array An assoc array which map the column alias names
- * to the alias clauses.
+ * @return array
*/
public function getAsColumns()
{
return $this->asColumns;
}
- /**
- * Returns the column name associated with an alias (AS-column).
- *
- * @param string $alias
- * @return string $string
- */
+ /**
+ * Returns the column name associated with an alias (AS-column).
+ *
+ * @param string $as
+ * @return string
+ */
public function getColumnForAs($as)
{
if (isset($this->asColumns[$as])) {
@@ -343,36 +353,35 @@
* Allows one to specify an alias for a table that can
* be used in various parts of the SQL.
*
- * @param string $alias
- * @param string $table
+ * @param string $alias
+ * @param string $table
*
- * @return Criteria A modified Criteria object.
+ * @return Criteria
*/
public function addAlias($alias, $table)
{
$this->aliases[$alias] = $table;
-
+
return $this;
}
/**
* Remove an alias for a table (useful when merging Criterias).
*
- * @param string $alias
- *
- * @return Criteria A modified Criteria object.
+ * @param string $alias
+ * @return Criteria
*/
public function removeAlias($alias)
{
unset($this->aliases[$alias]);
-
+
return $this;
}
-
+
/**
* Returns the aliases for this Criteria
*
- * @return array
+ * @return array
*/
public function getAliases()
{
@@ -382,8 +391,8 @@
/**
* Returns the table name associated with an alias.
*
- * @param string $alias
- * @return string $string
+ * @param string $alias
+ * @return string
*/
public function getTableForAlias($alias)
{
@@ -397,8 +406,8 @@
* Use this method to get the details of a table name that comes in a clause,
* which can be either a table name or an alias name.
*
- * @param string $tableAliasOrName
- * @return array($tableName, $tableAlias)
+ * @param string $tableAliasOrName
+ * @return array
*/
public function getTableNameAndAlias($tableAliasOrName)
{
@@ -408,7 +417,7 @@
return array($tableAliasOrName, null);
}
}
-
+
/**
* Get the keys of the criteria map, i.e. the list of columns bearing a condition
* <code>
@@ -416,7 +425,7 @@
* => array('book.price', 'book.title', 'author.first_name')
* </code>
*
- * @return array
+ * @return array
*/
public function keys()
{
@@ -426,8 +435,8 @@
/**
* Does this Criteria object contain the specified key?
*
- * @param string $column [table.]column
- * @return boolean True if this Criteria object contain the specified key.
+ * @param string $column [table.]column
+ * @return boolean
*/
public function containsKey($column)
{
@@ -437,10 +446,10 @@
}
/**
- * Does this Criteria object contain the specified key and does it have a value set for the key
+ * Does this Criteria object contain the specified key and does it have a value set for the key
*
- * @param string $column [table.]column
- * @return boolean True if this Criteria object contain the specified key and a value for that key
+ * @param string $column [table.]column
+ * @return boolean
*/
public function keyContainsValue($column)
{
@@ -448,27 +457,29 @@
// exist but have a NULL value (that'd be valid).
return (array_key_exists($column, $this->map) && ($this->map[$column]->getValue() !== null) );
}
-
+
/**
* Whether this Criteria has any where columns.
- *
* This counts conditions added with the add() method.
+ *
+ * @see add()
*
- * @return boolean
- * @see add()
+ * @return boolean
*/
public function hasWhereClause()
{
return !empty($this->map);
}
- /**
- * Will force the sql represented by this criteria to be executed within
- * a transaction. This is here primarily to support the oid type in
- * postgresql. Though it can be used to require any single sql statement
- * to use a transaction.
- * @return void
- */
+ /**
+ * Will force the sql represented by this criteria to be executed within
+ * a transaction. This is here primarily to support the oid type in
+ * postgresql. Though it can be used to require any single sql statement
+ * to use a transaction.
+ *
+ * @param boolean $v
+ * @return void
+ */
public function setUseTransaction($v)
{
$this->useTransaction = (boolean) $v;
@@ -478,7 +489,7 @@
* Whether the sql command specified by this criteria must be wrapped
* in a transaction.
*
- * @return boolean
+ * @return boolean
*/
public function isUseTransaction()
{
@@ -491,18 +502,18 @@
* Make sure you call containsKey($column) prior to calling this method,
* since no check on the existence of the $column is made in this method.
*
- * @param string $column Column name.
- * @return Criterion A Criterion object.
+ * @param string $column Column name.
+ * @return Criterion
*/
public function getCriterion($column)
{
return $this->map[$column];
}
-
+
/**
* Method to return the latest Criterion in a table.
*
- * @return Criterion A Criterion or null no Criterion is added.
+ * @return Criterion
*/
public function getLastCriterion()
{
@@ -510,6 +521,7 @@
$map = array_values($this->map);
return $map[$cnt - 1];
}
+
return null;
}
@@ -518,10 +530,11 @@
* to this Criteria. This can be used to chain the
* Criterions to form a more complex where clause.
*
- * @param string $column Full name of column (for example TABLE.COLUMN).
- * @param mixed $value
- * @param string $comparison
- * @return Criterion
+ * @param string $column Full name of column (for example TABLE.COLUMN).
+ * @param mixed $value
+ * @param string $comparison
+ *
+ * @return Criterion
*/
public function getNewCriterion($column, $value = null, $comparison = self::EQUAL)
{
@@ -531,28 +544,30 @@
/**
* Method to return a String table name.
*
- * @param string $name Name of the key.
- * @return string The value of the object at key.
+ * @param string $name Name of the key.
+ * @return string
*/
public function getColumnName($name)
{
if (isset($this->map[$name])) {
return $this->map[$name]->getColumn();
}
+
return null;
}
/**
* Shortcut method to get an array of columns indexed by table.
+ *
* <code>
* print_r($c->getTablesColumns());
* => array(
- * 'book' => array('book.price', 'book.title'),
+ * 'book' => array('book.price', 'book.title'),
* 'author' => array('author.first_name')
* )
* </code>
*
- * @return array array(table => array(table.column1, table.column2))
+ * @return array array(table => array(table.column1, table.column2))
*/
public function getTablesColumns()
{
@@ -565,10 +580,10 @@
}
/**
- * Method to return a comparison String.
+ * Method to return a String with the value of the object at key.
*
- * @param string $key String name of the key.
- * @return string A String with the value of the object at key.
+ * @param string $key String name of the key.
+ * @return string
*/
public function getComparison($key)
{
@@ -579,9 +594,9 @@
}
/**
- * Get the Database(Map) name.
+ * Get a String with the Database(Map) name.
*
- * @return string A String with the Database(Map) name.
+ * @return string
*/
public function getDbName()
{
@@ -589,11 +604,11 @@
}
/**
- * Set the DatabaseMap name. If <code>null</code> is supplied, uses value
+ * Set the DatabaseMap name. If <code>null</code> is supplied, uses value
* provided by <code>Propel::getDefaultDB()</code>.
*
- * @param string $dbName The Database (Map) name.
- * @return void
+ * @param string $dbName The Database (Map) name.
+ * @return void
*/
public function setDbName($dbName = null)
{
@@ -607,32 +622,32 @@
* any SELECT columns or WHERE columns. This must be explicitly
* set, of course, in order to be useful.
*
- * @return string
+ * @return string
*/
public function getPrimaryTableName()
{
return $this->primaryTableName;
}
- /**
- * Sets the primary table for this Criteria.
- *
- * This is useful for cases where a Criteria may not contain
- * any SELECT columns or WHERE columns. This must be explicitly
- * set, of course, in order to be useful.
- *
- * @param string $v
- */
+ /**
+ * Sets the primary table for this Criteria.
+ *
+ * This is useful for cases where a Criteria may not contain
+ * any SELECT columns or WHERE columns. This must be explicitly
+ * set, of course, in order to be useful.
+ *
+ * @param string $tableName
+ */
public function setPrimaryTableName($tableName)
{
$this->primaryTableName = $tableName;
}
/**
- * Method to return a String table name.
+ * Method to return the value of table for criterion at key.
*
- * @param string $name The name of the key.
- * @return string The value of table for criterion at key.
+ * @param string $name The name of the key.
+ * @return string
*/
public function getTableName($name)
{
@@ -645,8 +660,8 @@
/**
* Method to return the value that was added to Criteria.
*
- * @param string $name A String with the name of the key.
- * @return mixed The value of object at key.
+ * @param string $name A String with the name of the key.
+ * @return mixed
*/
public function getValue($name)
{
@@ -658,9 +673,10 @@
/**
* An alias to getValue() -- exposing a Hashtable-like interface.
+ * The value within the Criterion (not the Criterion object).
*
- * @param string $key An Object.
- * @return mixed The value within the Criterion (not the Criterion object).
+ * @param string $key An Object.
+ * @return mixed
*/
public function get($key)
{
@@ -677,9 +693,10 @@
* throw a NPE. The reason for this is that none of the add()
* methods support adding anything other than a String as a key.
*
- * @param string $key
- * @param mixed $value
- * @return Instance of self.
+ * @param string $key
+ * @param mixed $value
+ *
+ * @return Criteria
*/
public function put($key, $value)
{
@@ -694,7 +711,7 @@
* if the map was another Criteria, its attributes are copied to this
* Criteria, overwriting previous settings.
*
- * @param mixed $t Mappings to be stored in this map.
+ * @param mixed $t Mappings to be stored in this map.
*/
public function putAll($t)
{
@@ -726,11 +743,11 @@
* The name of the table must be used implicitly in the column name,
* so the Column name must be something like 'TABLE.id'.
*
- * @param string $critOrColumn The column to run the comparison on, or Criterion object.
- * @param mixed $value
- * @param string $comparison A String.
+ * @param string|Criterion $p1 The column to run the comparison on, or Criterion object
+ * @param mixed $value
+ * @param string $comparison A String
*
- * @return A modified Criteria object.
+ * @return Criteria
*/
public function add($p1, $value = null, $comparison = null)
{
@@ -742,7 +759,7 @@
}
return $this;
}
-
+
/**
* This method creates a new criterion but keeps it for later use with combine()
* Until combine() is called, the condition is not added to the query
@@ -759,12 +776,12 @@
* The name of the table must be used implicitly in the column name,
* so the Column name must be something like 'TABLE.id'.
*
- * @param string $name name to combine the criterion later
- * @param string $p1 The column to run the comparison on, or Criterion object.
- * @param mixed $value
- * @param string $comparison A String.
+ * @param string $name The name to combine the criterion later
+ * @param string $p1 The column to run the comparison on, or Criterion object.
+ * @param mixed $value
+ * @param string $comparison A String.
*
- * @return A modified Criteria object.
+ * @return Criteria
*/
public function addCond($name, $p1, $value = null, $comparison = null)
{
@@ -776,14 +793,16 @@
}
return $this;
}
-
+
/**
* Combine several named criterions with a logical operator
- *
- * @param array $criterions array of the name of the criterions to combine
- * @param string $operator logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR
- * @param string $name optional name to combine the criterion later
- */
+ *
+ * @param array $criterions Array of the name of the criterions to combine
+ * @param string $operator Logical operator, either Criteria::LOGICAL_AND, or Criteria::LOGICAL_OR
+ * @param string $name Name to combine the criterion later
+ *
+ * @return Criteria
+ */
public function combine($criterions = array(), $operator = self::LOGICAL_AND, $name = null)
{
$operatorMethod = (strtoupper($operator) == self::LOGICAL_AND) ? 'addAnd' : 'addOr';
@@ -805,25 +824,25 @@
} else {
$this->addCond($name, $firstCriterion, null, null);
}
-
+
return $this;
}
/**
- * This is the way that you should add a join of two tables.
+ * This is the way that you should add a join of two tables.
* Example usage:
* <code>
* $c->addJoin(ProjectPeer::ID, FooPeer::PROJECT_ID, Criteria::LEFT_JOIN);
* // LEFT JOIN FOO ON (PROJECT.ID = FOO.PROJECT_ID)
* </code>
*
- * @param mixed $left A String with the left side of the join.
- * @param mixed $right A String with the right side of the join.
- * @param mixed $joinType A String with the join operator
- * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN,
- * and Criteria::RIGHT_JOIN
+ * @param mixed $left A String with the left side of the join.
+ * @param mixed $right A String with the right side of the join.
+ * @param mixed $joinType A String with the join operator
+ * among Criteria::INNER_JOIN, Criteria::LEFT_JOIN,
+ * and Criteria::RIGHT_JOIN
*
- * @return Criteria A modified Criteria object.
+ * @return Criteria
*/
public function addJoin($left, $right, $joinType = null)
{
@@ -835,9 +854,9 @@
}
return $this->addMultipleJoin($conditions, $joinType);
}
-
+
$join = new Join();
-
+
// is the left table an alias ?
$dotpos = strrpos($left, '.');
$leftTableAlias = substr($left, 0, $dotpos);
@@ -849,14 +868,14 @@
$rightTableAlias = substr($right, 0, $dotpos);
$rightColumnName = substr($right, $dotpos + 1);
list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias);
-
+
$join->addExplicitCondition(
$leftTableName, $leftColumnName, $leftTableAlias,
$rightTableName, $rightColumnName, $rightTableAlias,
Join::EQUAL);
-
+
$join->setJoinType($joinType);
-
+
return $this->addJoinObject($join);
}
@@ -865,7 +884,7 @@
* @deprecated use Join::setJoinCondition($criterion) instead
*
* @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606
- *
+ *
* Example usage:
* $c->addMultipleJoin(array(
* array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN), // if no third argument, defaults to Criteria::EQUAL
@@ -873,12 +892,13 @@
* ),
* Criteria::LEFT_JOIN
* );
- *
- * @see addJoin()
- * @param array $conditions An array of conditions, each condition being an array (left, right, operator)
- * @param string $joinType A String with the join operator. Defaults to an implicit join.
*
- * @return Criteria A modified Criteria object.
+ * @see addJoin()
+ *
+ * @param array $conditions An array of conditions, each condition being an array (left, right, operator)
+ * @param string $joinType A String with the join operator. Defaults to an implicit join.
+ *
+ * @return Criteria
*/
public function addMultipleJoin($conditions, $joinType = null)
{
@@ -921,17 +941,18 @@
$joinCondition = $joinCondition->addAnd($criterion);
}
}
+
$join->setJoinType($joinType);
$join->setJoinCondition($joinCondition);
+
return $this->addJoinObject($join);
}
-
+
/**
* Add a join object to the Criteria
*
- * @param Join $join A join object
- *
- * @return Criteria A modified Criteria object
+ * @param Join $join A join object
+ * @return Criteria
*/
public function addJoinObject(Join $join)
{
@@ -944,20 +965,21 @@
/**
* Get the array of Joins.
- * @return array Join[]
+ *
+ * @return array|Join[]
*/
public function getJoins()
{
return $this->joins;
}
-
+
/**
* Adds a Criteria as subQuery in the From Clause.
*
- * @param Criteria $subQueryCriteria Criteria to build the subquery from
- * @param string $alias alias for the subQuery
+ * @param Criteria $subQueryCriteria Criteria to build the subquery from
+ * @param string $alias Alias for the subQuery
*
- * @return Criteria this modified Criteria object (Fluid API)
+ * @return Criteria
*/
public function addSelectQuery(Criteria $subQueryCriteria, $alias = null)
{
@@ -965,14 +987,14 @@
$alias = 'alias_' . ($subQueryCriteria->forgeSelectQueryAlias() + count($this->selectQueries));
}
$this->selectQueries[$alias] = $subQueryCriteria;
-
+
return $this;
}
/**
* Checks whether this Criteria has a subquery.
- *
- * @return Boolean
+ *
+ * @return boolean
*/
public function hasSelectQueries()
{
@@ -981,8 +1003,8 @@
/**
* Get the associative array of Criteria for the subQueries per alias.
- *
- * @return array Criteria[]
+ *
+ * @return array|Criteria[]
*/
public function getSelectQueries()
{
@@ -991,9 +1013,9 @@
/**
* Get the Criteria for a specific subQuery.
- *
- * @param string $alias alias for the subQuery
- * @return Criteria
+ *
+ * @param string $alias Alias for the subQuery
+ * @return Criteria
*/
public function getSelectQuery($alias)
{
@@ -1001,10 +1023,10 @@
}
/**
- * checks if the Criteria for a specific subQuery is set.
- *
- * @param string $alias alias for the subQuery
- * @return boolean
+ * Checks if the Criteria for a specific subQuery is set.
+ *
+ * @param string $alias Alias for the subQuery
+ * @return boolean
*/
public function hasSelectQuery($alias)
{
@@ -1017,40 +1039,42 @@
foreach ($this->getSelectQueries() as $c1) {
$aliasNumber += $c1->forgeSelectQueryAlias();
}
+
return ++$aliasNumber;
}
/**
* Adds "ALL" modifier to the SQL statement.
- * @return Criteria Modified Criteria object (for fluent API)
+ *
+ * @return Criteria
*/
public function setAll()
{
$this->removeSelectModifier(self::DISTINCT);
$this->addSelectModifier(self::ALL);
-
+
return $this;
}
/**
* Adds "DISTINCT" modifier to the SQL statement.
- * @return Criteria Modified Criteria object (for fluent API)
+ *
+ * @return Criteria
*/
public function setDistinct()
{
$this->removeSelectModifier(self::ALL);
$this->addSelectModifier(self::DISTINCT);
-
+
return $this;
}
-
+
/**
* Adds a modifier to the SQL statement.
* e.g. self::ALL, self::DISTINCT, 'SQL_CALC_FOUND_ROWS', 'HIGH_PRIORITY', etc.
*
- * @param string $modifier The modifier to add
- *
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param string $modifier The modifier to add
+ * @return Criteria
*/
public function addSelectModifier($modifier)
{
@@ -1058,42 +1082,40 @@
if (!$this->hasSelectModifier($modifier)) {
$this->selectModifiers[] = $modifier;
}
-
+
return $this;
}
-
+
/**
* Removes a modifier to the SQL statement.
* Checks for existence before removal
*
- * @param string $modifier The modifier to add
- *
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param string $modifier The modifier to add
+ * @return Criteria
*/
public function removeSelectModifier($modifier)
{
$this->selectModifiers = array_values(array_diff($this->selectModifiers, array($modifier)));
-
+
return $this;
}
-
+
/**
* Checks the existence of a SQL select modifier
*
- * @param string $modifier The modifier to add
- *
- * @return bool
+ * @param string $modifier The modifier to add
+ * @return boolean
*/
public function hasSelectModifier($modifier)
{
return in_array($modifier, $this->selectModifiers);
}
-
+
/**
* Sets ignore case.
*
- * @param boolean $b True if case should be ignored.
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param boolean $b True if case should be ignored.
+ * @return Criteria
*/
public function setIgnoreCase($b)
{
@@ -1104,7 +1126,7 @@
/**
* Is ignore case on or off?
*
- * @return boolean True if case is ignored.
+ * @return boolean
*/
public function isIgnoreCase()
{
@@ -1120,8 +1142,8 @@
* multiple records but you are only interested in the first one then you
* should be using setLimit(1).
*
- * @param boolean $b Set to TRUE if you expect the query to select just one record.
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param boolean $b Set to TRUE if you expect the query to select just one record.
+ * @return Criteria
*/
public function setSingleRecord($b)
{
@@ -1132,7 +1154,7 @@
/**
* Is single record?
*
- * @return boolean True if a single record is being returned.
+ * @return boolean
*/
public function isSingleRecord()
{
@@ -1142,8 +1164,8 @@
/**
* Set limit.
*
- * @param limit An int with the value for limit.
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param integer $limit An int with the value for limit.
+ * @return Criteria
*/
public function setLimit($limit)
{
@@ -1153,9 +1175,9 @@
}
/**
- * Get limit.
+ * Get an integer with the value for limit.
*
- * @return int An int with the value for limit.
+ * @return integet
*/
public function getLimit()
{
@@ -1165,9 +1187,10 @@
/**
* Set offset.
*
- * @param int $offset An int with the value for offset. (Note this values is
- * cast to a 32bit integer and may result in truncatation)
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param integer $offset An int with the value for offset.
+ * (Note this values is cast to a 32bit integer
+ * and may result in truncatation)
+ * @return Criteria
*/
public function setOffset($offset)
{
@@ -1178,7 +1201,7 @@
/**
* Get offset.
*
- * @return An int with the value for offset.
+ * @return integer
*/
public function getOffset()
{
@@ -1188,56 +1211,56 @@
/**
* Add select column.
*
- * @param string $name Name of the select column.
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param string $name Name of the select column.
+ * @return Criteria
*/
public function addSelectColumn($name)
{
$this->selectColumns[] = $name;
return $this;
}
-
+
/**
* Set the query comment, that appears after the first verb in the SQL query
*
- * @param string $comment The comment to add to the query, without comment sign
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param string $comment The comment to add to the query, without comment sign
+ * @return Criteria
*/
public function setComment($comment = null)
{
$this->queryComment = $comment;
-
+
return $this;
}
-
+
/**
* Get the query comment, that appears after the first verb in the SQL query
*
- * @return string The comment to add to the query, without comment sign
+ * @return string
*/
public function getComment()
{
return $this->queryComment;
}
-
+
/**
* Whether this Criteria has any select columns.
- *
* This will include columns added with addAsColumn() method.
+ *
+ * @see addAsColumn()
+ * @see addSelectColumn()
*
- * @return boolean
- * @see addAsColumn()
- * @see addSelectColumn()
+ * @return boolean
*/
public function hasSelectClause()
{
return (!empty($this->selectColumns) || !empty($this->asColumns));
}
-
+
/**
- * Get select columns.
+ * Get an array with the name of the select columns.
*
- * @return array An array with the name of the select columns.
+ * @return array
*/
public function getSelectColumns()
{
@@ -1247,7 +1270,7 @@
/**
* Clears current select columns.
*
- * @return Criteria Modified Criteria object (for fluent API)
+ * @return Criteria
*/
public function clearSelectColumns()
{
@@ -1256,9 +1279,9 @@
}
/**
- * Get select modifiers.
+ * Get an array with the select modifiers.
*
- * @return An array with the select modifiers.
+ * @return array
*/
public function getSelectModifiers()
{
@@ -1268,8 +1291,8 @@
/**
* Add group by column name.
*
- * @param string $groupBy The name of the column to group by.
- * @return A modified Criteria object.
+ * @param string $groupBy The name of the column to group by.
+ * @return Criteria
*/
public function addGroupByColumn($groupBy)
{
@@ -1280,8 +1303,8 @@
/**
* Add order by column name, explicitly specifying ascending.
*
- * @param name The name of the column to order by.
- * @return A modified Criteria object.
+ * @param string $name The name of the column to order by.
+ * @return Criteria
*/
public function addAscendingOrderByColumn($name)
{
@@ -1292,8 +1315,8 @@
/**
* Add order by column name, explicitly specifying descending.
*
- * @param string $name The name of the column to order by.
- * @return Criteria Modified Criteria object (for fluent API)
+ * @param string $name The name of the column to order by.
+ * @return Criteria
*/
public function addDescendingOrderByColumn($name)
{
@@ -1302,9 +1325,9 @@
}
/**
- * Get order by columns.
+ * Get an array with the name of the order columns.
*
- * @return array An array with the name of the order columns.
+ * @return array
*/
public function getOrderByColumns()
{
@@ -1314,7 +1337,7 @@
/**
* Clear the order-by columns.
*
- * @return Criteria Modified Criteria object (for fluent API)
+ * @return Criteria
*/
public function clearOrderByColumns()
{
@@ -1325,7 +1348,7 @@
/**
* Clear the group-by columns.
*
- * @return Criteria
+ * @return Criteria
*/
public function clearGroupByColumns()
{
@@ -1336,7 +1359,7 @@
/**
* Get group by columns.
*
- * @return array
+ * @return array
*/
public function getGroupByColumns()
{
@@ -1344,29 +1367,30 @@
}
/**
- * Get Having Criterion.
+ * Get the Criterion object that is the having clause.
*
- * @return Criterion A Criterion object that is the having clause.
+ * @return Criterion
*/
public function getHaving()
{
return $this->having;
}
-
+
/**
* Remove an object from the criteria.
*
- * @param string $key A string with the key to be removed.
- * @return mixed The removed value.
+ * @param string $key A string with the key to be removed.
+ * @return mixed
*/
public function remove($key)
{
- if ( isset ( $this->map[$key] ) ) {
+ if (isset ($this->map[$key])) {
$removed = $this->map[$key];
unset ( $this->map[$key] );
if ( $removed instanceof Criterion ) {
return $removed->getValue();
}
+
return $removed;
}
}
@@ -1374,11 +1398,10 @@
/**
* Build a string representation of the Criteria.
*
- * @return string A String with the representation of the Criteria.
+ * @return string
*/
public function toString()
{
-
$sb = "Criteria:";
try {
@@ -1402,18 +1425,21 @@
/**
* Returns the size (count) of this criteria.
- * @return int
+ *
+ * @return integer
*/
public function size()
{
return count($this->map);
}
- /**
- * This method checks another Criteria to see if they contain
- * the same attributes and hashtable entries.
- * @return boolean
- */
+ /**
+ * This method checks another Criteria to see if they contain
+ * the same attributes and hashtable entries.
+ *
+ * @param Criteria $crit
+ * @return boolean
+ */
public function equals($crit)
{
if ($crit === null || !($crit instanceof Criteria)) {
@@ -1465,18 +1491,17 @@
}
return false;
}
-
+
/**
* Add the content of a Criteria to the current Criteria
* In case of conflict, the current Criteria keeps its properties
- *
- * @param Criteria $criteria The criteria to read properties from
- * @param string $operator The logical operator used to combine conditions
- * Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR
- * This parameter is deprecated, use _or() instead
-
*
- * @return Criteria The current criteria object
+ * @param Criteria $criteria The criteria to read properties from
+ * @param string $operator The logical operator used to combine conditions
+ * Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR
+ * This parameter is deprecated, use _or() instead
+ *
+ * @return Criteria
*/
public function mergeWith(Criteria $criteria, $operator = null)
{
@@ -1485,29 +1510,29 @@
if($limit != 0 && $this->getLimit() == 0) {
$this->limit = $limit;
}
-
+
// merge offset
$offset = $criteria->getOffset();
if($offset != 0 && $this->getOffset() == 0) {
$this->offset = $offset;
}
-
+
// merge select modifiers
$selectModifiers = $criteria->getSelectModifiers();
if ($selectModifiers && ! $this->selectModifiers){
$this->selectModifiers = $selectModifiers;
}
-
+
// merge select columns
$this->selectColumns = array_merge($this->getSelectColumns(), $criteria->getSelectColumns());
-
+
// merge as columns
$commonAsColumns = array_intersect_key($this->getAsColumns(), $criteria->getAsColumns());
if (!empty($commonAsColumns)) {
throw new PropelException('The given criteria contains an AsColumn with an alias already existing in the current object');
}
$this->asColumns = array_merge($this->getAsColumns(), $criteria->getAsColumns());
-
+
// merge orderByColumns
$orderByColumns = array_merge($this->getOrderByColumns(), $criteria->getOrderByColumns());
$this->orderByColumns = array_unique($orderByColumns);
@@ -1515,7 +1540,7 @@
// merge groupByColumns
$groupByColumns = array_merge($this->getGroupByColumns(), $criteria->getGroupByColumns());
$this->groupByColumns = array_unique($groupByColumns);
-
+
// merge where conditions
if ($operator == Criteria::LOGICAL_OR) {
$this->_or();
@@ -1532,7 +1557,7 @@
}
$isFirstCondition = false;
}
-
+
// merge having
if ($having = $criteria->getHaving()) {
if ($this->getHaving()) {
@@ -1541,17 +1566,17 @@
$this->addHaving($having);
}
}
-
+
// merge alias
$commonAliases = array_intersect_key($this->getAliases(), $criteria->getAliases());
if (!empty($commonAliases)) {
throw new PropelException('The given criteria contains an alias already existing in the current object');
}
$this->aliases = array_merge($this->getAliases(), $criteria->getAliases());
-
+
// merge join
$this->joins = array_merge($this->getJoins(), $criteria->getJoins());
-
+
return $this;
}
@@ -1567,9 +1592,8 @@
* $crit->addHaving($c);
* </code>
*
- * @param having A Criterion object
- *
- * @return A modified Criteria object.
+ * @param Criterion $having A Criterion object
+ * @return Criteria
*/
public function addHaving(Criterion $having)
{
@@ -1577,20 +1601,25 @@
return $this;
}
- /**
- * If a criterion for the requested column already exists, the condition is "AND"ed to the existing criterion (necessary for Propel 1.4 compatibility).
- * If no criterion for the requested column already exists, the condition is "AND"ed to the latest criterion.
- * If no criterion exist, the condition is added a new criterion
- *
- * Any comparison can be used.
- *
- * Supports a number of different signatures:
- * - addAnd(column, value, comparison)
- * - addAnd(column, value)
- * - addAnd(Criterion)
- *
- * @return Criteria A modified Criteria object.
- */
+ /**
+ * If a criterion for the requested column already exists, the condition is "AND"ed to the existing criterion (necessary for Propel 1.4 compatibility).
+ * If no criterion for the requested column already exists, the condition is "AND"ed to the latest criterion.
+ * If no criterion exist, the condition is added a new criterion
+ *
+ * Any comparison can be used.
+ *
+ * Supports a number of different signatures:
+ * - addAnd(column, value, comparison)
+ * - addAnd(column, value)
+ * - addAnd(Criterion)
+ *
+ * @param Criterion|string $p1
+ * @param mixed $p2
+ * @param mixed $p3
+ * @param boolean $preferColumnCondition
+ *
+ * @return Criteria
+ */
public function addAnd($p1, $p2 = null, $p3 = null, $preferColumnCondition = true)
{
$criterion = ($p1 instanceof Criterion) ? $p1 : new Criterion($this, $p1, $p2, $p3);
@@ -1607,25 +1636,30 @@
return $this;
}
-
- /**
- * If a criterion for the requested column already exists, the condition is "OR"ed to the existing criterion (necessary for Propel 1.4 compatibility).
- * If no criterion for the requested column already exists, the condition is "OR"ed to the latest criterion.
- * If no criterion exist, the condition is added a new criterion
- *
- * Any comparison can be used.
- *
- * Supports a number of different signatures:
- * - addOr(column, value, comparison)
- * - addOr(column, value)
- * - addOr(Criterion)
- *
- * @return Criteria A modified Criteria object.
- */
+
+ /**
+ * If a criterion for the requested column already exists, the condition is "OR"ed to the existing criterion (necessary for Propel 1.4 compatibility).
+ * If no criterion for the requested column already exists, the condition is "OR"ed to the latest criterion.
+ * If no criterion exist, the condition is added a new criterion
+ *
+ * Any comparison can be used.
+ *
+ * Supports a number of different signatures:
+ * - addOr(column, value, comparison)
+ * - addOr(column, value)
+ * - addOr(Criterion)
+ *
+ * @param Criterion|string $p1
+ * @param mixed $p2
+ * @param mixed $p3
+ * @param boolean $preferColumnCondition
+ *
+ * @return Criteria
+ */
public function addOr($p1, $p2 = null, $p3 = null, $preferColumnCondition = true)
{
$rightCriterion = ($p1 instanceof Criterion) ? $p1 : new Criterion($this, $p1, $p2, $p3);
-
+
$key = $rightCriterion->getTable() . '.' . $rightCriterion->getColumn();
if ($preferColumnCondition && $this->containsKey($key)) {
// FIXME: addOr() operates preferably on existing conditions on the same column
@@ -1651,14 +1685,14 @@
* Overrides Criteria::add() to use the default combine operator
* @see Criteria::add()
*
- * @param string|Criterion $p1 The column to run the comparison on (e.g. BookPeer::ID), or Criterion object
- * @param mixed $value
- * @param string $operator A String, like Criteria::EQUAL.
- * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column
- * (necessary for Propel 1.4 compatibility).
- * If false, the condition is combined with the last existing condition.
+ * @param string|Criterion $p1 The column to run the comparison on (e.g. BookPeer::ID), or Criterion object
+ * @param mixed $value
+ * @param string $operator A String, like Criteria::EQUAL.
+ * @param boolean $preferColumnCondition If true, the condition is combined with an existing condition on the same column
+ * (necessary for Propel 1.4 compatibility).
+ * If false, the condition is combined with the last existing condition.
*
- * @return Criteria A modified Criteria object.
+ * @return Criteria
*/
public function addUsingOperator($p1, $value = null, $operator = null, $preferColumnCondition = true)
{
@@ -1669,20 +1703,26 @@
return $this->addAnd($p1, $value, $operator, $preferColumnCondition);
}
}
-
+
// Fluid operators
-
+
+ /**
+ * @return Criteria
+ */
public function _or()
{
$this->defaultCombineOperator = Criteria::LOGICAL_OR;
-
+
return $this;
}
+ /**
+ * @return Criteria
+ */
public function _and()
{
$this->defaultCombineOperator = Criteria::LOGICAL_AND;
-
+
return $this;
}
@@ -1693,9 +1733,9 @@
* or a PropelConditionalProxy instance otherwise.
* Allows for conditional statements in a fluid interface.
*
- * @param bool $cond
+ * @param boolean $cond
*
- * @return PropelConditionalProxy|Criteria
+ * @return PropelConditionalProxy|Criteria
*/
public function _if($cond)
{
@@ -1710,9 +1750,9 @@
* Returns a PropelConditionalProxy instance.
* Allows for conditional statements in a fluid interface.
*
- * @param bool $cond ignored
+ * @param boolean $cond Ignored
*
- * @return PropelConditionalProxy
+ * @return PropelConditionalProxy
*/
public function _elseif($cond)
{
@@ -1723,7 +1763,7 @@
* Returns a PropelConditionalProxy instance.
* Allows for conditional statements in a fluid interface.
*
- * @return PropelConditionalProxy
+ * @return PropelConditionalProxy
*/
public function _else()
{
@@ -1734,13 +1774,13 @@
* Returns the current object
* Allows for conditional statements in a fluid interface.
*
- * @return Criteria
+ * @return Criteria
*/
public function _endif()
{
return $this;
}
-
+
/**
* Ensures deep cloning of attached objects
*/
@@ -1756,5 +1796,4 @@
$this->having = clone $this->having;
}
}
-
}
Index: propel/query/ModelCriteria.php
===================================================================
--- propel/query/ModelCriteria.php (revision 2294)
+++ propel/query/ModelCriteria.php (working copy)
@@ -17,6 +17,9 @@
*
* magic methods:
*
+ * @method ModelCriteria _or()
+ * @method ModelCriteria _and()
+ *
* @method ModelCriteria leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method ModelCriteria rightJoin($relation) Adds a RIGHT JOIN clause to the query
* @method ModelCriteria innerJoin($relation) Adds a INNER JOIN clause to the query
@@ -55,9 +58,9 @@
* Creates a new instance with the default capacity which corresponds to
* the specified database.
*
- * @param string $dbName The dabase name
- * @param string $modelName The phpName of a model, e.g. 'Book'
- * @param string $modelAlias The alias for the model in this query, e.g. 'b'
+ * @param string $dbName The dabase name
+ * @param string $modelName The phpName of a model, e.g. 'Book'
+ * @param string $modelAlias The alias for the model in this query, e.g. 'b'
*/
public function __construct($dbName = null, $modelName, $modelAlias = null)
{
@@ -82,10 +85,10 @@
/**
* Sets the alias for the model in this query
*
- * @param string $modelAlias The model alias
- * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default)
+ * @param string $modelAlias The model alias
+ * @param boolean $useAliasInSQL Whether to use the alias in the SQL code (false by default)
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function setModelAlias($modelAlias, $useAliasInSQL = false)
{
@@ -101,7 +104,7 @@
/**
* Returns the alias of the main class for this model criteria
*
- * @return string The model alias
+ * @return string
*/
public function getModelAlias()
{
@@ -110,8 +113,9 @@
/**
* Return the string to use in a clause as a model prefix for the main model
+ * The model alias if it exists, the model name if not
*
- * @return string The model alias if it exists, the model name if not
+ * @return string
*/
public function getModelAliasOrName()
{
@@ -121,7 +125,7 @@
/**
* Returns the name of the Peer class for this model criteria
*
- * @return string
+ * @return string
*/
public function getModelPeerName()
{
@@ -131,7 +135,7 @@
/**
* Returns the TabkleMap object for this Criteria
*
- * @return TableMap
+ * @return TableMap
*/
public function getTableMap()
{
@@ -142,12 +146,13 @@
* Sets the formatter to use for the find() output
* Formatters must extend PropelFormatter
* Use the ModelCriteria constants for class names:
+ *
* <code>
* $c->setFormatter(ModelCriteria::FORMAT_ARRAY);
* </code>
*
- * @param string|PropelFormatter $formatter a formatter class name, or a formatter instance
- * @return ModelCriteria The current object, for fluid interface
+ * @param string|PropelFormatter $formatter A formatter class name, or a formatter instance
+ * @return ModelCriteria
*/
public function setFormatter($formatter)
{
@@ -166,7 +171,7 @@
* Gets the formatter to use for the find() output
* Defaults to an instance of ModelCriteria::$defaultFormatterClass, i.e. PropelObjectsFormatter
*
- * @return PropelFormatter
+ * @return PropelFormatter
*/
public function getFormatter()
{
@@ -188,11 +193,11 @@
*
* @see Criteria::add()
*
- * @param string $conditionName A name to store the condition for a later combination with combine()
- * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
- * @param mixed $value A value for the condition
+ * @param string $conditionName A name to store the condition for a later combination with combine()
+ * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
+ * @param mixed $value A value for the condition
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function condition($conditionName, $clause, $value = null)
{
@@ -211,11 +216,11 @@
*
* @see Criteria::add()
*
- * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId'
- * @param mixed $value A value for the condition
- * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL
+ * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId'
+ * @param mixed $value A value for the condition
+ * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function filterBy($column, $value, $comparison = Criteria::EQUAL)
{
@@ -235,9 +240,8 @@
*
* @see filterBy()
*
- * @param mixed $conditions An array of conditions, using column phpNames as key
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param mixed $conditions An array of conditions, using column phpNames as key
+ * @return ModelCriteria
*/
public function filterByArray($conditions)
{
@@ -251,6 +255,7 @@
/**
* Adds a condition on a column based on a pseudo SQL clause
* Uses introspection to translate the column phpName into a fully qualified name
+ *
* <code>
* // simple clause
* $c->where('b.Title = ?', 'foo');
@@ -262,11 +267,11 @@
*
* @see Criteria::add()
*
- * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?'
- * Or an array of condition names
- * @param mixed $value A value for the condition
+ * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?'
+ * Or an array of condition names
+ * @param mixed $value A value for the condition
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function where($clause, $value = null)
{
@@ -285,6 +290,7 @@
/**
* Adds a condition on a column based on a pseudo SQL clause
* Uses introspection to translate the column phpName into a fully qualified name
+ *
* <code>
* // simple clause
* $c->orWhere('b.Title = ?', 'foo');
@@ -297,10 +303,10 @@
* @see Criteria::addOr()
* @deprecated Use _or()->where() instead
*
- * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
- * @param mixed $value A value for the condition
+ * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
+ * @param mixed $value A value for the condition
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function orWhere($clause, $value = null)
{
@@ -323,11 +329,11 @@
*
* @see Criteria::addHaving()
*
- * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?'
- * Or an array of condition names
- * @param mixed $value A value for the condition
+ * @param mixed $clause A string representing the pseudo SQL clause, e.g. 'Book.AuthorId = ?'
+ * Or an array of condition names
+ * @param mixed $value A value for the condition
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function having($clause, $value = null)
{
@@ -353,14 +359,15 @@
* $c->orderBy('Book.CategoryId', 'desc')
* => $c->addDescendingOrderByColumn(BookPeer::CATEGORY_ID)
*
- * @param string $columnName The column to order by
- * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC
+ * @param string $columnName The column to order by
+ * @param string $order The sorting order. Criteria::ASC by default,
+ * also accepts Criteria::DESC
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function orderBy($columnName, $order = Criteria::ASC)
{
- list($column, $realColumnName) = $this->getColumnFromName($columnName, false);
+ list(, $realColumnName) = $this->getColumnFromName($columnName, false);
$order = strtoupper($order);
switch ($order) {
case Criteria::ASC:
@@ -384,13 +391,12 @@
* $c->groupBy('Book.AuthorId')
* => $c->addGroupByColumn(BookPeer::AUTHOR_ID)
*
- * @param string $columnName The column to group by
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param string $columnName The column to group by
+ * @return ModelCriteria
*/
public function groupBy($columnName)
{
- list($column, $realColumnName) = $this->getColumnFromName($columnName, false);
+ list(, $realColumnName) = $this->getColumnFromName($columnName, false);
$this->addGroupByColumn($realColumnName);
return $this;
@@ -405,9 +411,8 @@
* => $c->addGroupByColumn(BookPeer::AUTHOR_ID);
* => $c->addGroupByColumn(BookPeer::PUBLISHER_ID);
*
- * @param string $class The class name or alias
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param string $class The class name or alias
+ * @return ModelCriteria
*/
public function groupByClass($class)
{
@@ -420,6 +425,7 @@
} else {
throw new PropelException('Unknown model or alias ' . $class);
}
+
foreach ($tableMap->getColumns() as $column) {
if (isset($this->aliases[$class])) {
$this->addGroupByColumn($class . '.' . $column->getName());
@@ -427,15 +433,15 @@
$this->addGroupByColumn($column->getFullyQualifiedName());
}
}
-
+
return $this;
}
-
+
/**
* Adds a DISTINCT clause to the query
* Alias for Criteria::setDistinct()
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function distinct()
{
@@ -448,9 +454,8 @@
* Adds a LIMIT clause (or its subselect equivalent) to the query
* Alias for Criteria:::setLimit()
*
- * @param int $limit Maximum number of results to return by the query
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param integer $limit Maximum number of results to return by the query
+ * @return ModelCriteria
*/
public function limit($limit)
{
@@ -463,9 +468,8 @@
* Adds an OFFSET clause (or its subselect equivalent) to the query
* Alias for of Criteria::setOffset()
*
- * @param int $offset Offset of the first result to return
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param integer $offset Offset of the first result to return
+ * @return ModelCriteria
*/
public function offset($offset)
{
@@ -492,9 +496,8 @@
* ArticleQuery::create()->select(array('Id', 'Name'))->findOne();
* => array('Id' => 1, 'Name' => 'Foo')
*
- * @param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name')
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param mixed $columnArray A list of column names (e.g. array('Title', 'Category.Name', 'c.Content')) or a single column name (e.g. 'Name')
+ * @return ModelCriteria
*/
public function select($columnArray)
{
@@ -548,7 +551,7 @@
* This method returns the previousJoin for this ModelCriteria,
* by default this is null, but after useQuery this is set the to the join of that use
*
- * @return Join the previousJoin for this ModelCriteria
+ * @return ModelJoin
*/
public function getPreviousJoin()
{
@@ -559,7 +562,7 @@
* This method sets the previousJoin for this ModelCriteria,
* by default this is null, but after useQuery this is set the to the join of that use
*
- * @param Join $previousJoin The previousJoin for this ModelCriteria
+ * @param Join $previousJoin The previousJoin for this ModelCriteria
*/
public function setPreviousJoin(Join $previousJoin)
{
@@ -569,9 +572,8 @@
/**
* This method returns an already defined join clause from the query
*
- * @param string $name The name of the join clause
- *
- * @return Join A join object
+ * @param string $name The name of the join clause
+ * @return Join
*/
public function getJoin($name)
{
@@ -594,10 +596,10 @@
* => $c->addJoin(BookPeer::AUTHOR_ID, 'a.ID', Criteria::RIGHT_JOIN);
* </code>
*
- * @param string $relation Relation to use for the join
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ * @param string $relation Relation to use for the join
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function join($relation, $joinType = Criteria::INNER_JOIN)
{
@@ -648,21 +650,21 @@
return $this;
}
-
+
/**
* Add another condition to an already added join
- * @example
+ *
* <code>
* $query->join('Book.Author');
* $query->addJoinCondition('Author', 'Book.Title LIKE ?', 'foo%');
* </code>
*
- * @param string $name The relation name or alias on which the join was created
- * @param string $clause SQL clause, may contain column and table phpNames
- * @param mixed $value An optional value to bind to the clause
- * @param string $operator The operator to use to add the condition. Defaults to 'AND'
+ * @param string $name The relation name or alias on which the join was created
+ * @param string $clause SQL clause, may contain column and table phpNames
+ * @param mixed $value An optional value to bind to the clause
+ * @param string $operator The operator to use to add the condition. Defaults to 'AND'
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function addJoinCondition($name, $clause, $value = null, $operator = null)
{
@@ -676,13 +678,13 @@
$criterion = $this->getCriterionForClause($clause, $value);
$method = $operator === Criteria::LOGICAL_OR ? 'addOr' : 'addAnd';
$join->getJoinCondition()->$method($criterion);
-
+
return $this;
}
-
+
/**
* Replace the condition of an already added join
- * @example
+ *
* <code>
* $query->join('Book.Author');
* $query->condition('cond1', 'Book.AuthorId = Author.Id')
@@ -691,10 +693,10 @@
* $query->setJoinCondition('Author', 'cond3');
* </code>
*
- * @param string $name The relation name or alias on which the join was created
- * @param mixed $condition A Criterion object, or a condition name
+ * @param string $name The relation name or alias on which the join was created
+ * @param mixed $condition A Criterion object, or a condition name
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function setJoinCondition($name, $condition)
{
@@ -711,13 +713,16 @@
return $this;
}
- /**
- * Add a join object to the Criteria
- * @see Criteria::addJoinObject()
- * @param Join $join A join object
- *
- * @return ModelCriteria The current object, for fluid interface
- */
+ /**
+ * Add a join object to the Criteria
+ *
+ * @see Criteria::addJoinObject()
+ *
+ * @param Join $join A join object
+ * @param string $name
+ *
+ * @return ModelCriteria
+ */
public function addJoinObject(Join $join, $name = null)
{
if (!in_array($join, $this->joins)) { // compare equality, NOT identity
@@ -733,6 +738,7 @@
/**
* Adds a JOIN clause to the query and hydrates the related objects
* Shortcut for $c->join()->with()
+ *
* <code>
* $c->joinWith('Book.Author');
* => $c->join('Book.Author');
@@ -742,10 +748,10 @@
* => $c->with('a');
* </code>
*
- * @param string $relation Relation to use for the join
- * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
+ * @param string $relation Relation to use for the join
+ * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function joinWith($relation, $joinType = Criteria::INNER_JOIN)
{
@@ -759,6 +765,7 @@
* Adds a relation to hydrate together with the main object
* The relation must be initialized via a join() prior to calling with()
* Examples:
+ *
* <code>
* $c->join('Book.Author');
* $c->with('Author');
@@ -766,12 +773,12 @@
* $c->join('Book.Author a', Criteria::RIGHT_JOIN);
* $c->with('a');
* </code>
+ *
* WARNING: on a one-to-many relationship, the use of with() combined with limit()
* will return a wrong number of results for the related objects
*
- * @param string $relation Relation to use for the join
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param string $relation Relation to use for the join
+ * @return ModelCriteria
*/
public function with($relation)
{
@@ -804,6 +811,7 @@
* together with the main object.
*
* @see with()
+ *
* @return array
*/
public function getWith()
@@ -820,13 +828,13 @@
* Adds a supplementary column to the select clause
* These columns can later be retrieved from the hydrated objects using getVirtualColumn()
*
- * @param string $clause The SQL clause with object model column names
- * e.g. 'UPPER(Author.FirstName)'
- * @param string $name Optional alias for the added column
+ * @param string $clause The SQL clause with object model column names
+ * e.g. 'UPPER(Author.FirstName)'
+ * @param string $name Optional alias for the added column
* If no alias is provided, the clause is used as a column alias
* This alias is used for retrieving the column via BaseObject::getVirtualColumn($alias)
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function withColumn($clause, $name = null)
{
@@ -844,15 +852,16 @@
return $this;
}
- /**
- * Initializes a secondary ModelCriteria object, to be later merged with the current object
- *
- * @see ModelCriteria::endUse()
- * @param string $relationName Relation name or alias
- * @param string $secondCriteriaClass Classname for the ModelCriteria to be used
- *
- * @return ModelCriteria The secondary criteria object
- */
+ /**
+ * Initializes a secondary ModelCriteria object, to be later merged with the current object
+ *
+ * @see ModelCriteria::endUse()
+ *
+ * @param string $relationName Relation name or alias
+ * @param string $secondaryCriteriaClass
+ *
+ * @return ModelCriteria
+ */
public function useQuery($relationName, $secondaryCriteriaClass = null)
{
if (!isset($this->joins[$relationName])) {
@@ -877,7 +886,7 @@
*
* @see Criteria::mergeWith()
*
- * @return ModelCriteria The primary criteria object
+ * @return ModelCriteria
*/
public function endUse()
{
@@ -893,13 +902,15 @@
/**
* Add the content of a Criteria to the current Criteria
* In case of conflict, the current Criteria keeps its properties
+ *
* @see Criteria::mergeWith()
*
- * @param Criteria $criteria The criteria to read properties from
- * @param string $operator The logical operator used to combine conditions
- * Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR
+ * @param Criteria $criteria The criteria to read properties from
+ * @param string $operator The logical operator used to combine conditions
+ * Defaults to Criteria::LOGICAL_AND,
+ * also accapts Criteria::LOGICAL_OR
*
- * @return ModelCriteria The primary criteria object
+ * @return ModelCriteria
*/
public function mergeWith(Criteria $criteria, $operator = null)
{
@@ -917,7 +928,7 @@
* Clear the conditions to allow the reuse of the query object.
* The ModelCriteria's Model and alias 'all the properties set by construct) will remain.
*
- * @return ModelCriteria The primary criteria object
+ * @return ModelCriteria
*/
public function clear()
{
@@ -932,8 +943,8 @@
/**
* Sets the primary Criteria for this secondary Criteria
*
- * @param ModelCriteria $criteria The primary criteria
- * @param Join $previousJoin The previousJoin for this ModelCriteria
+ * @param ModelCriteria $criteria The primary criteria
+ * @param Join $previousJoin The previousJoin for this ModelCriteria
*/
public function setPrimaryCriteria(ModelCriteria $criteria, Join $previousJoin)
{
@@ -944,23 +955,23 @@
/**
* Gets the primary criteria for this secondary Criteria
*
- * @return ModelCriteria The primary criteria
+ * @return ModelCriteria
*/
public function getPrimaryCriteria()
{
return $this->primaryCriteria;
}
-
+
/**
* Adds a Criteria as subQuery in the From Clause.
- *
+ *
* @see Criteria::addSelectQuery()
*
- * @param Criteria $subQueryCriteria Criteria to build the subquery from
- * @param string $alias alias for the subQuery
- * @param boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns
+ * @param Criteria $subQueryCriteria Criteria to build the subquery from
+ * @param string $alias Alias for the subQuery
+ * @param boolean $addAliasAndSelectColumns Set to false if you want to manually add the aliased select columns
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function addSelectQuery(Criteria $subQueryCriteria, $alias = null, $addAliasAndSelectColumns = true)
{
@@ -980,11 +991,11 @@
}
return $this;
}
-
+
/**
* Adds the select columns for a the current table
*
- * @return ModelCriteria The current object, for fluid interface
+ * @return ModelCriteria
*/
public function addSelfSelectColumns()
{
@@ -996,9 +1007,8 @@
/**
* Adds the select columns for a relation
*
- * @param string $relation The relation name or alias, as defined in join()
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param string $relation The relation name or alias, as defined in join()
+ * @return ModelCriteria
*/
public function addRelationSelectColumns($relation)
{
@@ -1013,9 +1023,8 @@
* e.g. 'Book b' => array('Book', 'b')
* e.g. 'Book' => array('Book', null)
*
- * @param string $class The classname to explode
- *
- * @return array list($className, $aliasName)
+ * @param string $class The classname to explode
+ * @return array
*/
public static function getClassAndAlias($class)
{
@@ -1031,8 +1040,8 @@
* Returns the name of a relation from a string.
* The input looks like '$leftName.$relationName $relationAlias'
*
- * @param string $relation Relation to use for the join
- * @return string the relationName used in the join
+ * @param string $relation Relation to use for the join
+ * @return string
*/
public static function getRelationName($relation)
{
@@ -1055,9 +1064,8 @@
* even though they modify it. If the query must be reused after termination,
* you must call this method prior to temrination.
*
- * @param boolean $isKeepQuery
- *
- * @return ModelCriteria The current object, for fluid interface
+ * @param boolean $isKeepQuery
+ * @return ModelCriteria
*/
public function keepQuery($isKeepQuery = true)
{
@@ -1068,8 +1076,9 @@
/**
* Checks whether the automated cloning on termination is enabled.
+ * True if cloning must be done before termination
*
- * @return boolean true if cloning must be done before termination
+ * @return boolean
*/
public function isKeepQuery()
{
@@ -1079,7 +1088,7 @@
/**
* Code to execute before every SELECT statement
*
- * @param PropelPDO $con The connection object used by the query
+ * @param PropelPDO $con The connection object used by the query
*/
protected function basePreSelect(PropelPDO $con)
{
@@ -1095,9 +1104,8 @@
* and format the list of results with the current formatter
* By default, returns an array of model objects
*
- * @param PropelPDO $con an optional connection object
- *
- * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
+ * @param PropelPDO $con An optional connection object
+ * @return PropelObjectCollection|array
*/
public function find($con = null)
{
@@ -1112,9 +1120,8 @@
* and format the result with the current formatter
* By default, returns a model object
*
- * @param PropelPDO $con an optional connection object
- *
- * @return mixed the result, formatted by the current formatter
+ * @param PropelPDO $con An optional connection object
+ * @return mixed
*/
public function findOne($con = null)
{
@@ -1130,9 +1137,8 @@
* and format the result with the current formatter
* By default, returns a model object
*
- * @param PropelPDO $con an optional connection object
- *
- * @return mixed the result, formatted by the current formatter
+ * @param PropelPDO $con An optional connection object
+ * @return mixed
*/
public function findOneOrCreate($con = null)
{
@@ -1146,22 +1152,25 @@
}
$ret = $this->getFormatter()->formatRecord($obj);
}
+
return $ret;
}
/**
* Find object by primary key
* Behaves differently if the model has simple or composite primary key
+ *
* <code>
* // simple primary key
* $book = $c->findPk(12, $con);
* // composite primary key
* $bookOpinion = $c->findPk(array(34, 634), $con);
* </code>
- * @param mixed $key Primary key to use for the query
- * @param PropelPDO $con an optional connection object
+ *
+ * @param mixed $key Primary key to use for the query
+ * @param PropelPDO $con An optional connection object
*
- * @return mixed the result, formatted by the current formatter
+ * @return mixed
*/
public function findPk($key, $con = null)
{
@@ -1184,16 +1193,18 @@
/**
* Find objects by primary key
* Behaves differently if the model has simple or composite primary key
+ *
* <code>
* // simple primary key
* $books = $c->findPks(array(12, 56, 832), $con);
* // composite primary key
* $bookOpinion = $c->findPks(array(array(34, 634), array(45, 518), array(34, 765)), $con);
* </code>
- * @param array $keys Primary keys to use for the query
- * @param PropelPDO $con an optional connection object
+ *
+ * @param array $keys Primary keys to use for the query
+ * @param PropelPDO $con An optional connection object
*
- * @return mixed the list of results, formatted by the current formatter
+ * @return mixed
*/
public function findPks($keys, $con = null)
{
@@ -1209,6 +1220,12 @@
return $this->find($con);
}
+ /**
+ * @throws PropelException
+ * @param PropelPDO $con
+ *
+ * @return PDOStatement
+ */
protected function getSelectStatement($con = null)
{
$dbMap = Propel::getDatabaseMap($this->getDbName());
@@ -1228,10 +1245,13 @@
$this->basePreSelect($con);
$params = array();
$sql = BasePeer::createSelectSql($this, $params);
+
+ /** @var $stmt PDOStatement */
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
if (isset($stmt)) {
$stmt = null; // close
}
@@ -1565,7 +1585,7 @@
*
* @param array $values The associatiove array of columns and values for the update
* @param PropelPDO $con The connection object used by the query
- * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
+ * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
*/
protected function basePreUpdate(&$values, PropelPDO $con, $forceIndividualSaves = false)
{
@@ -1597,11 +1617,11 @@
* Beware that behaviors based on hooks in the object's save() method
* will only be triggered if you force individual saves, i.e. if you pass true as second argument.
*
- * @param array $values Associative array of keys and values to replace
- * @param PropelPDO $con an optional connection object
- * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
+ * @param array $values Associative array of keys and values to replace
+ * @param PropelPDO $con an optional connection object
+ * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
*
- * @return Integer Number of updated rows
+ * @return Integer Number of updated rows
*/
public function update($values, $con = null, $forceIndividualSaves = false)
{
@@ -1640,11 +1660,11 @@
* Issue an UPDATE query based the current ModelCriteria and a list of changes.
* This method is called by ModelCriteria::update() inside a transaction.
*
- * @param array $values Associative array of keys and values to replace
- * @param PropelPDO $con a connection object
- * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
+ * @param array $values Associative array of keys and values to replace
+ * @param PropelPDO $con a connection object
+ * @param boolean $forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
*
- * @return Integer Number of updated rows
+ * @return Integer Number of updated rows
*/
public function doUpdate($values, $con, $forceIndividualSaves = false)
{
@@ -1679,10 +1699,10 @@
/**
* Creates a Criterion object based on a list of existing condition names and a comparator
*
- * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2')
- * @param string $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR
+ * @param array $conditions The list of condition names, e.g. array('cond1', 'cond2')
+ * @param string $operator An operator, Criteria::LOGICAL_AND (default) or Criteria::LOGICAL_OR
*
- * @return Criterion a Criterion or ModelCriterion object
+ * @return Criterion a Criterion or ModelCriterion object
*/
protected function getCriterionForConditions($conditions, $operator = null)
{
@@ -1698,10 +1718,10 @@
* Creates a Criterion object based on a SQL clause and a value
* Uses introspection to translate the column phpName into a fully qualified name
*
- * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
- * @param mixed $value A value for the condition
+ * @param string $clause The pseudo SQL clause, e.g. 'AuthorId = ?'
+ * @param mixed $value A value for the condition
*
- * @return Criterion a Criterion or ModelCriterion object
+ * @return Criterion a Criterion or ModelCriterion object
*/
protected function getCriterionForClause($clause, $value)
{
@@ -1733,7 +1753,7 @@
}
return $criterion;
}
-
+
/**
* Converts value for some column types
*
@@ -1758,7 +1778,7 @@
$value = $colMap->getValueSetKey($value);
}
}
-
+
return $value;
}
@@ -1819,7 +1839,7 @@
if ($stringToTransform) {
$parsedString .= preg_replace_callback('/\w+\.\w+/', array($this, 'doReplaceNameInExpression'), $stringToTransform);
}
-
+
$clause = $parsedString;
return $this->foundMatch;
}
@@ -1858,9 +1878,9 @@
* => array($authorFirstNameColumnMap, 'a.FIRST_NAME')
* </code>
*
- * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title'
+ * @param string $phpName String representing the column name in a pseudo SQL clause, e.g. 'Book.Title'
*
- * @return array List($columnMap, $realColumnName)
+ * @return array List($columnMap, $realColumnName)
*/
protected function getColumnFromName($phpName, $failSilently = true)
{
@@ -1906,7 +1926,7 @@
/**
* Special case for subquery columns
*
- * @return array List($columnMap, $realColumnName)
+ * @return array List($columnMap, $realColumnName)
*/
protected function getColumnFromSubQuery($class, $phpName, $failSilently = true)
{
@@ -1925,7 +1945,7 @@
throw new PropelException(sprintf('Unknown column "%s" in the subQuery with alias "%s"', $phpName, $class));
}
}
-
+
/**
* Return a fully qualified column name corresponding to a simple column phpName
* Uses model alias if it exists
@@ -1970,11 +1990,11 @@
* Overrides Criteria::add() to force the use of a true table alias if it exists
*
* @see Criteria::add()
- * @param string $column The colName of column to run the condition on (e.g. BookPeer::ID)
- * @param mixed $value
- * @param string $operator A String, like Criteria::EQUAL.
+ * @param string $column The colName of column to run the condition on (e.g. BookPeer::ID)
+ * @param mixed $value
+ * @param string $operator A String, like Criteria::EQUAL.
*
- * @return ModelCriteria A modified Criteria object.
+ * @return ModelCriteria A modified Criteria object.
*/
public function addUsingAlias($p1, $value = null, $operator = null)
{
Index: propel/query/PropelQuery.php
===================================================================
--- propel/query/PropelQuery.php (revision 2294)
+++ propel/query/PropelQuery.php (working copy)
@@ -10,13 +10,22 @@
/**
* Factory for model queries
- *
+ *
+ * @method boolean mergeWith(Criteria $criteria)
+ * @method boolean setModelAlias($alias)
+ *
* @author François Zaninotto
* @version $Revision$
* @package propel.runtime.query
*/
class PropelQuery
{
+ /**
+ * @param $queryClassAndAlias
+ *
+ * @throws PropelException
+ * @return PropelQuery
+ */
public static function from($queryClassAndAlias)
{
list($class, $alias) = ModelCriteria::getClassAndAlias($queryClassAndAlias);
@@ -24,6 +33,7 @@
if (!class_exists($queryClass)) {
throw new PropelException('Cannot find a query class for ' . $class);
}
+ /** @var $query PropelQuery */
$query = new $queryClass();
if ($alias !== null) {
$query->setModelAlias($alias);
Index: propel/query/CriterionIterator.php
===================================================================
--- propel/query/CriterionIterator.php (revision 2294)
+++ propel/query/CriterionIterator.php (working copy)
@@ -7,7 +7,7 @@
*
* @license MIT License
*/
-
+
/**
* Class that implements SPL Iterator interface. This allows foreach () to
* be used w/ Criteria objects. Probably there is no performance advantage
@@ -25,6 +25,9 @@
private $criteriaKeys;
private $criteriaSize;
+ /**
+ * @param Criteria $criteria
+ */
public function __construct(Criteria $criteria) {
$this->criteria = $criteria;
$this->criteriaKeys = $criteria->keys();
@@ -35,6 +38,9 @@
$this->idx = 0;
}
+ /**
+ * @return boolean
+ */
public function valid() {
return $this->idx < $this->criteriaSize;
}
@@ -50,5 +56,4 @@
public function next() {
$this->idx++;
}
-
}
Index: propel/validator/MinLengthValidator.php
===================================================================
--- propel/validator/MinLengthValidator.php (revision 2294)
+++ propel/validator/MinLengthValidator.php (working copy)
@@ -25,11 +25,15 @@
*/
class MinLengthValidator implements BasicValidator
{
-
- /**
- * @see BasicValidator::isValid()
- */
- public function isValid (ValidatorMap $map, $str)
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $str)
{
$len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str);
return $len >= intval($map->getValue());
Index: propel/validator/UniqueValidator.php
===================================================================
--- propel/validator/UniqueValidator.php (revision 2294)
+++ propel/validator/UniqueValidator.php (working copy)
@@ -25,11 +25,15 @@
*/
class UniqueValidator implements BasicValidator
{
-
- /**
- * @see BasicValidator::isValid()
- */
- public function isValid (ValidatorMap $map, $str)
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $str)
{
$column = $map->getColumn();
Index: propel/validator/MaxLengthValidator.php
===================================================================
--- propel/validator/MaxLengthValidator.php (revision 2294)
+++ propel/validator/MaxLengthValidator.php (working copy)
@@ -31,8 +31,13 @@
*/
class MaxLengthValidator implements BasicValidator
{
-
- public function isValid (ValidatorMap $map, $str)
+ /**
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $str)
{
$len = function_exists('mb_strlen') ? mb_strlen($str) : strlen($str);
return $len <= intval($map->getValue());
Index: propel/validator/MatchValidator.php
===================================================================
--- propel/validator/MatchValidator.php (revision 2294)
+++ propel/validator/MatchValidator.php (working copy)
@@ -58,9 +58,14 @@
return $exp;
}
- /**
- * Whether the passed string matches regular expression.
- */
+ /**
+ * Whether the passed string matches regular expression.
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
public function isValid (ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) != 0);
Index: propel/validator/NotMatchValidator.php
===================================================================
--- propel/validator/NotMatchValidator.php (revision 2294)
+++ propel/validator/NotMatchValidator.php (working copy)
@@ -40,8 +40,9 @@
/**
* Prepares the regular expression entered in the XML
* for use with preg_match().
- * @param string $exp
- * @return string Prepared regular expession.
+ *
+ * @param string $exp
+ * @return string
*/
private function prepareRegexp($exp)
{
@@ -57,9 +58,14 @@
}
/**
- * Whether the passed string matches regular expression.
- */
- public function isValid (ValidatorMap $map, $str)
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $str)
{
return (preg_match($this->prepareRegexp($map->getValue()), $str) == 0);
}
Index: propel/validator/ValidValuesValidator.php
===================================================================
--- propel/validator/ValidValuesValidator.php (revision 2294)
+++ propel/validator/ValidValuesValidator.php (working copy)
@@ -25,8 +25,15 @@
*/
class ValidValuesValidator implements BasicValidator
{
-
- public function isValid (ValidatorMap $map, $str)
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $str)
{
return in_array($str, preg_split("/[|,]/", $map->getValue()));
}
Index: propel/validator/MinValueValidator.php
===================================================================
--- propel/validator/MinValueValidator.php (revision 2294)
+++ propel/validator/MinValueValidator.php (working copy)
@@ -28,11 +28,15 @@
*/
class MinValueValidator implements BasicValidator
{
-
- /**
- * @see BasicValidator::isValid()
- */
- public function isValid (ValidatorMap $map, $value)
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param mixed $value
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value)) {
return intval($value) >= intval($map->getValue());
Index: propel/validator/RequiredValidator.php
===================================================================
--- propel/validator/RequiredValidator.php (revision 2294)
+++ propel/validator/RequiredValidator.php (working copy)
@@ -27,10 +27,14 @@
*/
class RequiredValidator implements BasicValidator
{
-
- /**
- * @see BasicValidator::isValid()
- */
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param string $str
+ *
+ * @return boolean
+ */
public function isValid (ValidatorMap $map, $str)
{
return ($str !== null && $str !== "");
Index: propel/validator/TypeValidator.php
===================================================================
--- propel/validator/TypeValidator.php (revision 2294)
+++ propel/validator/TypeValidator.php (working copy)
@@ -25,6 +25,14 @@
*/
class TypeValidator implements BasicValidator
{
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param mixed $value
+ *
+ * @return boolean
+ */
public function isValid(ValidatorMap $map, $value)
{
switch ($map->getValue()) {
Index: propel/validator/MaxValueValidator.php
===================================================================
--- propel/validator/MaxValueValidator.php (revision 2294)
+++ propel/validator/MaxValueValidator.php (working copy)
@@ -28,11 +28,15 @@
*/
class MaxValueValidator implements BasicValidator
{
-
- /**
- * @see BasicValidator::isValid()
- */
- public function isValid (ValidatorMap $map, $value)
+ /**
+ * @see BasicValidator::isValid()
+ *
+ * @param ValidatorMap $map
+ * @param mixed $value
+ *
+ * @return boolean
+ */
+ public function isValid(ValidatorMap $map, $value)
{
if (is_null($value) == false && is_numeric($value) == true) {
return intval($value) <= intval($map->getValue());
Index: propel/Propel.php
===================================================================
--- propel/Propel.php (revision 2294)
+++ propel/Propel.php (working copy)
@@ -31,7 +31,7 @@
* The Propel version.
*/
const VERSION = '1.6.1-dev';
-
+
/**
* A constant for <code>default</code>.
*/
@@ -156,7 +156,7 @@
* @var string Base directory to use for autoloading. Initialized in self::initBaseDir()
*/
protected static $baseDir;
-
+
/**
* @var array A map of class names and their file paths for autoloading
*/
@@ -190,7 +190,7 @@
'DebugPDOStatement' => 'connection/DebugPDOStatement.php',
'PropelException' => 'exception/PropelException.php',
-
+
'ModelWith' => 'formatter/ModelWith.php',
'PropelArrayFormatter' => 'formatter/PropelArrayFormatter.php',
'PropelFormatter' => 'formatter/PropelFormatter.php',
@@ -198,7 +198,7 @@
'PropelOnDemandFormatter' => 'formatter/PropelOnDemandFormatter.php',
'PropelStatementFormatter' => 'formatter/PropelStatementFormatter.php',
'PropelSimpleArrayFormatter' => 'formatter/PropelSimpleArrayFormatter.php',
-
+
'BasicLogger' => 'logger/BasicLogger.php',
'MojaviLogAdapter' => 'logger/MojaviLogAdapter.php',
@@ -220,7 +220,7 @@
'PropelParser' => 'parser/PropelParser.php',
'PropelXMLParser' => 'parser/PropelXMLParser.php',
'PropelYAMLParser' => 'parser/PropelYAMLParser.php',
-
+
'Criteria' => 'query/Criteria.php',
'Criterion' => 'query/Criterion.php',
'CriterionIterator' => 'query/CriterionIterator.php',
@@ -269,19 +269,19 @@
// reset the connection map (this should enable runtime changes of connection params)
self::$connectionMap = array();
-
+
if (isset(self::$configuration['classmap']) && is_array(self::$configuration['classmap'])) {
PropelAutoloader::getInstance()->addClassPaths(self::$configuration['classmap']);
PropelAutoloader::getInstance()->register();
}
-
+
self::$isInit = true;
}
/**
* Configure Propel a PHP (array) config file.
*
- * @param string Path (absolute or relative to include_path) to config file.
+ * @param string $configFile Path (absolute or relative to include_path) to config file.
*
* @throws PropelException If configuration file cannot be opened.
* (E_WARNING probably will also be raised by PHP)
@@ -341,7 +341,7 @@
/**
* Sets the configuration for Propel and all dependencies.
*
- * @param mixed The Configuration (array or PropelConfiguration)
+ * @param mixed $c The Configuration (array or PropelConfiguration)
*/
public static function setConfiguration($c)
{
@@ -357,11 +357,11 @@
/**
* Get the configuration for this component.
*
- * @param int - PropelConfiguration::TYPE_ARRAY: return the configuration as an array
- * (for backward compatibility this is the default)
- * - PropelConfiguration::TYPE_ARRAY_FLAT: return the configuration as a flat array
- * ($config['name.space.item'])
- * - PropelConfiguration::TYPE_OBJECT: return the configuration as a PropelConfiguration instance
+ * @param int $type - PropelConfiguration::TYPE_ARRAY: return the configuration as an array
+ * (for backward compatibility this is the default)
+ * - PropelConfiguration::TYPE_ARRAY_FLAT: return the configuration as a flat array
+ * ($config['name.space.item'])
+ * - PropelConfiguration::TYPE_OBJECT: return the configuration as a PropelConfiguration instance
* @return mixed The Configuration (array or PropelConfiguration)
*/
public static function getConfiguration($type = PropelConfiguration::TYPE_ARRAY)
@@ -379,7 +379,7 @@
* interface. This interface is based on PEAR::Log, so you can also simply pass
* a PEAR::Log object to this method.
*
- * @param object The new logger to use. ([PEAR] Log or BasicLogger)
+ * @param object $logger The new logger to use. ([PEAR] Log or BasicLogger)
*/
public static function setLogger($logger)
{
@@ -400,7 +400,7 @@
/**
* Get the configured logger.
*
- * @return object Configured log class ([PEAR] Log or BasicLogger).
+ * @return Log|BasicLogger Configured log class ([PEAR] Log or BasicLogger).
*/
public static function logger()
{
@@ -409,11 +409,12 @@
/**
* Logs a message
- * If a logger has been configured, the logger will be used, otherwrise the
+ *
+ * If a logger has been configured, the logger will be used, otherwrise the
* logging message will be discarded without any further action
*
- * @param string The message that will be logged.
- * @param string The logging level.
+ * @param string $message The message that will be logged.
+ * @param integer $level The logging level.
*
* @return bool True if the message was logged successfully or no logger was used.
*/
@@ -449,7 +450,7 @@
*
* The database maps are "registered" by the generated map builder classes.
*
- * @param string The name of the database corresponding to the DatabaseMap to retrieve.
+ * @param string $name The name of the database corresponding to the DatabaseMap to retrieve.
*
* @return DatabaseMap The named <code>DatabaseMap</code>.
*
@@ -550,12 +551,12 @@
return self::getSlaveConnection($name);
}
- }
-
+ }
+
/**
* Gets an already-opened write PDO connection or opens a new one for passed-in db name.
*
- * @param string $name The datasource name that is used to look up the DSN
+ * @param string $name The datasource name that is used to look up the DSN
* from the runtime configuation file. Empty name not allowed.
*
* @return PDO A database connection
@@ -566,7 +567,7 @@
{
if (!isset(self::$connectionMap[$name]['master'])) {
// load connection parameter for master connection
- $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
+ $conparams = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : array();
if (empty($conparams)) {
throw new PropelException('No connection information in your runtime configuration file for datasource ['.$name.']');
}
@@ -577,11 +578,11 @@
return self::$connectionMap[$name]['master'];
}
-
+
/**
* Gets an already-opened read PDO connection or opens a new one for passed-in db name.
*
- * @param string $name The datasource name that is used to look up the DSN
+ * @param string $name The datasource name that is used to look up the DSN
* from the runtime configuation file. Empty name not allowed.
*
* @return PDO A database connection
@@ -622,14 +623,14 @@
return self::$connectionMap[$name]['slave'];
}
-
+
/**
* Opens a new PDO connection for passed-in db name.
*
* @param array $conparams Connection paramters.
* @param string $name Datasource name.
* @param string $defaultClass The PDO subclass to instantiate if there is no explicit classname
- * specified in the connection params (default is Propel::CLASS_PROPEL_PDO)
+ * specified in the connection params (default is Propel::CLASS_PROPEL_PDO)
*
* @return PDO A database connection of the given class (PDO, PropelPDO, SlavePDO or user-defined)
*
@@ -637,7 +638,6 @@
*/
public static function initConnection($conparams, $name, $defaultClass = Propel::CLASS_PROPEL_PDO)
{
-
$dsn = $conparams['dsn'];
if ($dsn === null) {
throw new PropelException('No dsn specified in your connection parameters for datasource ['.$name.']');
@@ -667,11 +667,9 @@
}
try {
+ /** @var $con PropelPDO */
$con = new $classname($dsn, $user, $password, $driver_options);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- if (Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT)->getParameter('debugpdo.logging.enabled', false)) {
- $con->useLogging(true);
- }
} catch (PDOException $e) {
throw new PropelException("Unable to open PDO connection", $e);
}
@@ -702,8 +700,8 @@
*
* Process the INI file flags to be passed to each connection.
*
- * @param array Where to find the list of constant flags and their new setting.
- * @param array Put the data into here
+ * @param array $source Where to find the list of constant flags and their new setting.
+ * @param array $write_to Put the data into here
*
* @throws PropelException If invalid options were specified.
*/
@@ -714,7 +712,10 @@
$key = $option;
} elseif (is_string($option)) {
$key = 'PropelPDO::' . $option;
- }
+ } else {
+ $key = null;
+ }
+
if (!defined($key)) {
throw new PropelException("Invalid PDO option/attribute name specified: ".$key);
}
@@ -735,7 +736,7 @@
/**
* Returns database adapter for a specific datasource.
*
- * @param string The datasource name.
+ * @param string $name The datasource name.
*
* @return DBAdapter The corresponding database adapter.
*
@@ -804,7 +805,7 @@
/**
* Autoload function for loading propel dependencies.
*
- * @param string The class name needing loading.
+ * @param string $className The class name needing loading.
*
* @return boolean TRUE if the class was loaded, false otherwise.
*/
@@ -816,7 +817,7 @@
}
return false;
}
-
+
/**
* Initialize the base directory for the autoloader.
* Avoids a call to dirname(__FILE__) each time self::autoload() is called.
@@ -836,7 +837,7 @@
* classname of a validator in the schema.xml. This method will attempt to include that
* class via autoload and then relative to a location on the include_path.
*
- * @param string $class dot-path to clas (e.g. path.to.my.ClassName).
+ * @param string $path dot-path to clas (e.g. path.to.my.ClassName).
* @return string unqualified classname
*/
public static function importClass($path) {
@@ -849,7 +850,7 @@
}
// check if class exists, using autoloader to attempt to load it.
- if (class_exists($class, $useAutoload=true)) {
+ if (class_exists($class, true)) {
return $class;
}
@@ -866,13 +867,13 @@
return $class;
}
- /**
- * Set your own class-name for Database-Mapping. Then
- * you can change the whole TableMap-Model, but keep its
- * functionality for Criteria.
- *
- * @param string The name of the class.
- */
+ /**
+ * Set your own class-name for Database-Mapping. Then
+ * you can change the whole TableMap-Model, but keep its
+ * functionality for Criteria.
+ *
+ * @param string $name The name of the class.
+ */
public static function setDatabaseMapClass($name)
{
self::$databaseMapClass = $name;
@@ -880,7 +881,7 @@
/**
* Disable instance pooling.
- *
+ *
* @return boolean true if the method changed the instance pooling state,
* false if it was already disabled
*/
@@ -895,7 +896,7 @@
/**
* Enable instance pooling (enabled by default).
- *
+ *
* @return boolean true if the method changed the instance pooling state,
* false if it was already enabled
*/
Index: propel/collection/PropelArrayCollection.php
===================================================================
--- propel/collection/PropelArrayCollection.php (revision 2294)
+++ propel/collection/PropelArrayCollection.php (working copy)
@@ -18,9 +18,11 @@
{
protected $workerObject;
- /**
- * Save all the elements in the collection
- */
+ /**
+ * Save all the elements in the collection
+ *
+ * @param PropelPDO $con
+ */
public function save($con = null)
{
if (null === $con) {
@@ -40,10 +42,12 @@
$con->rollback();
}
}
-
- /**
- * Delete all the elements in the collection
- */
+
+ /**
+ * Delete all the elements in the collection
+ *
+ * @param PropelPDO $con
+ */
public function delete($con = null)
{
if (null === $con) {
@@ -64,11 +68,12 @@
}
}
- /**
- * Get an array of the primary keys of all the objects in the collection
- *
- * @return array The list of the primary keys of the collection
- */
+ /**
+ * Get an array of the primary keys of all the objects in the collection
+ *
+ * @param boolean $usePrefix
+ * @return array The list of the primary keys of the collection
+ */
public function getPrimaryKeys($usePrefix = true)
{
$callable = array($this->getPeerClass(), 'getPrimaryKeyFromRow');
@@ -77,7 +82,7 @@
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key]= call_user_func($callable, array_values($element));
}
-
+
return $ret;
}
@@ -86,7 +91,7 @@
* Uses the object model to force the column types
* Does not empty the collection before adding the data from the array
*
- * @param array $arr
+ * @param array $arr
*/
public function fromArray($arr)
{
@@ -97,15 +102,15 @@
$this->append($obj->toArray());
}
}
-
+
/**
* Get an array representation of the collection
* This is not an alias for getData(), since it returns a copy of the data
*
- * @param string $keyColumn If null, the returned array uses an incremental index.
- * Otherwise, the array is indexed using the specified column
- * @param boolean $usePrefix If true, the returned array prefixes keys
- * with the model class name ('Article_0', 'Article_1', etc).
+ * @param string $keyColumn If null, the returned array uses an incremental index.
+ * Otherwise, the array is indexed using the specified column
+ * @param boolean $usePrefix If true, the returned array prefixes keys
+ * with the model class name ('Article_0', 'Article_1', etc).
*
* <code>
* $bookCollection->toArray();
@@ -124,6 +129,7 @@
* 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'),
* )
* </code>
+ *
* @return array
*/
public function toArray($keyColumn = null, $usePrefix = false)
@@ -137,10 +143,15 @@
return $ret;
}
-
- /**
- * Synonym for toArray(), to provide a similar interface to PopelObjectCollection
- */
+
+ /**
+ * Synonym for toArray(), to provide a similar interface to PopelObjectCollection
+ *
+ * @param string $keyColumn
+ * @param boolean $usePrefix
+ *
+ * @return array
+ */
public function getArrayCopy($keyColumn = null, $usePrefix = false)
{
if (null === $keyColumn && false === $usePrefix) {
@@ -149,27 +160,34 @@
return $this->toArray($keyColumn, $usePrefix);
}
}
-
- /**
- * Get an associative array representation of the collection
- * The first parameter specifies the column to be used for the key,
- * And the seconf for the value.
- * <code>
- * $res = $coll->toKeyValue('Id', 'Name');
- * </code>
- *
- * @return array
- */
+
+ /**
+ * Get an associative array representation of the collection
+ * The first parameter specifies the column to be used for the key,
+ * And the seconf for the value.
+ * <code>
+ * $res = $coll->toKeyValue('Id', 'Name');
+ * </code>
+ *
+ * @param string $keyColumn
+ * @param string $valueColumn
+ *
+ * @return array
+ */
public function toKeyValue($keyColumn, $valueColumn)
{
$ret = array();
foreach ($this as $obj) {
$ret[$obj[$keyColumn]] = $obj[$valueColumn];
}
-
+
return $ret;
}
+ /**
+ * @throws PropelException
+ * @return BaseObject
+ */
protected function getWorkerObject()
{
if (null === $this->workerObject) {
@@ -179,10 +197,7 @@
$class = $this->getModel();
$this->workerObject = new $class();
}
-
+
return $this->workerObject;
}
-
}
-
-?>
\ No newline at end of file
Index: propel/collection/PropelCollection.php
===================================================================
--- propel/collection/PropelCollection.php (revision 2294)
+++ propel/collection/PropelCollection.php (working copy)
@@ -12,10 +12,13 @@
* Class for iterating over a list of Propel elements
* The collection keys must be integers - no associative array accepted
*
+ * @method PropelCollection fromArray(array $data) Populate the collection from an Array
* @method PropelCollection fromXML(string $data) Populate the collection from an XML string
* @method PropelCollection fromYAML(string $data) Populate the collection from a YAML string
* @method PropelCollection fromJSON(string $data) Populate the collection from a JSON string
* @method PropelCollection fromCSV(string $data) Populate the collection from a CSV string
+ *
+ * @method array toArray() Export the collection to an Array
* @method string toXML() Export the collection to an XML string
* @method string toYAML() Export the collection to a YAML string
* @method string toJSON() Export the collection to a JSON string
@@ -26,13 +29,23 @@
*/
class PropelCollection extends ArrayObject implements Serializable
{
+ /**
+ * @var string
+ */
protected $model = '';
+
+ /**
+ * @var ArrayIterator
+ */
protected $iterator;
+
+ /**
+ * @var PropelFormatter
+ */
protected $formatter;
-
// Generic Collection methods
-
+
/**
* Get the data in the collection
*
@@ -57,7 +70,7 @@
* Gets the position of the internal pointer
* This position can be later used in seek()
*
- * @return int
+ * @return integer
*/
public function getPosition()
{
@@ -75,11 +88,11 @@
$this->getInternalIterator()->rewind();
return $this->getCurrent();
}
-
+
/**
* Check whether the internal pointer is at the beginning of the list
*
- * @return boolean
+ * @return boolean
*/
public function isFirst()
{
@@ -160,14 +173,14 @@
/**
* Check if the collection is empty
- *
+ *
* @return boolean
*/
public function isEmpty()
{
return $this->count() == 0;
}
-
+
/**
* Check if the current index is an odd integer
*
@@ -192,9 +205,8 @@
* Get an element from its key
* Alias for ArrayObject::offsetGet()
*
- * @param mixed $key
- *
- * @return mixed The element
+ * @param mixed $key
+ * @return mixed The element
*/
public function get($key)
{
@@ -203,11 +215,11 @@
}
return $this->offsetGet($key);
}
-
+
/**
* Pops an element off the end of the collection
*
- * @return mixed The popped element
+ * @return mixed The popped element
*/
public function pop()
{
@@ -223,7 +235,7 @@
/**
* Pops an element off the beginning of the collection
*
- * @return mixed The popped element
+ * @return mixed The popped element
*/
public function shift()
{
@@ -232,16 +244,15 @@
$arr = $this->getArrayCopy();
$ret = array_shift($arr);
$this->exchangeArray($arr);
-
+
return $ret;
}
/**
* Prepend one or more elements to the beginning of the collection
*
- * @param mixed $value the element to prepend
- *
- * @return int The number of new elements in the array
+ * @param mixed $value the element to prepend
+ * @return integer The number of new elements in the array
*/
public function prepend($value)
{
@@ -258,21 +269,20 @@
* Add an element to the collection with the given key
* Alias for ArrayObject::offsetSet()
*
- * @param mixed $key
- * @param mixed $value
- */
+ * @param mixed $key
+ * @param mixed $value
+ */
public function set($key, $value)
{
- return $this->offsetSet($key, $value);
+ $this->offsetSet($key, $value);
}
-
+
/**
* Removes a specified collection element
* Alias for ArrayObject::offsetUnset()
*
- * @param mixed $key
- *
- * @return mixed The removed element
+ * @param mixed $key
+ * @return mixed The removed element
*/
public function remove($key)
{
@@ -281,11 +291,11 @@
}
return $this->offsetUnset($key);
}
-
+
/**
* Clears the collection
- *
- * @return array The previous collection
+ *
+ * @return array The previous collection
*/
public function clear()
{
@@ -295,9 +305,8 @@
/**
* Whether or not this collection contains a specified element
*
- * @param mixed $element the element
- *
- * @return boolean
+ * @param mixed $element
+ * @return boolean
*/
public function contains($element)
{
@@ -307,17 +316,19 @@
/**
* Search an element in the collection
*
- * @param mixed $element
- *
- * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise
+ * @param mixed $element
+ * @return mixed Returns the key for the element if it is found in the collection, FALSE otherwise
*/
public function search($element)
{
return array_search($element, $this->getArrayCopy(), true);
- }
-
+ }
+
// Serializable interface
-
+
+ /**
+ * @return string
+ */
public function serialize()
{
$repr = array(
@@ -326,26 +337,34 @@
);
return serialize($repr);
}
-
+
+ /**
+ * @param string $data
+ */
public function unserialize($data)
{
$repr = unserialize($data);
$this->exchangeArray($repr['data']);
$this->model = $repr['model'];
}
-
+
// IteratorAggregate method
-
+
/**
* Overrides ArrayObject::getIterator() to save the iterator object
* for internal use e.g. getNext(), isOdd(), etc.
+ *
+ * @return ArrayIterator
*/
public function getIterator()
{
$this->iterator = new ArrayIterator($this);
return $this->iterator;
}
-
+
+ /**
+ * @return ArrayIterator
+ */
public function getInternalIterator()
{
if (null === $this->iterator) {
@@ -353,7 +372,7 @@
}
return $this->iterator;
}
-
+
/**
* Clear the internal Iterator.
* PHP 5.3 doesn't know how to free a PropelCollection object if it has an attached
@@ -364,13 +383,13 @@
{
$this->iterator = null;
}
-
+
// Propel collection methods
-
+
/**
* Set the model of the elements in the collection
*
- * @param string $model Name of the Propel object classes stored in the collection
+ * @param string $model Name of the Propel object classes stored in the collection
*/
public function setModel($model)
{
@@ -380,17 +399,17 @@
/**
* Get the model of the elements in the collection
*
- * @return string Name of the Propel object class stored in the collection
+ * @return string Name of the Propel object class stored in the collection
*/
public function getModel()
{
return $this->model;
}
-
+
/**
* Get the peer class of the elements in the collection
*
- * @return string Name of the Propel peer class stored in the collection
+ * @return string Name of the Propel peer class stored in the collection
*/
public function getPeerClass()
{
@@ -399,12 +418,18 @@
}
return constant($this->getModel() . '::PEER');
}
-
+
+ /**
+ * @param PropelFormatter $formatter
+ */
public function setFormatter(PropelFormatter $formatter)
{
$this->formatter = $formatter;
}
-
+
+ /**
+ * @return PropelFormatter
+ */
public function getFormatter()
{
return $this->formatter;
@@ -413,14 +438,13 @@
/**
* Get a connection object for the database containing the elements of the collection
*
- * @param string $type The connection type (Propel::CONNECTION_READ by default; can be Propel::connection_WRITE)
- *
- * @return PropelPDO a connection object
+ * @param string $type The connection type (Propel::CONNECTION_READ by default; can be Propel::connection_WRITE)
+ * @return PropelPDO A PropelPDO connection object
*/
- public function getConnection($type = Propel::CONNECTION_READ)
+ public function getConnection($type = Propel::CONNECTION_READ)
{
$databaseName = constant($this->getPeerClass() . '::DATABASE_NAME');
-
+
return Propel::getConnection($databaseName, $type);
}
@@ -432,11 +456,10 @@
* $coll->importFrom('JSON', '{{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');
* </code>
*
- * @param mixed $parser A PropelParser instance,
- * or a format name ('XML', 'YAML', 'JSON', 'CSV')
- * @param string $data The source data to import from
+ * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
*
- * @return BaseObject The current object, for fluid interface
+ * @return BaseObject The current object, for fluid interface
*/
public function importFrom($parser, $data)
{
@@ -454,9 +477,8 @@
* => {{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}}');
* </code>
*
- * @param mixed $parser A PropelParser instance,
- * or a format name ('XML', 'YAML', 'JSON', 'CSV')
- * @return string The exported data
+ * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @return string The exported data
*/
public function exportTo($parser)
{
@@ -466,11 +488,17 @@
return $parser->listFromArray($this->toArray(null, true));
}
- /**
- * Catches calls to undefined methods.
- * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
- * Allows to define default __call() behavior if you use a custom BaseObject
- */
+ /**
+ * Catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you use a custom BaseObject
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return array|string
+ */
public function __call($name, $params)
{
if (preg_match('/^from(\w+)$/', $name, $matches)) {
@@ -480,16 +508,17 @@
return $this->exportTo($matches[1]);
}
throw new PropelException('Call to undefined method: ' . $name);
- }
-
- /**
+ }
+
+ /**
* Returns a string representation of the current collection.
- * Based on the string representation of the underlying objects, defined in
+ * Based on the string representation of the underlying objects, defined in
* the Peer::DEFAULT_STRING_FORMAT constant
- */
+ *
+ * @return string
+ */
public function __toString()
{
return (string) $this->exportTo(constant($this->getPeerClass() . '::DEFAULT_STRING_FORMAT'));
}
-
-}
\ No newline at end of file
+}
Index: propel/collection/PropelOnDemandIterator.php
===================================================================
--- propel/collection/PropelOnDemandIterator.php (revision 2294)
+++ propel/collection/PropelOnDemandIterator.php (working copy)
@@ -16,31 +16,43 @@
*/
class PropelOnDemandIterator implements Iterator
{
- protected
- $formatter,
- $stmt,
- $currentRow,
+ /**
+ * @var PropelObjectFormatter
+ */
+ protected $formatter;
+
+ /**
+ * @var PDOStatement
+ */
+ protected $stmt;
+
+ protected
+ $currentRow,
$currentKey = -1,
- $isValid = null,
+ $isValid = false,
$enableInstancePoolingOnFinish = false;
-
+
+ /**
+ * @param PropelFormatter $formatter
+ * @param PDOStatement $stmt
+ */
public function __construct(PropelFormatter $formatter, PDOStatement $stmt)
{
$this->formatter = $formatter;
$this->stmt = $stmt;
$this->enableInstancePoolingOnFinish = Propel::disableInstancePooling();
}
-
+
public function closeCursor()
{
$this->stmt->closeCursor();
}
-
+
/**
* Returns the number of rows in the resultset
* Warning: this number is inaccurate for most databases. Do not rely on it for a portable application.
- *
- * @return int number of results
+ *
+ * @return integer Number of results
*/
public function count()
{
@@ -48,12 +60,12 @@
}
// Iterator Interface
-
+
/**
* Gets the current Model object in the collection
* This is where the hydration takes place.
*
- * @see PropelObjectFormatter::getAllObjectsFromRow()
+ * @see PropelObjectFormatter::getAllObjectsFromRow()
*
* @return BaseObject
*/
@@ -61,7 +73,7 @@
{
return $this->formatter->getAllObjectsFromRow($this->currentRow);
}
-
+
/**
* Gets the current key in the iterator
*
@@ -71,7 +83,7 @@
{
return $this->currentKey;
}
-
+
/**
* Advances the curesor in the statement
* Closes the cursor if the end of the statement is reached
@@ -88,7 +100,7 @@
}
}
}
-
+
/**
* Initializes the iterator by advancing to the first position
* This method can only be called once (this is a NoRewindIterator)
@@ -105,14 +117,16 @@
if (null !== $this->isValid) {
throw new PropelException('The On Demand collection can only be iterated once');
}
-
+
// initialize the current row and key
$this->next();
}
-
+
+ /**
+ * @return boolean
+ */
public function valid()
{
- return $this->isValid;
+ return (boolean) $this->isValid;
}
-
-}
\ No newline at end of file
+}
Index: propel/collection/PropelOnDemandCollection.php
===================================================================
--- propel/collection/PropelOnDemandCollection.php (revision 2294)
+++ propel/collection/PropelOnDemandCollection.php (working copy)
@@ -16,26 +16,43 @@
*/
class PropelOnDemandCollection extends PropelCollection
{
- protected
- $iterator,
- $currentRow,
+ /**
+ * @var PropelOnDemandIterator
+ */
+ protected $iterator;
+
+ protected
+ $currentRow,
$currentKey = -1,
$isValid = null;
-
+
+ /**
+ * @param PropelFormatter $formatter
+ * @param PDOStatement $stmt
+ */
public function initIterator(PropelFormatter $formatter, PDOStatement $stmt)
{
$this->iterator = new PropelOnDemandIterator($formatter, $stmt);
}
-
+
// IteratorAggregate Interface
-
+
+ /**
+ * @return PropelOnDemandIterator
+ */
public function getIterator()
{
return $this->iterator;
}
// ArrayAccess Interface
-
+
+ /**
+ * @throws PropelException
+ * @param integer $offset
+ *
+ * @return boolean
+ */
public function offsetExists($offset)
{
if ($offset == $this->currentKey) {
@@ -44,6 +61,12 @@
throw new PropelException('The On Demand Collection does not allow acces by offset');
}
+ /**
+ * @throws PropelException
+ * @param integer $offset
+ *
+ * @return mixed
+ */
public function offsetGet($offset)
{
if ($offset == $this->currentKey) {
@@ -51,49 +74,66 @@
}
throw new PropelException('The On Demand Collection does not allow acces by offset');
}
-
+
+ /**
+ * @throws PropelException
+ *
+ * @param integer $offset
+ * @param mixed $value
+ */
public function offsetSet($offset, $value)
{
throw new PropelException('The On Demand Collection is read only');
}
+ /**
+ * @throws PropelException
+ * @param integer $offset
+ */
public function offsetUnset($offset)
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
// Serializable Interface
-
+
+ /**
+ * @throws PropelException
+ */
public function serialize()
{
throw new PropelException('The On Demand Collection cannot be serialized');
}
+ /**
+ * @throws PropelException
+ * @param string $data
+ */
public function unserialize($data)
{
throw new PropelException('The On Demand Collection cannot be serialized');
}
-
+
// Countable Interface
-
+
/**
* Returns the number of rows in the resultset
* Warning: this number is inaccurate for most databases. Do not rely on it for a portable application.
- *
- * @return int number of results
+ *
+ * @return integer Number of results
*/
public function count()
{
return $this->iterator->count();
}
-
+
// ArrayObject methods
-
+
public function append($value)
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function prepend($value)
{
throw new PropelException('The On Demand Collection is read only');
@@ -103,49 +143,49 @@
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function exchangeArray($input)
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function getArrayCopy()
{
throw new PropelException('The On Demand Collection does not allow acces by offset');
}
-
+
public function getFlags()
{
throw new PropelException('The On Demand Collection does not allow acces by offset');
}
-
+
public function ksort()
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function natcasesort()
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function natsort()
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function setFlags($flags)
{
throw new PropelException('The On Demand Collection does not allow acces by offset');
}
-
+
public function uasort($cmp_function)
{
throw new PropelException('The On Demand Collection is read only');
}
-
+
public function uksort($cmp_function)
{
throw new PropelException('The On Demand Collection is read only');
}
-}
\ No newline at end of file
+}
Index: propel/collection/PropelObjectCollection.php
===================================================================
--- propel/collection/PropelObjectCollection.php (revision 2294)
+++ propel/collection/PropelObjectCollection.php (working copy)
@@ -16,10 +16,12 @@
*/
class PropelObjectCollection extends PropelCollection
{
-
- /**
- * Save all the elements in the collection
- */
+
+ /**
+ * Save all the elements in the collection
+ *
+ * @param PropelPDO $con
+ */
public function save($con = null)
{
if (null === $con) {
@@ -27,6 +29,7 @@
}
$con->beginTransaction();
try {
+ /** @var $element BaseObject */
foreach ($this as $element) {
$element->save($con);
}
@@ -36,9 +39,11 @@
throw $e;
}
}
-
+
/**
* Delete all the elements in the collection
+ *
+ * @param PropelPDO $con
*/
public function delete($con = null)
{
@@ -47,6 +52,7 @@
}
$con->beginTransaction();
try {
+ /** @var $element BaseObject */
foreach ($this as $element) {
$element->delete($con);
}
@@ -57,19 +63,22 @@
}
}
- /**
- * Get an array of the primary keys of all the objects in the collection
- *
- * @return array The list of the primary keys of the collection
- */
+ /**
+ * Get an array of the primary keys of all the objects in the collection
+ *
+ * @param boolean $usePrefix
+ * @return array The list of the primary keys of the collection
+ */
public function getPrimaryKeys($usePrefix = true)
{
$ret = array();
+
+ /** @var $obj BaseObject */
foreach ($this as $key => $obj) {
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key]= $obj->getPrimaryKey();
}
-
+
return $ret;
}
@@ -78,31 +87,31 @@
* Each object is populated from an array and the result is stored
* Does not empty the collection before adding the data from the array
*
- * @param array $arr
+ * @param array $arr
*/
public function fromArray($arr)
{
$class = $this->getModel();
foreach ($arr as $element) {
+ /** @var $obj BaseObject */
$obj = new $class();
$obj->fromArray($element);
$this->append($obj);
}
}
-
+
/**
* Get an array representation of the collection
* Each object is turned into an array and the result is returned
*
* @param string $keyColumn If null, the returned array uses an incremental index.
- * Otherwise, the array is indexed using the specified column
- * @param boolean $usePrefix If true, the returned array prefixes keys
- * with the model class name ('Article_0', 'Article_1', etc).
- * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME,
- * BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME,
- * BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
- * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns.
- * Defaults to TRUE.
+ * Otherwise, the array is indexed using the specified column
+ * @param boolean $usePrefix If true, the returned array prefixes keys
+ * with the model class name ('Article_0', 'Article_1', etc).
+ * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME,
+ * BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME,
+ * BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
+ * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
*
* <code>
@@ -122,46 +131,50 @@
* 'Book_1' => array('Id' => 456, 'Title' => 'Don Juan'),
* )
* </code>
+ *
* @return array
*/
public function toArray($keyColumn = null, $usePrefix = false, $keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
{
$ret = array();
$keyGetterMethod = 'get' . $keyColumn;
+
+ /** @var $obj BaseObject */
foreach ($this as $key => $obj) {
$key = null === $keyColumn ? $key : $obj->$keyGetterMethod();
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key] = $obj->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
-
+
return $ret;
}
-
+
/**
* Get an array representation of the collection
*
- * @param string $keyColumn If null, the returned array uses an incremental index.
- * Otherwise, the array is indexed using the specified column
- * @param boolean $usePrefix If true, the returned array prefixes keys
- * with the model class name ('Article_0', 'Article_1', etc).
+ * @param string $keyColumn If null, the returned array uses an incremental index.
+ * Otherwise, the array is indexed using the specified column
+ * @param boolean $usePrefix If true, the returned array prefixes keys
+ * with the model class name ('Article_0', 'Article_1', etc).
*
* <code>
- * $bookCollection->getArrayCopy();
- * array(
- * 0 => $book0,
- * 1 => $book1,
- * )
- * $bookCollection->getArrayCopy('Id');
- * array(
- * 123 => $book0,
- * 456 => $book1,
- * )
- * $bookCollection->getArrayCopy(null, true);
- * array(
- * 'Book_0' => $book0,
- * 'Book_1' => $book1,
- * )
+ * $bookCollection->getArrayCopy();
+ * array(
+ * 0 => $book0,
+ * 1 => $book1,
+ * )
+ * $bookCollection->getArrayCopy('Id');
+ * array(
+ * 123 => $book0,
+ * 456 => $book1,
+ * )
+ * $bookCollection->getArrayCopy(null, true);
+ * array(
+ * 'Book_0' => $book0,
+ * 'Book_1' => $book1,
+ * )
* </code>
+ *
* @return array
*/
public function getArrayCopy($keyColumn = null, $usePrefix = false)
@@ -176,20 +189,24 @@
$key = $usePrefix ? ($this->getModel() . '_' . $key) : $key;
$ret[$key] = $obj;
}
-
+
return $ret;
}
-
- /**
- * Get an associative array representation of the collection
- * The first parameter specifies the column to be used for the key,
- * And the seconf for the value.
- * <code>
- * $res = $coll->toKeyValue('Id', 'Name');
- * </code>
- *
- * @return array
- */
+
+ /**
+ * Get an associative array representation of the collection
+ * The first parameter specifies the column to be used for the key,
+ * And the seconf for the value.
+ *
+ * <code>
+ * $res = $coll->toKeyValue('Id', 'Name');
+ * </code>
+ *
+ * @param string $keyColumn
+ * @param string $valueColumn
+ *
+ * @return array
+ */
public function toKeyValue($keyColumn = 'PrimaryKey', $valueColumn = null)
{
$ret = array();
@@ -198,19 +215,19 @@
foreach ($this as $obj) {
$ret[$obj->$keyGetterMethod()] = $obj->$valueGetterMethod();
}
-
+
return $ret;
}
-
+
/**
* Makes an additional query to populate the objects related to the collection objects
* by a certain relation
*
- * @param string $relation Relation name (e.g. 'Book')
- * @param Criteria $criteria Optional Criteria object to filter the related object collection
- * @param PropelPDO $con Optional connection object
+ * @param string $relation Relation name (e.g. 'Book')
+ * @param Criteria $criteria Optional Criteria object to filter the related object collection
+ * @param PropelPDO $con Optional connection object
*
- * @return PropelObjectCollection the list of related objects
+ * @return PropelObjectCollection The list of related objects
*/
public function populateRelation($relation, $criteria = null, $con = null)
{
@@ -225,7 +242,7 @@
return $coll;
}
$symRelationMap = $relationMap->getSymmetricalRelation();
-
+
$query = PropelQuery::from($relationMap->getRightTable()->getPhpName());
if (null !== $criteria) {
$query->mergeWith($criteria);
@@ -249,10 +266,7 @@
} else {
throw new PropelException('populateRelation() does not support this relation type');
}
-
+
return $relatedObjects;
}
-
}
-
-?>
\ No newline at end of file
Index: propel/om/NodeObject.php
===================================================================
--- propel/om/NodeObject.php (revision 2294)
+++ propel/om/NodeObject.php (working copy)
@@ -21,8 +21,8 @@
/**
* If object is saved without left/right values, set them as undefined (0)
*
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param PropelPDO $con Connection to use.
+ * @return void
* @throws PropelException
*/
public function save(PropelPDO $con = null);
@@ -30,8 +30,8 @@
/**
* Delete node and descendants
*
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param PropelPDO $con Connection to use.
+ * @return void
* @throws PropelException
*/
public function delete(PropelPDO $con = null);
@@ -39,7 +39,7 @@
/**
* Sets node properties to make it a root node.
*
- * @return object The current object (for fluent API support)
+ * @return object The current object (for fluent API support)
* @throws PropelException
*/
public function makeRoot();
@@ -47,278 +47,279 @@
/**
* Gets the level if set, otherwise calculates this and returns it
*
- * @param PropelPDO $con Connection to use.
- * @return int
+ * @param PropelPDO $con Connection to use.
+ * @return int
*/
public function getLevel(PropelPDO $con = null);
/**
* Get the path to the node in the tree
*
- * @param PropelPDO $con Connection to use.
- * @return array
+ * @param PropelPDO $con Connection to use.
+ * @return array
*/
public function getPath(PropelPDO $con = null);
/**
* Gets the number of children for the node (direct descendants)
*
- * @param PropelPDO $con Connection to use.
- * @return int
+ * @param PropelPDO $con Connection to use.
+ * @return int
*/
public function getNumberOfChildren(PropelPDO $con = null);
/**
* Gets the total number of desceandants for the node
*
- * @param PropelPDO $con Connection to use.
- * @return int
+ * @param PropelPDO $con Connection to use.
+ * @return int
*/
public function getNumberOfDescendants(PropelPDO $con = null);
/**
* Gets the children for the node
*
- * @param PropelPDO $con Connection to use.
- * @return array
+ * @param PropelPDO $con Connection to use.
+ * @return array
*/
public function getChildren(PropelPDO $con = null);
/**
* Gets the descendants for the node
*
- * @param PropelPDO $con Connection to use.
- * @return array
+ * @param PropelPDO $con Connection to use.
+ * @return array
*/
public function getDescendants(PropelPDO $con = null);
- /**
- * Sets the level of the node in the tree
- *
- * @param int $v new value
- * @return object The current object (for fluent API support)
- */
+ /**
+ * Sets the level of the node in the tree
+ *
+ * @param ineger $level
+ * @return NodeObject
+ */
public function setLevel($level);
- /**
- * Sets the children array of the node in the tree
- *
- * @param array of Node $children array of Propel node object
- * @return object The current object (for fluent API support)
- */
- public function setChildren(array $children);
+ /**
+ * Sets the children array of the node in the tree
+ *
+ * @param array|NodeObject[] $children
+ * @return NodeObject
+ */
+ public function setChildren($children);
/**
* Sets the parentNode of the node in the tree
*
- * @param Node $parent Propel node object
- * @return object The current object (for fluent API support)
+ * @param NodeObject $parent
+ * @return NodeObject
*/
public function setParentNode(NodeObject $parent = null);
/**
* Sets the previous sibling of the node in the tree
*
- * @param Node $node Propel node object
- * @return object The current object (for fluent API support)
+ * @param NodeObject $node
+ * @return NodeObject
*/
public function setPrevSibling(NodeObject $node = null);
/**
* Sets the next sibling of the node in the tree
*
- * @param Node $node Propel node object
- * @return object The current object (for fluent API support)
+ * @param NodeObject $node
+ * @return NodeObject
*/
public function setNextSibling(NodeObject $node = null);
/**
* Determines if the node is the root node
*
- * @return bool
+ * @return boolean
*/
public function isRoot();
/**
* Determines if the node is a leaf node
*
- * @return bool
+ * @return boolean
*/
public function isLeaf();
/**
* Tests if object is equal to $node
*
- * @param object $node Propel object for node to compare to
- * @return bool
+ * @param NodeObject $node
+ * @return boolean
*/
public function isEqualTo(NodeObject $node);
/**
* Tests if object has an ancestor
*
- * @param PropelPDO $con Connection to use.
- * @return bool
+ * @param PropelPDO $con Connection to use.
+ * @return boolean
*/
public function hasParent(PropelPDO $con = null);
/**
* Determines if the node has children / descendants
*
- * @return bool
+ * @return boolean
*/
public function hasChildren();
/**
* Determines if the node has previous sibling
*
- * @param PropelPDO $con Connection to use.
- * @return bool
+ * @param PropelPDO $con Connection to use.
+ * @return boolean
*/
public function hasPrevSibling(PropelPDO $con = null);
/**
* Determines if the node has next sibling
*
- * @param PropelPDO $con Connection to use.
- * @return bool
+ * @param PropelPDO $con Connection to use.
+ * @return boolean
*/
public function hasNextSibling(PropelPDO $con = null);
/**
* Gets ancestor for the given node if it exists
*
- * @param PropelPDO $con Connection to use.
- * @return mixed Propel object if exists else false
+ * @param PropelPDO $con Connection to use.
+ * @return NodeObject|false
*/
public function retrieveParent(PropelPDO $con = null);
/**
* Gets first child if it exists
*
- * @param PropelPDO $con Connection to use.
- * @return mixed Propel object if exists else false
+ * @param PropelPDO $con Connection to use.
+ * @return NodeObject|false
*/
public function retrieveFirstChild(PropelPDO $con = null);
/**
* Gets last child if it exists
*
- * @param PropelPDO $con Connection to use.
- * @return mixed Propel object if exists else false
+ * @param PropelPDO $con Connection to use.
+ * @return NodeObject|false
*/
public function retrieveLastChild(PropelPDO $con = null);
/**
* Gets prev sibling for the given node if it exists
*
- * @param PropelPDO $con Connection to use.
- * @return mixed Propel object if exists else false
+ * @param PropelPDO $con Connection to use.
+ * @return NodeObject|false
*/
public function retrievePrevSibling(PropelPDO $con = null);
/**
* Gets next sibling for the given node if it exists
*
- * @param PropelPDO $con Connection to use.
- * @return mixed Propel object if exists else false
+ * @param PropelPDO $con Connection to use.
+ * @return NodeObject|false
*/
public function retrieveNextSibling(PropelPDO $con = null);
/**
* Inserts as first child of destination node $parent
*
- * @param object $parent Propel object for given destination node
- * @param PropelPDO $con Connection to use.
- * @return object The current object (for fluent API support)
+ * @param NodeObject $parent Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
+ *
+ * @return NodeObject
*/
public function insertAsFirstChildOf(NodeObject $parent, PropelPDO $con = null);
/**
* Inserts as last child of destination node $parent
*
- * @param object $parent Propel object for given destination node
- * @param PropelPDO $con Connection to use.
- * @return object The current object (for fluent API support)
+ * @param NodeObject $parent Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
+ *
+ * @return NodeObject
*/
public function insertAsLastChildOf(NodeObject $parent, PropelPDO $con = null);
/**
* Inserts node as previous sibling to destination node $dest
*
- * @param object $dest Propel object for given destination node
- * @param PropelPDO $con Connection to use.
- * @return object The current object (for fluent API support)
+ * @param NodeObject $dest Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
+ *
+ * @return NodeObject
*/
public function insertAsPrevSiblingOf(NodeObject $dest, PropelPDO $con = null);
/**
* Inserts node as next sibling to destination node $dest
*
- * @param object $dest Propel object for given destination node
- * @param PropelPDO $con Connection to use.
- * @return object The current object (for fluent API support)
+ * @param NodeObject $dest Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
+ *
+ * @return NodeObject
*/
public function insertAsNextSiblingOf(NodeObject $dest, PropelPDO $con = null);
/**
* Moves node to be first child of $parent
*
- * @param object $parent Propel object for destination node
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param NodeObject $parent Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
*/
public function moveToFirstChildOf(NodeObject $parent, PropelPDO $con = null);
/**
* Moves node to be last child of $parent
*
- * @param object $parent Propel object for destination node
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param NodeObject $parent Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
*/
public function moveToLastChildOf(NodeObject $parent, PropelPDO $con = null);
/**
* Moves node to be prev sibling to $dest
*
- * @param object $dest Propel object for destination node
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param NodeObject $dest Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
*/
public function moveToPrevSiblingOf(NodeObject $dest, PropelPDO $con = null);
/**
* Moves node to be next sibling to $dest
*
- * @param object $dest Propel object for destination node
- * @param PropelPDO $con Connection to use.
- * @return void
+ * @param NodeObject $dest Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
*/
public function moveToNextSiblingOf(NodeObject $dest, PropelPDO $con = null);
/**
* Inserts node as parent of given node.
*
- * @param object $node Propel object for given destination node
- * @param PropelPDO $con Connection to use.
- * @return void
- * @throws Exception When trying to insert node as parent of a root node
+ * @param NodeObject $node Propel object for given destination node
+ * @param PropelPDO $con Connection to use.
+ *
+ * @throws Exception when trying to insert node as parent of a root node
+ * @return NodeObject
*/
public function insertAsParentOf(NodeObject $node, PropelPDO $con = null);
/**
* Wraps the getter for the scope value
*
- * @return int
+ * @return integer
*/
public function getScopeIdValue();
/**
* Set the value of scope column
*
- * @param int $v new value
- * @return object The current object (for fluent API support)
+ * @param integer $v
+ * @return NodeObject
*/
public function setScopeIdValue($v);
-} // NodeObject
+}
Index: propel/om/NestedSetRecursiveIterator.php
===================================================================
--- propel/om/NestedSetRecursiveIterator.php (revision 2294)
+++ propel/om/NestedSetRecursiveIterator.php (working copy)
@@ -17,10 +17,19 @@
*/
class NestedSetRecursiveIterator implements RecursiveIterator
{
+ /**
+ * @var NodeObject|null
+ */
protected $topNode = null;
+ /**
+ * @var NodeObject|null
+ */
protected $curNode = null;
+ /**
+ * @param NodeObject $node
+ */
public function __construct($node)
{
$this->topNode = $node;
@@ -32,16 +41,25 @@
$this->curNode = $this->topNode;
}
+ /**
+ * @return boolean
+ */
public function valid()
{
return ($this->curNode !== null);
}
+ /**
+ * @return NodeObject|null
+ */
public function current()
{
return $this->curNode;
}
+ /**
+ * @return string
+ */
public function key()
{
$method = method_exists($this->curNode, 'getPath') ? 'getPath' : 'getAncestors';
@@ -49,9 +67,13 @@
foreach ($this->curNode->$method() as $node) {
$key[] = $node->getPrimaryKey();
}
+
return implode('.', $key);
}
+ /**
+ * @return NodeObject|null
+ */
public function next()
{
$nextNode = null;
@@ -70,17 +92,25 @@
}
$this->curNode = $nextNode;
}
+
return $this->curNode;
}
+ /**
+ * @return boolean
+ */
public function hasChildren()
{
return $this->curNode->hasChildren();
}
+ /**
+ * @return NestedSetRecursiveIterator
+ */
public function getChildren()
{
$method = method_exists($this->curNode, 'retrieveFirstChild') ? 'retrieveFirstChild' : 'getFirstChild';
+
return new NestedSetRecursiveIterator($this->curNode->$method());
}
}
Index: propel/om/Persistent.php
===================================================================
--- propel/om/Persistent.php (revision 2294)
+++ propel/om/Persistent.php (working copy)
@@ -23,33 +23,32 @@
/**
* getter for the object primaryKey.
*
- * @return ObjectKey the object primaryKey as an Object
+ * @return mixed
*/
public function getPrimaryKey();
/**
* Sets the PrimaryKey for the object.
*
- * @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()).
- * @return void
- * @throws Exception, This method might throw an exceptions
+ * @param mixed $primaryKey The new PrimaryKey object or string (result of PrimaryKey.toString()).
+ * @throws Exception when this method might throw an exceptions
*/
public function setPrimaryKey($primaryKey);
/**
- * Returns whether the object has been modified, since it was
- * last retrieved from storage.
+ * Returns whether the object has been modified,
+ * since it was last retrieved from storage.
*
- * @return boolean True if the object has been modified.
+ * @return boolean
*/
public function isModified();
/**
* Has specified column been modified?
*
- * @param string $col
- * @return boolean True if $col has been modified.
+ * @param string $col
+ * @return boolean
*/
public function isColumnModified($col);
@@ -58,51 +57,50 @@
* be false, if the object was retrieved from storage or was created
* and then saved.
*
- * @return boolean True, if the object has never been persisted.
+ * @return boolean
*/
public function isNew();
/**
- * Setter for the isNew attribute. This method will be called
- * by Propel-generated children and Peers.
+ * Setter for the isNew attribute.
+ * This method will be called by Propel-generated children and Peers.
*
- * @param boolean $b the state of the object.
+ * @param boolean $b The state of the object.
*/
public function setNew($b);
/**
* Resets (to false) the "modified" state for this object.
- *
- * @return void
*/
public function resetModified();
/**
* Whether this object has been deleted.
- * @return boolean The deleted state of this object.
+ *
+ * @return boolean
*/
public function isDeleted();
/**
* Specify whether this object has been deleted.
- * @param boolean $b The deleted state of this object.
- * @return void
+ *
+ * @param boolean $b The deleted state of this object.
*/
public function setDeleted($b);
/**
* Deletes the object.
- * @param PropelPDO $con
- * @return void
- * @throws Exception
+ *
+ * @param PropelPDO $con
+ * @throws Exception
*/
public function delete(PropelPDO $con = null);
/**
* Saves the object.
- * @param PropelPDO $con
- * @return void
- * @throws Exception
+ *
+ * @param PropelPDO $con
+ * @throws Exception
*/
public function save(PropelPDO $con = null);
}
Index: propel/om/BaseObject.php
===================================================================
--- propel/om/BaseObject.php (revision 2294)
+++ propel/om/BaseObject.php (working copy)
@@ -12,10 +12,17 @@
* This class contains attributes and methods that are used by all
* business objects within the system.
*
+ * @method getPrimaryKey() Returns the primary key for the object (row).
+ * @method clearAllReferences() Resets all references to other model objects
+ * or collections of model objects.
+ *
+ * @method BaseObject fromArray(array $data) Populate the object from an Array
* @method BaseObject fromXML(string $data) Populate the object from an XML string
* @method BaseObject fromYAML(string $data) Populate the object from a YAML string
* @method BaseObject fromJSON(string $data) Populate the object from a JSON string
* @method BaseObject fromCSV(string $data) Populate the object from a CSV string
+ *
+ * @method array toArray() Export the object to an Array
* @method string toXML() Export the object to an XML string
* @method string toYAML() Export the object to a YAML string
* @method string toJSON() Export the object to a JSON string
@@ -31,42 +38,44 @@
{
/**
- * attribute to determine if this object has previously been saved.
- * @var boolean
+ * Attribute to determine if this object has previously been saved.
+ *
+ * @var boolean
*/
protected $_new = true;
/**
- * attribute to determine whether this object has been deleted.
- * @var boolean
+ * Attribute to determine whether this object has been deleted.
+ *
+ * @var boolean
*/
protected $_deleted = false;
/**
* The columns that have been modified in current object.
* Tracking modified columns allows us to only update modified columns.
- * @var array
+ *
+ * @var array
*/
protected $modifiedColumns = array();
-
+
/**
* The (virtual) columns that are added at runtime
* The formatters can add supplementary columns based on a resultset
- * @var array
+ *
+ * @var array
*/
protected $virtualColumns = array();
-
+
/**
* Empty constructor (this allows people with their own BaseObject implementation to use its constructor)
*/
- public function __construct() {
+ public function __construct() { ; }
- }
-
/**
* Returns whether the object has been modified.
*
- * @return boolean True if the object has been modified.
+ * @return boolean
*/
public function isModified()
{
@@ -76,8 +85,8 @@
/**
* Has specified column been modified?
*
- * @param string $col column fully qualified name (BasePeer::TYPE_COLNAME), e.g. Book::AUTHOR_ID
- * @return boolean True if $col has been modified.
+ * @param string $col Fully qualified name (BasePeer::TYPE_COLNAME), e.g. Book::AUTHOR_ID
+ * @return boolean
*/
public function isColumnModified($col)
{
@@ -85,8 +94,9 @@
}
/**
- * Get the columns that have been modified in this object.
- * @return array A unique list of the modified column names for this object.
+ * Get the unique list of the modified column names for this object
+ *
+ * @return array
*/
public function getModifiedColumns()
{
@@ -94,11 +104,10 @@
}
/**
- * Returns whether the object has ever been saved. This will
- * be false, if the object was retrieved from storage or was created
- * and then saved.
+ * Returns whether the object has ever been saved. This will be false,
+ * if the object was retrieved from storage or was created and then saved.
*
- * @return true, if the object has never been persisted.
+ * @return boolean
*/
public function isNew()
{
@@ -109,7 +118,7 @@
* Setter for the isNew attribute. This method will be called
* by Propel-generated children and Peers.
*
- * @param boolean $b the state of the object.
+ * @param boolean $b The state of the object.
*/
public function setNew($b)
{
@@ -118,7 +127,8 @@
/**
* Whether this object has been deleted.
- * @return boolean The deleted state of this object.
+ *
+ * @return boolean
*/
public function isDeleted()
{
@@ -127,8 +137,8 @@
/**
* Specify whether this object has been deleted.
- * @param boolean $b The deleted state of this object.
- * @return void
+ *
+ * @param boolean $b The deleted state of this object.
*/
public function setDeleted($b)
{
@@ -137,8 +147,9 @@
/**
* Code to be run before persisting the object
- * @param PropelPDO $con
- * @return bloolean
+ *
+ * @param PropelPDO $con
+ * @return bloolean
*/
public function preSave(PropelPDO $con = null)
{
@@ -147,30 +158,34 @@
/**
* Code to be run after persisting the object
- * @param PropelPDO $con
+ *
+ * @param PropelPDO $con
*/
public function postSave(PropelPDO $con = null) { }
/**
* Code to be run before inserting to database
- * @param PropelPDO $con
- * @return boolean
+ *
+ * @param PropelPDO $con
+ * @return boolean
*/
public function preInsert(PropelPDO $con = null)
{
return true;
}
-
+
/**
* Code to be run after inserting to database
- * @param PropelPDO $con
+ *
+ * @param PropelPDO $con
*/
public function postInsert(PropelPDO $con = null) { }
/**
* Code to be run before updating the object in database
- * @param PropelPDO $con
- * @return boolean
+ *
+ * @param PropelPDO $con
+ * @return boolean
*/
public function preUpdate(PropelPDO $con = null)
{
@@ -179,14 +194,16 @@
/**
* Code to be run after updating the object in database
- * @param PropelPDO $con
+ *
+ * @param PropelPDO $con
*/
public function postUpdate(PropelPDO $con = null) { }
/**
* Code to be run before deleting the object in database
- * @param PropelPDO $con
- * @return boolean
+ *
+ * @param PropelPDO $con
+ * @return boolean
*/
public function preDelete(PropelPDO $con = null)
{
@@ -195,14 +212,15 @@
/**
* Code to be run after deleting the object in database
- * @param PropelPDO $con
+ *
+ * @param PropelPDO $con
*/
public function postDelete(PropelPDO $con = null) { }
-
+
/**
* Sets the modified state for the object to be false.
- * @param string $col If supplied, only the specified column is reset.
- * @return void
+ *
+ * @param string $col If supplied, only the specified column is reset.
*/
public function resetModified($col = null)
{
@@ -216,12 +234,15 @@
}
/**
- * Compares this with another <code>BaseObject</code> instance. If
- * <code>obj</code> is an instance of <code>BaseObject</code>, delegates to
- * <code>equals(BaseObject)</code>. Otherwise, returns <code>false</code>.
+ * Compares this with another <code>BaseObject</code> instance.
+ *
+ * If <code>obj</code> is an instance of <code>BaseObject</code>,
+ * delegates to <code>equals(BaseObject)</code>.
+ *
+ * Otherwise, returns <code>false</code>.
*
- * @param obj The object to compare to.
- * @return Whether equal to the object specified.
+ * @param BaseObject $obj The object to compare to.
+ * @return boolean
*/
public function equals($obj)
{
@@ -243,7 +264,7 @@
* If the primary key is not <code>null</code>, return the hashcode of the
* primary key. Otherwise calls <code>Object.hashCode()</code>.
*
- * @return int Hashcode
+ * @return integer
*/
public function hashCode()
{
@@ -251,15 +272,14 @@
if ($ok === null) {
return crc32(serialize($this));
}
+
return crc32(serialize($ok)); // serialize because it could be an array ("ComboKey")
}
-
+
/**
* Get the associative array of the virtual columns in this object
*
- * @param string $name The virtual column name
- *
- * @return array
+ * @return array
*/
public function getVirtualColumns()
{
@@ -268,85 +288,91 @@
/**
* Checks the existence of a virtual column in this object
- *
- * @return boolean
+ *
+ * @param string $name The virtual column name
+ * @return boolean
*/
public function hasVirtualColumn($name)
{
return array_key_exists($name, $this->virtualColumns);
}
-
+
/**
* Get the value of a virtual column in this object
*
- * @return mixed
+ * @param string $name The virtual column name
+ * @return mixed
*/
public function getVirtualColumn($name)
{
if (!$this->hasVirtualColumn($name)) {
throw new PropelException('Cannot get value of inexistent virtual column ' . $name);
}
+
return $this->virtualColumns[$name];
}
-
+
/**
* Get the value of a virtual column in this object
*
- * @param string $name The virtual column name
- * @param mixed $value The value to give to the virtual column
+ * @param string $name The virtual column name
+ * @param mixed $value The value to give to the virtual column
*
- * @return BaseObject The current object, for fluid interface
+ * @return BaseObject
*/
public function setVirtualColumn($name, $value)
{
$this->virtualColumns[$name] = $value;
+
return $this;
}
/**
* Logs a message using Propel::log().
*
- * @param string $msg
- * @param int $priority One of the Propel::LOG_* logging levels
- * @return boolean
+ * @param string $msg
+ * @param integer $priority One of the Propel::LOG_* logging levels
+ *
+ * @return boolean
*/
protected function log($msg, $priority = Propel::LOG_INFO)
{
return Propel::log(get_class($this) . ': ' . $msg, $priority);
}
-
+
/**
* Populate the current object from a string, using a given parser format
+ *
* <code>
- * $book = new Book();
- * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ * $book = new Book();
+ * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
* </code>
*
- * @param mixed $parser A PropelParser instance,
- * or a format name ('XML', 'YAML', 'JSON', 'CSV')
- * @param string $data The source data to import from
+ * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @param string $data The source data to import from
*
- * @return BaseObject The current object, for fluid interface
+ * @return BaseObject
*/
public function importFrom($parser, $data)
{
if (!$parser instanceof PropelParser) {
$parser = PropelParser::getParser($parser);
}
+
return $this->fromArray($parser->toArray($data), BasePeer::TYPE_PHPNAME);
}
/**
* Export the current object properties to a string, using a given parser format
+ *
* <code>
- * $book = BookQuery::create()->findPk(9012);
- * echo $book->exportTo('JSON');
- * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
+ * $book = BookQuery::create()->findPk(9012);
+ * echo $book->exportTo('JSON');
+ * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
* </code>
*
- * @param mixed $parser A PropelParser instance,
- * or a format name ('XML', 'YAML', 'JSON', 'CSV')
- * @return string The exported data
+ * @param mixed $parser A PropelParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
+ * @return string
*/
public function exportTo($parser)
{
@@ -355,22 +381,31 @@
}
return $parser->fromArray($this->toArray(BasePeer::TYPE_PHPNAME, true, array(), true));
}
-
+
/**
* Clean up internal collections prior to serializing
* Avoids recursive loops that turn into segmentation faults when serializing
- */
+ *
+ * @return array
+ */
public function __sleep()
{
$this->clearAllReferences();
+
return array_keys(get_object_vars($this));
}
- /**
- * Catches calls to undefined methods.
- * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
- * Allows to define default __call() behavior if you use a custom BaseObject
- */
+ /**
+ * Catches calls to undefined methods.
+ *
+ * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
+ * Allows to define default __call() behavior if you use a custom BaseObject
+ *
+ * @param string $name
+ * @param mixed $params
+ *
+ * @return BaseObject|string
+ */
public function __call($name, $params)
{
if (preg_match('/^from(\w+)$/', $name, $matches)) {
@@ -380,5 +415,5 @@
return $this->exportTo($matches[1]);
}
throw new PropelException('Call to undefined method: ' . $name);
- }
+ }
}
Index: propel/parser/PropelCSVParser.php
===================================================================
--- propel/parser/PropelCSVParser.php (revision 2294)
+++ propel/parser/PropelCSVParser.php (working copy)
@@ -22,15 +22,15 @@
const QUOTE_ALL = 1;
const QUOTE_NONNUMERIC = 2;
const QUOTE_MINIMAL = 3;
-
+
// these settings are predefined for Excel CSV format
-
+
public $delimiter = ',';
public $lineTerminator = "\r\n";
public $quotechar = '"';
public $escapechar = "\\";
public $quoting = self::QUOTE_MINIMAL;
-
+
/**
* Converts data from an associative array to CSV.
*
@@ -56,21 +56,21 @@
}
$rows[] = implode($this->formatRow($array), $this->delimiter);
}
-
+
return implode($rows, $this->lineTerminator) . $this->lineTerminator;
}
-
+
public function listFromArray($array)
{
return $this->fromArray($array, true);
}
-
- /**
- * Accepts a row of data and returns it formatted
- *
- * @param array An array of data to be formatted for output to the file
- * @return array The formatted array
- */
+
+ /**
+ * Accepts a row of data and returns it formatted
+ *
+ * @param array $row An $array array of data to be formatted for output to the file
+ * @return array
+ */
protected function formatRow($row)
{
foreach ($row as &$column) {
@@ -101,11 +101,11 @@
}
/**
- * Escapes a column (escapes quotechar with escapechar)
- *
- * @param string A single value to be escaped for output
- * @return string Escaped input value
- */
+ * Escapes a column (escapes quotechar with escapechar)
+ *
+ * @param string $input A single value to be escaped for output
+ * @return string Escaped input value
+ */
protected function escape($input)
{
return str_replace(
@@ -118,7 +118,7 @@
/**
* Quotes a column with quotechar
*
- * @param string A single value to be quoted for output
+ * @param string $input A single value to be quoted for output
* @return string Quoted input value
*/
protected function quote($input)
@@ -129,7 +129,7 @@
/**
* Returns true if input contains quotechar, delimiter or any of the characters in lineTerminator
*
- * @param string A single value to be checked for special characters
+ * @param string $input A single value to be checked for special characters
* @return boolean True if contains any special characters
*/
protected function containsSpecialChars($input)
@@ -137,21 +137,27 @@
$special_chars = str_split($this->lineTerminator, 1);
$special_chars[] = $this->quotechar;
$special_chars[] = $this->delimiter;
+
foreach ($special_chars as $char) {
if (strpos($input, $char) !== false) {
return true;
}
}
+
+ return false;
}
- /**
- * Serializes a value to place it into a CSV output
- */
+ /**
+ * Serializes a value to place it into a CSV output
+ *
+ * @param mixed $input
+ * @return string
+ */
protected function serialize($input)
{
return serialize($input);
}
-
+
/**
* Alias for PropelCSVParser::fromArray()
*
@@ -204,7 +210,7 @@
$array = array_combine($keys, $values);
}
}
-
+
return $array;
}
@@ -219,12 +225,12 @@
preg_match_all('/(".+?"|[^' . $delim . ']+)(' . $delim . '|$)/', $row, $matches);
return $matches[1];
}
-
+
/**
* Accepts a formatted row of data and returns it raw
- *
- * @param array An array of data from a CSV output
- * @return array The cleaned up array
+ *
+ * @param array $row An array of data from a CSV output
+ * @return array
*/
protected function cleanupRow($row)
{
@@ -242,13 +248,13 @@
}
return $row;
}
-
+
protected function isQuoted($input)
{
$quote = preg_quote($this->quotechar, '/');
return preg_match('/^' . $quote . '.*' . $quote . '$/', $input);
}
-
+
protected function unescape($input)
{
return str_replace(
@@ -257,28 +263,34 @@
$input
);
}
-
+
protected function unquote($input)
{
return trim($input, $this->quotechar);
}
-
- /**
- * Checks whether a value from CSV output is serialized
- */
+
+ /**
+ * Checks whether a value from CSV output is serialized
+ *
+ * @param string $input
+ * @return boolean
+ */
protected function isSerialized($input)
{
return preg_match('/^\w\:\d+\:\{/', $input);
}
- /**
- * Unserializes a value from CSV output
- */
+ /**
+ * Unserializes a value from CSV output
+ *
+ * @param string $input
+ * @return mixed
+ */
protected function unserialize($input)
{
return unserialize($input);
}
-
+
/**
* Alias for PropelCSVParser::toArray()
*
@@ -292,5 +304,5 @@
{
return $this->toArray($data, $isList, $includeHeading);
}
-
+
}
Index: propel/parser/PropelParser.php
===================================================================
--- propel/parser/PropelParser.php (revision 2294)
+++ propel/parser/PropelParser.php (working copy)
@@ -22,7 +22,7 @@
*
* Override in the parser driver.
*
- * @param array $array Source data to convert
+ * @param array $array Source data to convert
* @return mixed Converted data, depending on the parser format
*/
abstract public function fromArray($array);
@@ -41,7 +41,7 @@
{
return $this->fromArray($data);
}
-
+
public function listToArray($data)
{
return $this->toArray($data);
@@ -52,7 +52,7 @@
*
* @param string $path Path to the file to load
*
- * @return string The file content processed by PHP
+ * @return string The file content processed by PHP
*/
public function load($path)
{
@@ -62,15 +62,17 @@
ob_start();
include($path);
$contents = ob_get_clean();
-
+
return $contents;
}
-
+
/**
* Dumps data to a file, or to STDOUT if no filename is given
*
- * @param string $data The file content
- * @param string $path Path of the file to create
+ * @param string $data The file content
+ * @param string $path Path of the file to create
+ *
+ * @return boolean
*/
public function dump($data, $path = null)
{
@@ -79,6 +81,8 @@
} else {
echo $data;
}
+
+ return true;
}
/**
@@ -94,7 +98,7 @@
if (!class_exists($class)) {
throw new PropelException(sprintf('Unknown parser class "%s"', $class));
}
-
+
return new $class;
}
}
Index: propel/parser/PropelXMLParser.php
===================================================================
--- propel/parser/PropelXMLParser.php (revision 2294)
+++ propel/parser/PropelXMLParser.php (working copy)
@@ -30,7 +30,7 @@
{
$rootNode = $this->getRootNode($rootElementName);
$this->arrayToDOM($array, $rootNode, $charset, false);
-
+
return $rootNode->ownerDocument->saveXML();
}
@@ -38,10 +38,10 @@
{
$rootNode = $this->getRootNode($rootElementName);
$this->arrayToDOM($array, $rootNode, $charset, true);
-
+
return $rootNode->ownerDocument->saveXML();
}
-
+
/**
* Create a DOMDocument and get the root DOMNode using a root element name
*
@@ -56,7 +56,7 @@
$xml->formatOutput = true;
$rootElement = $xml->createElement($rootElementName);
$xml->appendChild($rootElement);
-
+
return $rootElement;
}
@@ -88,13 +88,24 @@
return $this->listFromArray($array, $rootElementName, $charset);
}
+ /**
+ * @param array $array
+ * @param DOMElement $rootElement
+ * @param string $charset
+ * @param boolean $removeNumbersFromKeys
+ *
+ * @return DOMElement
+ */
protected function arrayToDOM($array, $rootElement, $charset = null, $removeNumbersFromKeys = false)
{
foreach ($array as $key => $value) {
if ($removeNumbersFromKeys) {
$key = preg_replace('/[^a-z]/i', '', $key);
}
+
+ /** @var $element DOMElement */
$element = $rootElement->ownerDocument->createElement($key);
+
if (is_array($value)) {
if (!empty($value)) {
$element = $this->arrayToDOM($value, $element, $charset);
@@ -116,7 +127,7 @@
return $rootElement;
}
-
+
/**
* Converts data from XML to an associative array.
*
@@ -141,11 +152,17 @@
{
return $this->toArray($data);
}
-
+
+ /**
+ * @param DOMNode $data
+ * @return array
+ */
protected function convertDOMElementToArray(DOMNode $data)
{
$array = array();
$elementNames = array();
+
+ /** @var $element DOMElement */
foreach ($data->childNodes as $element) {
if ($element->nodeType == XML_TEXT_NODE) {
continue;
@@ -176,8 +193,13 @@
return $array;
}
+ /**
+ * @param DomNode $node
+ * @return boolean
+ */
protected function hasOnlyTextNodes(DomNode $node)
{
+ /** @var $childNode DOMElement */
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeType != XML_CDATA_SECTION_NODE && $childNode->nodeType != XML_TEXT_NODE) {
return false;
Index: propel/map/ColumnMap.php
===================================================================
--- propel/map/ColumnMap.php (revision 2294)
+++ propel/map/ColumnMap.php (working copy)
@@ -25,7 +25,6 @@
*/
class ColumnMap
{
-
// Propel type of the column
protected $type;
@@ -68,8 +67,10 @@
/**
* Constructor.
*
- * @param string $name The name of the column.
- * @param TableMap containingTable TableMap of the table this column is in.
+ * @param string $name The name of the column.
+ * @param TableMap $containingTable TableMap of the table this column is in.
+ *
+ * @return ColumnMap
*/
public function __construct($name, TableMap $containingTable)
{
@@ -80,7 +81,7 @@
/**
* Get the name of a column.
*
- * @return string A String with the column name.
+ * @return string
*/
public function getName()
{
@@ -89,7 +90,8 @@
/**
* Get the table map this column belongs to.
- * @return TableMap
+ *
+ * @return TableMap
*/
public function getTable()
{
@@ -99,17 +101,17 @@
/**
* Get the name of the table this column is in.
*
- * @return string A String with the table name.
+ * @return string
*/
public function getTableName()
{
return $this->table->getName();
}
-
+
/**
* Get the table name + column name.
*
- * @return string A String with the full column name.
+ * @return string
*/
public function getFullyQualifiedName()
{
@@ -119,39 +121,38 @@
/**
* Set the php name of this column.
*
- * @param string $phpName A string representing the PHP name.
- * @return void
+ * @param string $phpName A string representing the PHP name.
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
-
+
/**
* Get the name of a column.
*
- * @return string A String with the column name.
+ * @return string
*/
public function getPhpName()
{
return $this->phpName;
}
-
+
/**
* Set the Propel type of this column.
*
- * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE).
- * @return void
+ * @param string $type A string representing the Propel type (e.g. PropelColumnTypes::DATE).
*/
public function setType($type)
{
$this->type = $type;
}
-
+
/**
* Get the Propel type of this column.
+ * A string representing the Propel type (e.g. PropelColumnTypes::DATE)
*
- * @return string A string representing the Propel type (e.g. PropelColumnTypes::DATE).
+ * @return string
*/
public function getType()
{
@@ -161,7 +162,7 @@
/**
* Get the PDO type of this column.
*
- * @return int The PDO::PARMA_* value
+ * @return integer
*/
public function getPdoType()
{
@@ -170,7 +171,8 @@
/**
* Whether this is a BLOB, LONGVARBINARY, or VARBINARY.
- * @return boolean
+ *
+ * @return boolean
*/
public function isLob()
{
@@ -180,22 +182,23 @@
/**
* Whether this is a DATE/TIME/TIMESTAMP column.
*
- * @return boolean
- * @since 1.3
+ * @since 1.3
+ * @return boolean
*/
public function isTemporal()
{
return ($this->type == PropelColumnTypes::TIMESTAMP || $this->type == PropelColumnTypes::DATE || $this->type == PropelColumnTypes::TIME || $this->type == PropelColumnTypes::BU_DATE || $this->type == PropelColumnTypes::BU_TIMESTAMP);
}
-
+
/**
* Whether this is a DATE/TIME/TIMESTAMP column that is post-epoch (1970).
*
* PHP cannot handle pre-epoch timestamps well -- hence the need to differentiate
* between epoch and pre-epoch timestamps.
*
- * @return boolean
* @deprecated Propel supports non-epoch dates
+ *
+ * @return boolean
*/
public function isEpochTemporal()
{
@@ -204,7 +207,8 @@
/**
* Whether this column is numeric (int, decimal, bigint etc).
- * @return boolean
+ *
+ * @return boolean
*/
public function isNumeric()
{
@@ -213,7 +217,8 @@
/**
* Whether this column is a text column (varchar, char, longvarchar).
- * @return boolean
+ *
+ * @return boolean
*/
public function isText()
{
@@ -223,18 +228,17 @@
/**
* Set the size of this column.
*
- * @param int $size An int specifying the size.
- * @return void
+ * @param integer $size An int specifying the size.
*/
public function setSize($size)
{
$this->size = $size;
}
-
+
/**
* Get the size of this column.
*
- * @return int An int specifying the size.
+ * @return integer An int specifying the size.
*/
public function getSize()
{
@@ -244,18 +248,17 @@
/**
* Set if this column is a primary key or not.
*
- * @param boolean $pk True if column is a primary key.
- * @return void
+ * @param boolean $pk True if column is a primary key.
*/
public function setPrimaryKey($pk)
{
$this->pk = $pk;
}
-
+
/**
* Is this column a primary key?
*
- * @return boolean True if column is a primary key.
+ * @return boolean True if column is a primary key.
*/
public function isPrimaryKey()
{
@@ -265,18 +268,17 @@
/**
* Set if this column may be null.
*
- * @param boolean nn True if column may be null.
- * @return void
+ * @param boolean $nn True if column may be null.
*/
public function setNotNull($nn)
{
$this->notNull = $nn;
}
-
+
/**
* Is null value allowed ?
*
- * @return boolean True if column may not be null.
+ * @return boolean
*/
public function isNotNull()
{
@@ -285,17 +287,18 @@
/**
* Sets the default value for this column.
- * @param mixed $defaultValue the default value for the column
- * @return void
+ *
+ * @param mixed $defaultValue The default value for the column
*/
public function setDefaultValue($defaultValue)
{
$this->defaultValue = $defaultValue;
}
-
+
/**
* Gets the default value for this column.
- * @return mixed String or NULL
+ *
+ * @return null|string
*/
public function getDefaultValue()
{
@@ -305,9 +308,8 @@
/**
* Set the foreign key for this column.
*
- * @param string tableName The name of the table that is foreign.
- * @param string columnName The name of the column that is foreign.
- * @return void
+ * @param string $tableName The name of the table that is foreign.
+ * @param string $columnName The name of the column that is foreign.
*/
public function setForeignKey($tableName, $columnName)
{
@@ -323,7 +325,7 @@
/**
* Is this column a foreign key?
*
- * @return boolean True if column is a foreign key.
+ * @return boolean
*/
public function isForeignKey()
{
@@ -333,16 +335,21 @@
return false;
}
}
-
+
/**
* Get the RelationMap object for this foreign key
+ *
+ * @return RelationMap
*/
public function getRelation()
{
- if(!$this->relatedTableName) return null;
- foreach ($this->getTable()->getRelations() as $name => $relation)
+ if (!$this->relatedTableName) {
+ return null;
+ }
+
+ foreach ($this->getTable()->getRelations() as $relation)
{
- if($relation->getType() == RelationMap::MANY_TO_ONE)
+ if ($relation->getType() == RelationMap::MANY_TO_ONE)
{
if ($relation->getForeignTable()->getName() == $this->getRelatedTableName()
&& array_key_exists($this->getFullyQualifiedName(), $relation->getColumnMappings()))
@@ -351,12 +358,14 @@
}
}
}
+
+ return null;
}
-
+
/**
* Get the table.column that this column is related to.
*
- * @return string A String with the full name for the related column.
+ * @return string
*/
public function getRelatedName()
{
@@ -366,7 +375,7 @@
/**
* Get the table name that this column is related to.
*
- * @return string A String with the name for the related table.
+ * @return string
*/
public function getRelatedTableName()
{
@@ -376,18 +385,18 @@
/**
* Get the column name that this column is related to.
*
- * @return string A String with the name for the related column.
+ * @return string
*/
public function getRelatedColumnName()
{
return $this->relatedColumnName;
}
-
+
/**
* Get the TableMap object that this column is related to.
*
- * @return TableMap The related TableMap object
- * @throws PropelException when called on a column with no foreign key
+ * @throws PropelException when called on a column with no foreign key
+ * @return TableMap The related TableMap object
*/
public function getRelatedTable()
{
@@ -397,67 +406,87 @@
throw new PropelException("Cannot fetch RelatedTable for column with no foreign key: " . $this->columnName);
}
}
-
+
/**
* Get the TableMap object that this column is related to.
*
- * @return ColumnMap The related ColumnMap object
- * @throws PropelException when called on a column with no foreign key
+ * @throws PropelException when called on a column with no foreign key
+ * @return ColumnMap The related ColumnMap object
*/
public function getRelatedColumn()
{
return $this->getRelatedTable()->getColumn($this->relatedColumnName);
}
+ /**
+ * @param string $validator
+ */
public function addValidator($validator)
{
$this->validators[] = $validator;
}
+ /**
+ * @return boolean
+ */
public function hasValidators()
{
return count($this->validators) > 0;
}
+ /**
+ * @return array|ValidatorMap[]
+ */
public function getValidators()
{
return $this->validators;
}
-
+
/**
* Set the valueSet of this column (only valid for ENUM columns).
*
- * @param array $values A list of allowed values
+ * @param array $values A list of allowed values
*/
public function setValueSet($values)
{
$this->valueSet = $values;
}
-
+
/**
* Get the valueSet of this column (only valid for ENUM columns).
*
- * @return array A list of allowed values
+ * @return array
*/
public function getValueSet()
{
return $this->valueSet;
}
-
+
+ /**
+ * @param mixed $value
+ * @return boolean
+ */
public function isInValueSet($value)
{
return in_array($value, $this->valueSet);
}
-
+
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
public function getValueSetKey($value)
{
return array_search($value, $this->valueSet);
}
-
+
/**
* Performs DB-specific ignore case, but only if the column type necessitates it.
- * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name).
- * @param DBAdapter $db
+ *
+ * @param string $str The expression we want to apply the ignore case formatting to (e.g. the column name).
+ * @param DBAdapter $db
+ *
+ * @return string
*/
public function ignoreCase($str, DBAdapter $db)
{
@@ -467,14 +496,14 @@
return $str;
}
}
-
+
/**
* Normalizes the column name, removing table prefix and uppercasing.
*
* article.first_name becomes FIRST_NAME
*
- * @param string $name
- * @return string Normalized column name.
+ * @param string $name
+ * @return string
*/
public static function normalizeName($name)
{
@@ -484,11 +513,11 @@
$name = strtoupper($name);
return $name;
}
-
+
/**
* Set this column to be a primaryString column.
*
- * @param boolean $pkString
+ * @param boolean $pkString
*/
public function setPrimaryString($pkString)
{
@@ -498,20 +527,19 @@
/**
* Is this column a primaryString column?
*
- * @return boolean True, if this column is the primaryString column.
+ * @return boolean
*/
public function isPrimaryString()
{
return $this->isPkString;
}
- // deprecated methods
-
/**
* Gets column name
+ *
* @deprecated Use getName() instead
+ *
* @return string
- * @deprecated Use getName() instead.
*/
public function getColumnName()
{
Index: propel/map/RelationMap.php
===================================================================
--- propel/map/RelationMap.php (revision 2294)
+++ propel/map/RelationMap.php (working copy)
@@ -24,40 +24,51 @@
*/
class RelationMap
{
+ /**
+ * Types
+ */
+ const
+ MANY_TO_ONE = 1,
+ ONE_TO_MANY = 2,
+ ONE_TO_ONE = 3,
+ MANY_TO_MANY = 4;
+ /**
+ * Representations
+ */
const
- // types
- MANY_TO_ONE = 1,
- ONE_TO_MANY = 2,
- ONE_TO_ONE = 3,
- MANY_TO_MANY = 4,
- // representations
LOCAL_TO_FOREIGN = 0,
- LEFT_TO_RIGHT = 1;
-
- protected
- $name,
- $type,
- $localTable,
- $foreignTable,
- $localColumns = array(),
- $foreignColumns = array(),
+ LEFT_TO_RIGHT = 1;
+
+ protected
+ $name, $type,
+ $localTable, $foreignTable,
$onUpdate, $onDelete;
/**
+ * @var array|ColumnMap[]
+ */
+ protected $localColumns = array();
+
+ /**
+ * @var array|ColumnMap[]
+ */
+ protected $foreignColumns = array();
+
+ /**
* Constructor.
*
- * @param string $name Name of the relation.
+ * @param string $name Name of the relation.
*/
public function __construct($name)
{
$this->name = $name;
}
-
+
/**
* Get the name of this relation.
*
- * @return string The name of the relation.
+ * @return string
*/
public function getName()
{
@@ -67,7 +78,7 @@
/**
* Set the type
*
- * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE)
+ * @param integer $type The relation type (either self::MANY_TO_ONE, self::ONE_TO_MANY, or self::ONE_TO_ONE)
*/
public function setType($type)
{
@@ -77,7 +88,7 @@
/**
* Get the type
*
- * @return integer the relation type
+ * @return integer
*/
public function getType()
{
@@ -87,7 +98,7 @@
/**
* Set the local table
*
- * @param TableMap $table The local table for this relationship
+ * @param TableMap $table The local table for this relationship
*/
public function setLocalTable($table)
{
@@ -95,9 +106,9 @@
}
/**
- * Get the local table
+ * Get the local table for this relationship
*
- * @return TableMap The local table for this relationship
+ * @return TableMap
*/
public function getLocalTable()
{
@@ -107,7 +118,7 @@
/**
* Set the foreign table
*
- * @param TableMap $table The foreign table for this relationship
+ * @param TableMap $table The foreign table for this relationship
*/
public function setForeignTable($table)
{
@@ -115,19 +126,19 @@
}
/**
- * Get the foreign table
+ * Get the foreign table for this relationship
*
- * @return TableMap The foreign table for this relationship
+ * @return TableMap
*/
public function getForeignTable()
{
return $this->foreignTable;
}
-
+
/**
- * Get the left table of the relation
+ * Get the left table for this relationship
*
- * @return TableMap The left table for this relationship
+ * @return TableMap
*/
public function getLeftTable()
{
@@ -135,35 +146,36 @@
}
/**
- * Get the right table of the relation
+ * Get the right table for this relationship
*
- * @return TableMap The right table for this relationship
+ * @return TableMap
*/
public function getRightTable()
{
return ($this->getType() == RelationMap::MANY_TO_ONE) ? $this->getForeignTable() : $this->getLocalTable();
}
-
+
/**
* Add a column mapping
*
- * @param ColumnMap $local The local column
- * @param ColumnMap $foreign The foreign column
+ * @param ColumnMap $local The local column
+ * @param ColumnMap $foreign The foreign column
*/
public function addColumnMapping(ColumnMap $local, ColumnMap $foreign)
{
$this->localColumns[] = $local;
$this->foreignColumns[] = $foreign;
}
-
+
/**
- * Get an associative array mapping local column names to foreign column names
+ * Get an associative array (local => foreign) of fully qualified column names
* The arrangement of the returned array depends on the $direction parameter:
* - If the value is RelationMap::LOCAL_TO_FOREIGN, then the returned array is local => foreign
* - If the value is RelationMap::LEFT_TO_RIGHT, then the returned array is left => right
*
- * @param int $direction How the associative array must return columns
- * @return Array Associative array (local => foreign) of fully qualified column names
+ * @param integer $direction How the associative array must return columns
+ *
+ * @return array
*/
public function getColumnMappings($direction = RelationMap::LOCAL_TO_FOREIGN)
{
@@ -178,53 +190,54 @@
$h[$this->foreignColumns[$i]->getFullyQualifiedName()] = $this->localColumns[$i]->getFullyQualifiedName();
}
}
+
return $h;
}
-
+
/**
* Returns true if the relation has more than one column mapping
*
- * @return boolean
+ * @return boolean
*/
public function isComposite()
{
return $this->countColumnMappings() > 1;
}
-
+
/**
* Return the number of column mappings
*
- * @return int
+ * @return integer
*/
public function countColumnMappings()
{
return count($this->localColumns);
}
-
+
/**
- * Get the local columns
+ * Get the local ColumnMap objects
*
- * @return Array list of ColumnMap objects
+ * @return array|ColumnMap[]
*/
public function getLocalColumns()
{
return $this->localColumns;
}
-
+
/**
- * Get the foreign columns
+ * Get the foreign list of ColumnMap objects
*
- * @return Array list of ColumnMap objects
+ * @return array|ColumnMap[]
*/
public function getForeignColumns()
{
return $this->foreignColumns;
}
-
+
/**
* Get the left columns of the relation
*
- * @return array of ColumnMap objects
+ * @return array|ColumnMap[]
*/
public function getLeftColumns()
{
@@ -234,7 +247,7 @@
/**
* Get the right columns of the relation
*
- * @return array of ColumnMap objects
+ * @return array|ColumnMap[]
*/
public function getRightColumns()
{
@@ -245,7 +258,7 @@
/**
* Set the onUpdate behavior
*
- * @param string $onUpdate
+ * @param string $onUpdate
*/
public function setOnUpdate($onUpdate)
{
@@ -253,19 +266,19 @@
}
/**
- * Get the onUpdate behavior
+ * Get the onUpdate relation type
*
- * @return integer the relation type
+ * @return integer
*/
public function getOnUpdate()
{
return $this->onUpdate;
}
-
+
/**
* Set the onDelete behavior
*
- * @param string $onDelete
+ * @param string $onDelete
*/
public function setOnDelete($onDelete)
{
@@ -273,15 +286,15 @@
}
/**
- * Get the onDelete behavior
+ * Get the onDelete relation type
*
- * @return integer the relation type
+ * @return integer
*/
public function getOnDelete()
{
return $this->onDelete;
}
-
+
/**
* Gets the symmetrical relation
*
@@ -290,10 +303,13 @@
public function getSymmetricalRelation()
{
$localMapping = array($this->getLeftColumns(), $this->getRightColumns());
+
foreach ($this->getRightTable()->getRelations() as $relation) {
if ($localMapping == array($relation->getRightColumns(), $relation->getLeftColumns())) {
return $relation;
}
}
+
+ return null;
}
}
Index: propel/map/DatabaseMap.php
===================================================================
--- propel/map/DatabaseMap.php (revision 2294)
+++ propel/map/DatabaseMap.php (working copy)
@@ -26,52 +26,51 @@
*/
class DatabaseMap
{
-
/** @var string Name of the database. */
protected $name;
- /** @var array TableMap[] Tables in the database, using table name as key */
+ /** @var array|TableMap[] Tables in the database, using table name as key */
protected $tables = array();
-
- /** @var array TableMap[] Tables in the database, using table phpName as key */
+
+ /** @var array|TableMap[] Tables in the database, using table phpName as key */
protected $tablesByPhpName = array();
/**
* Constructor.
*
- * @param string $name Name of the database.
+ * @param string $name The name of the database.
*/
public function __construct($name)
{
$this->name = $name;
}
-
+
/**
* Get the name of this database.
*
- * @return string The name of the database.
+ * @return string
*/
public function getName()
{
return $this->name;
}
-
+
/**
* Add a new table to the database by name.
*
- * @param string $tableName The name of the table.
- * @return TableMap The newly created TableMap.
+ * @param string $tableName The name of the table.
+ * @return TableMap
*/
public function addTable($tableName)
{
$this->tables[$tableName] = new TableMap($tableName, $this);
return $this->tables[$tableName];
}
-
+
/**
* Add a new table object to the database.
*
- * @param TableMap $table The table to add
+ * @param TableMap $table The table to add
*/
public function addTableObject(TableMap $table)
{
@@ -79,29 +78,31 @@
$this->tables[$table->getName()] = $table;
$this->tablesByPhpName[$table->getClassname()] = $table;
}
-
+
/**
* Add a new table to the database, using the tablemap class name.
*
- * @param string $tableMapClass The name of the table map to add
- * @return TableMap The TableMap object
+ * @param string $tableMapClass The name of the table map to add
+ * @return TableMap
*/
public function addTableFromMapClass($tableMapClass)
{
+ /** @var $table TableMap */
$table = new $tableMapClass();
- if(!$this->hasTable($table->getName())) {
+
+ if (!$this->hasTable($table->getName())) {
$this->addTableObject($table);
return $table;
} else {
return $this->getTable($table->getName());
}
}
-
+
/**
* Does this database contain this specific table?
*
- * @param string $name The String representation of the table.
- * @return boolean True if the database contains the table.
+ * @param string $name The String representation of the table.
+ * @return boolean
*/
public function hasTable($name)
{
@@ -114,9 +115,10 @@
/**
* Get a TableMap for the table by name.
*
- * @param string $name Name of the table.
- * @return TableMap A TableMap
+ * @param string $name The name of the table.
+ *
* @throws PropelException if the table is undefined
+ * @return TableMap
*/
public function getTable($name)
{
@@ -129,7 +131,7 @@
/**
* Get a TableMap[] of all of the tables in the database.
*
- * @return array A TableMap[].
+ * @return array|TableMap[]
*/
public function getTables()
{
@@ -140,30 +142,38 @@
* Get a ColumnMap for the column by name.
* Name must be fully qualified, e.g. book.AUTHOR_ID
*
- * @param $qualifiedColumnName Name of the column.
- * @return ColumnMap A TableMap
+ * @param string $qualifiedColumnName Name of the column.
+ *
* @throws PropelException if the table is undefined, or if the table is undefined
- */
+ * @return ColumnMap
+ */
public function getColumn($qualifiedColumnName)
{
list($tableName, $columnName) = explode('.', $qualifiedColumnName);
return $this->getTable($tableName)->getColumn($columnName, false);
}
-
+
// deprecated methods
-
+
/**
* Does this database contain this specific table?
*
* @deprecated Use hasTable() instead
- * @param string $name The String representation of the table.
- * @return boolean True if the database contains the table.
+ *
+ * @param string $name The String representation of the table.
+ * @return boolean
*/
public function containsTable($name)
{
return $this->hasTable($name);
}
-
+
+ /**
+ * @throws PropelException
+ * @param string $phpName
+ *
+ * @return TableMap
+ */
public function getTableByPhpName($phpName)
{
if (array_key_exists($phpName, $this->tablesByPhpName)) {
@@ -178,14 +188,16 @@
throw new PropelException("Cannot fetch TableMap for undefined table phpName: " . $phpName);
}
}
-
- /**
- * Convenience method to get the DBAdapter registered with Propel for this database.
+
+ /**
+ * Convenience method to get the DBAdapter registered with Propel for this database.
+ *
+ * @see Propel::getDB()
+ *
* @return DBAdapter
- * @see Propel::getDB(string)
- */
+ */
public function getDBAdapter()
{
return Propel::getDB($this->name);
- }
+ }
}
Index: propel/map/ValidatorMap.php
===================================================================
--- propel/map/ValidatorMap.php (revision 2294)
+++ propel/map/ValidatorMap.php (working copy)
@@ -26,65 +26,104 @@
{
/** rule name of this validator */
private $name;
+
/** the dot-path to class to use for validator */
private $classname;
+
/** value to check against */
private $value;
+
/** execption message thrown on invalid input */
private $message;
- /** related column */
+
+ /**
+ * @var ColumnMap Related column
+ */
private $column;
+ /**
+ * @param ColumnMap $containingColumn
+ */
public function __construct($containingColumn)
{
$this->column = $containingColumn;
}
+ /**
+ * @return ColumnMap
+ */
public function getColumn()
{
return $this->column;
}
+ /**
+ * @return string
+ */
public function getColumnName()
{
return $this->column->getColumnName();
}
+ /**
+ * @param string $name
+ */
public function setName($name)
{
$this->name = $name;
}
+ /**
+ * @param string $classname
+ */
public function setClass($classname)
{
$this->classname = $classname;
}
+ /**
+ * @param string $value
+ */
public function setValue($value)
{
$this->value = $value;
}
+ /**
+ * @param string $message
+ */
public function setMessage($message)
{
$this->message = $message;
}
+ /**
+ * @return string
+ */
public function getName()
{
return $this->name;
}
+ /**
+ * @return string
+ */
public function getClass()
{
return $this->classname;
}
+ /**
+ * @return string
+ */
public function getValue()
{
return $this->value;
}
+ /**
+ * @return string
+ */
public function getMessage()
{
return $this->message;
Index: propel/map/TableMap.php
===================================================================
--- propel/map/TableMap.php (revision 2294)
+++ propel/map/TableMap.php (working copy)
@@ -26,58 +26,97 @@
*/
class TableMap
{
-
/**
- * Columns in the table
- * @var array TableMap[]
+ * Columns in the table
+ * @var array TableMap[]
*/
protected $columns = array();
/**
- * Columns in the table, using table phpName as key
- * @var array TableMap[]
+ * Columns in the table, using table phpName as key
+ * @var array TableMap[]
*/
protected $columnsByPhpName = array();
- // The database this table belongs to
+ /**
+ * The database this table belongs to
+ * @var DatabaseMap
+ */
protected $dbMap;
- // The name of the table
+ /**
+ * The name of the table
+ * @var string
+ */
protected $tableName;
- // The PHP name of the table
+ /**
+ * The PHP name of the table
+ * @var string
+ */
protected $phpName;
- // The Classname for this table
+ /**
+ * The Classname for this table
+ * @var string
+ */
protected $classname;
- // The Package for this table
+ /**
+ * The Package for this table
+ * @var string
+ */
protected $package;
-
- // Whether to use an id generator for pkey
+
+ /**
+ * Whether to use an id generator for pkey
+ * @var boolean
+ */
protected $useIdGenerator;
- // Whether the table uses single table inheritance
+ /**
+ * Whether the table uses single table inheritance
+ * @var boolean
+ */
protected $isSingleTableInheritance = false;
-
- // The primary key columns in the table
+
+ /**
+ * The primary key columns in the table
+ * @var array
+ */
protected $primaryKeys = array();
-
- // The foreign key columns in the table
+
+ /**
+ * The foreign key columns in the table
+ * @var array
+ */
protected $foreignKeys = array();
- // The relationships in the table
+ /**
+ * The relationships in the table
+ * @var array
+ */
protected $relations = array();
- // Relations are lazy loaded. This property tells if the relations are loaded or not
+ /**
+ * Relations are lazy loaded. This property tells if the relations are loaded or not
+ * @var boolean
+ */
protected $relationsBuilt = false;
-
- // Object to store information that is needed if the for generating primary keys
+
+ /**
+ * Object to store information that is needed if the for generating primary keys
+ * @var Object
+ */
protected $pkInfo;
-
+
/**
* Construct a new TableMap.
*
+ * @param string $name
+ * @param DatabaseMap $dbMap
+ *
+ * @return TableMap
*/
public function __construct($name = null, $dbMap = null)
{
@@ -89,7 +128,7 @@
}
$this->initialize();
}
-
+
/**
* Initialize the TableMap to build columns, relations, etc
* This method should be overridden by descendents
@@ -107,11 +146,11 @@
{
$this->dbMap = $dbMap;
}
-
+
/**
* Get the DatabaseMap containing this TableMap.
*
- * @return DatabaseMap A DatabaseMap.
+ * @return DatabaseMap A DatabaseMap.
*/
public function getDatabaseMap()
{
@@ -121,17 +160,17 @@
/**
* Set the name of the Table.
*
- * @param string $name The name of the table.
+ * @param string $name The name of the table.
*/
public function setName($name)
{
$this->tableName = $name;
}
-
+
/**
* Get the name of the Table.
*
- * @return string A String with the name of the table.
+ * @return string A String with the name of the table.
*/
public function getName()
{
@@ -141,17 +180,17 @@
/**
* Set the PHP name of the Table.
*
- * @param string $phpName The PHP Name for this table
+ * @param string $phpName The PHP Name for this table
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
-
+
/**
* Get the PHP name of the Table.
*
- * @return string A String with the name of the table.
+ * @return string A String with the name of the table.
*/
public function getPhpName()
{
@@ -161,7 +200,7 @@
/**
* Set the Classname of the Table. Could be useful for calling
* Peer and Object methods dynamically.
- * @param string $classname The Classname
+ * @param string $classname The Classname
*/
public function setClassname($classname)
{
@@ -170,26 +209,26 @@
/**
* Get the Classname of the Propel Class belonging to this table.
- * @return string
+ * @return string
*/
public function getClassname()
{
return $this->classname;
}
-
+
/**
* Get the Peer Classname of the Propel Class belonging to this table.
- * @return string
+ * @return string
*/
public function getPeerClassname()
{
return constant($this->classname . '::PEER');
}
-
+
/**
* Set the Package of the Table
*
- * @param string $package The Package
+ * @param string $package The Package
*/
public function setPackage($package)
{
@@ -198,16 +237,16 @@
/**
* Get the Package of the table.
- * @return string
+ * @return string
*/
public function getPackage()
{
return $this->package;
}
-
+
/**
* Set whether or not to use Id generator for primary key.
- * @param boolean $bit
+ * @param boolean $bit
*/
public function setUseIdGenerator($bit)
{
@@ -216,7 +255,7 @@
/**
* Whether to use Id generator for primary key.
- * @return boolean
+ * @return boolean
*/
public function isUseIdGenerator()
{
@@ -225,7 +264,7 @@
/**
* Set whether or not to this table uses single table inheritance
- * @param boolean $bit
+ * @param boolean $bit
*/
public function setSingleTableInheritance($bit)
{
@@ -234,7 +273,7 @@
/**
* Whether this table uses single table inheritance
- * @return boolean
+ * @return boolean
*/
public function isSingleTableInheritance()
{
@@ -244,17 +283,17 @@
/**
* Sets the name of the sequencxe used to generate a key
*
- * @param $pkInfo information needed to generate a key
+ * @param Object $pkInfo information needed to generate a key
*/
public function setPrimaryKeyMethodInfo($pkInfo)
{
$this->pkInfo = $pkInfo;
}
-
+
/**
* Get the name of the sequence used to generate a primary key
*
- * @return An Object.
+ * @return Object
*/
public function getPrimaryKeyMethodInfo()
{
@@ -264,15 +303,17 @@
/**
* Add a column to the table.
*
- * @param string name A String with the column name.
- * @param string $type A string specifying the Propel type.
- * @param boolean $isNotNull Whether column does not allow NULL values.
- * @param int $size An int specifying the size.
- * @param boolean $pk True if column is a primary key.
- * @param string $fkTable A String with the foreign key table name.
- * @param $fkColumn A String with the foreign key column name.
- * @param string $defaultValue The default value for this column.
- * @return ColumnMap The newly created column.
+ * @param string $name A String with the column name.
+ * @param string $phpName
+ * @param string $type A string specifying the Propel type.
+ * @param boolean $isNotNull Whether column does not allow NULL values.
+ * @param integer $size An int specifying the size.
+ * @param string $defaultValue The default value for this column.
+ * @param boolean $pk True if column is a primary key.
+ * @param string $fkTable A String with the foreign key table name.
+ * @param string $fkColumn A String with the foreign key column name.
+ *
+ * @return ColumnMap The newly created column.
*/
public function addColumn($name, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null, $pk = false, $fkTable = null, $fkColumn = null)
{
@@ -287,37 +328,38 @@
$col->setPrimaryKey(true);
$this->primaryKeys[$name] = $col;
}
-
+
if ($fkTable && $fkColumn) {
$col->setForeignKey($fkTable, $fkColumn);
$this->foreignKeys[$name] = $col;
}
-
+
$this->columns[$name] = $col;
$this->columnsByPhpName[$phpName] = $col;
return $col;
}
-
+
/**
* Add a pre-created column to this table. It will replace any
* existing column.
*
- * @param ColumnMap $cmap A ColumnMap.
- * @return ColumnMap The added column map.
+ * @param ColumnMap $cmap A ColumnMap.
+ * @return ColumnMap The added column map.
*/
public function addConfiguredColumn($cmap)
{
$this->columns[ $cmap->getColumnName() ] = $cmap;
return $cmap;
}
-
+
/**
* Does this table contain the specified column?
*
- * @param mixed $name name of the column or ColumnMap instance
- * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
- * @return boolean True if the table contains the column.
+ * @param string|ColumnMap $name name of the column or ColumnMap instance
+ * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
+ *
+ * @return boolean True if the table contains the column.
*/
public function hasColumn($name, $normalize = true)
{
@@ -328,13 +370,13 @@
}
return isset($this->columns[$name]);
}
-
+
/**
* Get a ColumnMap for the table.
*
- * @param string $name A String with the name of the table.
- * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
- * @return ColumnMap A ColumnMap.
+ * @param string $name A String with the name of the table.
+ * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
+ * @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumn($name, $normalize = true)
@@ -351,19 +393,19 @@
/**
* Does this table contain the specified column?
*
- * @param mixed $phpName name of the column
- * @return boolean True if the table contains the column.
+ * @param mixed $phpName name of the column
+ * @return boolean True if the table contains the column.
*/
public function hasColumnByPhpName($phpName)
{
return isset($this->columnsByPhpName[$phpName]);
}
-
+
/**
* Get a ColumnMap for the table.
*
- * @param string $phpName A String with the name of the table.
- * @return ColumnMap A ColumnMap.
+ * @param string $phpName A String with the name of the table.
+ * @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumnByPhpName($phpName)
@@ -373,11 +415,11 @@
}
return $this->columnsByPhpName[$phpName];
}
-
+
/**
* Get a ColumnMap[] of the columns in this table.
*
- * @return array A ColumnMap[].
+ * @return array|ColumnMap[]
*/
public function getColumns()
{
@@ -387,11 +429,14 @@
/**
* Add a primary key column to this Table.
*
- * @param string $columnName A String with the column name.
- * @param string $type A string specifying the Propel type.
- * @param boolean $isNotNull Whether column does not allow NULL values.
- * @param $size An int specifying the size.
- * @return ColumnMap Newly added PrimaryKey column.
+ * @param string $columnName A String with the column name.
+ * @param string $phpName
+ * @param string $type A string specifying the Propel type.
+ * @param boolean $isNotNull Whether column does not allow NULL values.
+ * @param integer $size An int specifying the size.
+ * @param mixed $defaultValue
+ *
+ * @return ColumnMap Newly added PrimaryKey column.
*/
public function addPrimaryKey($columnName, $phpName, $type, $isNotNull = false, $size = null, $defaultValue = null)
{
@@ -401,14 +446,16 @@
/**
* Add a foreign key column to the table.
*
- * @param string $columnName A String with the column name.
- * @param string $type A string specifying the Propel type.
- * @param string $fkTable A String with the foreign key table name.
- * @param string $fkColumn A String with the foreign key column name.
- * @param boolean $isNotNull Whether column does not allow NULL values.
- * @param int $size An int specifying the size.
- * @param string $defaultValue The default value for this column.
- * @return ColumnMap Newly added ForeignKey column.
+ * @param string $columnName A String with the column name.
+ * @param string $phpName
+ * @param string $type A string specifying the Propel type.
+ * @param string $fkTable A String with the foreign key table name.
+ * @param string $fkColumn A String with the foreign key column name.
+ * @param boolean $isNotNull Whether column does not allow NULL values.
+ * @param integer $size An int specifying the size.
+ * @param string $defaultValue The default value for this column.
+ *
+ * @return ColumnMap Newly added ForeignKey column.
*/
public function addForeignKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null)
{
@@ -418,34 +465,36 @@
/**
* Add a foreign primary key column to the table.
*
- * @param string $columnName A String with the column name.
- * @param string $type A string specifying the Propel type.
- * @param string $fkTable A String with the foreign key table name.
- * @param string $fkColumn A String with the foreign key column name.
- * @param boolean $isNotNull Whether column does not allow NULL values.
- * @param int $size An int specifying the size.
- * @param string $defaultValue The default value for this column.
- * @return ColumnMap Newly created foreign pkey column.
+ * @param string $columnName A String with the column name.
+ * @param string $phpName
+ * @param string $type A string specifying the Propel type.
+ * @param string $fkTable A String with the foreign key table name.
+ * @param string $fkColumn A String with the foreign key column name.
+ * @param boolean $isNotNull Whether column does not allow NULL values.
+ * @param integer $size An int specifying the size.
+ * @param string $defaultValue The default value for this column.
+ *
+ * @return ColumnMap Newly created foreign pkey column.
*/
public function addForeignPrimaryKey($columnName, $phpName, $type, $fkTable, $fkColumn, $isNotNull = false, $size = 0, $defaultValue = null)
{
return $this->addColumn($columnName, $phpName, $type, $isNotNull, $size, $defaultValue, true, $fkTable, $fkColumn);
}
-
+
/**
* Returns array of ColumnMap objects that make up the primary key for this table
*
- * @return array ColumnMap[]
+ * @return array ColumnMap[]
*/
public function getPrimaryKeys()
{
return $this->primaryKeys;
}
-
+
/**
* Returns array of ColumnMap objects that are foreign keys for this table
*
- * @return array ColumnMap[]
+ * @return array ColumnMap[]
*/
public function getForeignKeys()
{
@@ -455,12 +504,12 @@
/**
* Add a validator to a table's column
*
- * @param string $columnName The name of the validator's column
- * @param string $name The rule name of this validator
- * @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
- * @param string $value
- * @param string $message The error message which is returned on invalid values
- * @return void
+ * @param string $columnName The name of the validator's column
+ * @param string $name The rule name of this validator
+ * @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
+ * @param string $value
+ * @param string $message The error message which is returned on invalid values
+ * @return void
*/
public function addValidator($columnName, $name, $classname, $value, $message)
{
@@ -478,7 +527,7 @@
$col->addValidator($validator);
}
}
-
+
/**
* Build relations
* Relations are lazy loaded for performance reasons
@@ -486,16 +535,19 @@
*/
public function buildRelations()
{
- }
-
+ }
+
/**
* Adds a RelationMap to the table
- *
- * @param string $name The relation name
- * @param string $tablePhpName The related table name
- * @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE)
- * @param array $columnMapping An associative array mapping column names (local => foreign)
- * @return RelationMap the built RelationMap object
+ *
+ * @param string $name The relation name
+ * @param string $tablePhpName The related table name
+ * @param integer $type The relation type (either RelationMap::MANY_TO_ONE, RelationMap::ONE_TO_MANY, or RelationMAp::ONE_TO_ONE)
+ * @param array $columnMapping An associative array mapping column names (local => foreign)
+ * @param string $onDelete
+ * @param string $onUpdate
+ *
+ * @return RelationMap The built RelationMap object
*/
public function addRelation($name, $tablePhpName, $type, $columnMapping = array(), $onDelete = null, $onUpdate = null)
{
@@ -529,20 +581,20 @@
* Gets a RelationMap of the table by relation name
* This method will build the relations if they are not built yet
*
- * @param String $name The relation name
- * @return boolean true if the relation exists
+ * @param String $name The relation name
+ * @return boolean true if the relation exists
*/
public function hasRelation($name)
{
return array_key_exists($name, $this->getRelations());
}
-
+
/**
* Gets a RelationMap of the table by relation name
* This method will build the relations if they are not built yet
*
- * @param String $name The relation name
- * @return RelationMap The relation object
+ * @param String $name The relation name
+ * @return RelationMap The relation object
* @throws PropelException When called on an inexistent relation
*/
public function getRelation($name)
@@ -557,8 +609,8 @@
/**
* Gets the RelationMap objects of the table
* This method will build the relations if they are not built yet
- *
- * @return Array list of RelationMap objects
+ *
+ * @return array|RelationMap[] An array list of RelationMap objects
*/
public function getRelations()
{
@@ -567,11 +619,12 @@
$this->buildRelations();
$this->relationsBuilt = true;
}
+
return $this->relations;
}
/**
- *
+ *
* Gets the list of behaviors registered for this table
*
* @return array
@@ -584,7 +637,7 @@
/**
* Does this table has a primaryString column?
*
- * @return boolean True if the table has a primaryString column.
+ * @return boolean True if the table has a primaryString column.
*/
public function hasPrimaryStringColumn()
{
@@ -594,7 +647,7 @@
/**
* Gets the ColumnMap for the primary string column.
*
- * @return ColumnMap
+ * @return null|ColumnMap
*/
public function getPrimaryStringColumn()
{
@@ -603,51 +656,55 @@
return $column;
}
}
+
+ return null;
}
// Deprecated methods and attributres, to be removed
-
+
/**
* Does this table contain the specified column?
*
* @deprecated Use hasColumn instead
- * @param mixed $name name of the column or ColumnMap instance
- * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
- * @return boolean True if the table contains the column.
+ *
+ * @param mixed $name name of the column or ColumnMap instance
+ * @param boolean $normalize Normalize the column name (if column name not like FIRST_NAME)
+ *
+ * @return boolean True if the table contains the column.
*/
public function containsColumn($name, $normalize = true)
{
return $this->hasColumn($name, $normalize);
}
-
+
/**
* Normalizes the column name, removing table prefix and uppercasing.
* article.first_name becomes FIRST_NAME
*
* @deprecated Use ColumnMap::normalizeColumName() instead
- * @param string $name
- * @return string Normalized column name.
+ * @param string $name
+ * @return string Normalized column name.
*/
protected function normalizeColName($name)
{
return ColumnMap::normalizeName($name);
}
-
+
/**
* Returns array of ColumnMap objects that make up the primary key for this table.
*
* @deprecated Use getPrimaryKeys instead
- * @return array ColumnMap[]
+ * @return array ColumnMap[]
*/
public function getPrimaryKeyColumns()
{
return array_values($this->primaryKeys);
}
-
+
//---Utility methods for doing intelligent lookup of table names
- /**
- * The prefix on the table name.
+ /**
+ * The prefix on the table name.
* @deprecated Not used anywhere in Propel
*/
private $prefix;
@@ -656,7 +713,7 @@
* Get table prefix name.
*
* @deprecated Not used anywhere in Propel
- * @return string A String with the prefix.
+ * @return string A String with the prefix.
*/
public function getPrefix()
{
@@ -667,21 +724,21 @@
* Set table prefix name.
*
* @deprecated Not used anywhere in Propel
- * @param string $prefix The prefix for the table name (ie: SCARAB for
+ * @param string $prefix The prefix for the table name (ie: SCARAB for
* SCARAB_PROJECT).
- * @return void
+ * @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
-
+
/**
* Tell me if i have PREFIX in my string.
*
* @deprecated Not used anywhere in Propel
- * @param data A String.
- * @return boolean True if prefix is contained in data.
+ * @param data A String.
+ * @return boolean True if prefix is contained in data.
*/
protected function hasPrefix($data)
{
@@ -692,8 +749,8 @@
* Removes the PREFIX if found
*
* @deprecated Not used anywhere in Propel
- * @param string $data A String.
- * @return string A String with data, but with prefix removed.
+ * @param string $data A String.
+ * @return string A String with data, but with prefix removed.
*/
protected function removePrefix($data)
{
@@ -707,8 +764,8 @@
* SCARAB_FOO_BAR becomes FooBar.
*
* @deprecated Not used anywhere in Propel. At buildtime, use Column::generatePhpName() for that purpose
- * @param data A String.
- * @return string A String with data processed.
+ * @param data A String.
+ * @return string A String with data processed.
*/
public final function removeUnderScores($data)
{
@@ -726,8 +783,8 @@
* Makes the first letter caps and the rest lowercase.
*
* @deprecated Not used anywhere in Propel.
- * @param string $data A String.
- * @return string A String with data processed.
+ * @param string $data A String.
+ * @return string A String with data processed.
*/
private function firstLetterCaps($data)
{
Index: propel/util/PropelDateTime.php
===================================================================
--- propel/util/PropelDateTime.php (revision 2294)
+++ propel/util/PropelDateTime.php (working copy)
@@ -34,7 +34,7 @@
* @var string
*/
private $tzString;
-
+
/**
* Factory method to get a DateTime object from a temporal input
*
@@ -56,6 +56,7 @@
}
try {
if (is_numeric($value)) { // if it's a unix timestamp
+ /** @var $dateTimeObject DateTime */
$dateTimeObject = new $dateTimeClass('@' . $value, new DateTimeZone('UTC'));
// timezone must be explicitly specified and then changed
// because of a DateTime bug: http://bugs.php.net/bug.php?id=43003
@@ -73,7 +74,7 @@
}
return $dateTimeObject;
}
-
+
/**
* PHP "magic" function called when object is serialized.
* Sets an internal property with the date string and returns properties
Index: propel/util/PropelPager.php
===================================================================
--- propel/util/PropelPager.php (revision 2294)
+++ propel/util/PropelPager.php (working copy)
@@ -98,11 +98,16 @@
private $peerClass;
private $peerSelectMethod;
private $peerCountMethod;
+
+ /** @var Criteria */
private $criteria;
+
+ /** @var Criteria */
private $countCriteria;
+
private $page;
- private $rs = null;
-
+ private $rs = array();
+
//Iterator vars
private $currentKey = 0;
@@ -244,7 +249,7 @@
$selectMethod = $this->getPeerSelectMethod();
if ($selectMethod == 'doSelect') {
$countMethod = 'doCount';
- } elseif ( ($pos = stripos($selectMethod, 'doSelectJoin')) === 0) {
+ } elseif ((stripos($selectMethod, 'doSelectJoin')) === 0) {
$countMethod = 'doCount' . substr($selectMethod, strlen('doSelect'));
} else {
// we will fall back to doCount() if we don't understand the join
@@ -356,7 +361,6 @@
*/
public function getPrevLinks($range = 5)
{
- $total = $this->getTotalPages();
$start = $this->getPage() - 1;
$end = $this->getPage() - $range;
$first = $this->getFirstPage();
@@ -379,7 +383,6 @@
*/
public function getNextLinks($range = 5)
{
- $total = $this->getTotalPages();
$start = $this->getPage() + 1;
$end = $this->getPage() + $range;
$last = $this->getLastPage();
@@ -533,7 +536,7 @@
{
$this->max = $v;
}
-
+
/**
* Returns the count of the current page's records
* @return int
@@ -542,7 +545,7 @@
{
return count($this->getResult());
}
-
+
/**
* Returns the current element of the iterator
* @return mixed
@@ -554,7 +557,7 @@
}
return $this->rs[$this->currentKey];
}
-
+
/**
* Returns the current key of the iterator
* @return int
@@ -563,7 +566,7 @@
{
return $this->currentKey;
}
-
+
/**
* Advances the iterator to the next element
* @return void
@@ -572,7 +575,7 @@
{
$this->currentKey++;
}
-
+
/**
* Resets the iterator to the first element
* @return void
@@ -581,7 +584,7 @@
{
$this->currentKey = 0;
}
-
+
/**
* Checks if the current key exists in the container
* @return boolean
Index: propel/util/PropelModelPager.php
===================================================================
--- propel/util/PropelModelPager.php (revision 2294)
+++ propel/util/PropelModelPager.php (working copy)
@@ -11,7 +11,7 @@
/**
* Implements a pager based on a ModelCriteria
* The code from this class heavily borrows from symfony's sfPager class
- *
+ *
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author François Zaninotto
* @version $Revision$
@@ -33,17 +33,27 @@
$results = null,
$resultsCounter = 0;
+ /**
+ * @param ModelCriteria $query
+ * @param integer $maxPerPage
+ */
public function __construct(ModelCriteria $query, $maxPerPage = 10)
{
$this->setQuery($query);
$this->setMaxPerPage($maxPerPage);
}
-
+
+ /**
+ * @param ModelCriteria $query
+ */
public function setQuery(ModelCriteria $query)
{
$this->query = $query;
}
-
+
+ /**
+ * @return ModelCriteria
+ */
public function getQuery()
{
return $this->query;
@@ -133,11 +143,11 @@
return $links;
}
-
+
/**
* Test whether the number of results exceeds the max number of results per page
- *
- * @return boolean true if the pager displays only a subset of the results
+ *
+ * @return boolean true if the pager displays only a subset of the results
*/
public function haveToPaginate()
{
@@ -147,7 +157,7 @@
/**
* Get the index of the first element in the page
* Returns 1 on the first page, $maxPerPage +1 on the second page, etc
- *
+ *
* @return int
*/
public function getFirstIndex()
@@ -162,7 +172,7 @@
/**
* Get the index of the last element in the page
* Always less than or eaqual to $maxPerPage
- *
+ *
* @return int
*/
public function getLastIndex()
@@ -181,7 +191,7 @@
/**
* Get the total number of results of the query
* This can be greater than $maxPerPage
- *
+ *
* @return int
*/
public function getNbResults()
@@ -191,7 +201,7 @@
/**
* Set the total number of results of the query
- *
+ *
* @param int $nb
*/
protected function setNbResults($nb)
@@ -201,7 +211,7 @@
/**
* Check whether the current page is the first page
- *
+ *
* @return boolean true if the current page is the first page
*/
public function isFirstPage()
@@ -211,7 +221,7 @@
/**
* Get the number of the first page
- *
+ *
* @return int Always 1
*/
public function getFirstPage()
@@ -221,7 +231,7 @@
/**
* Check whether the current page is the last page
- *
+ *
* @return boolean true if the current page is the last page
*/
public function isLastPage()
@@ -231,7 +241,7 @@
/**
* Get the number of the last page
- *
+ *
* @return int
*/
public function getLastPage()
@@ -241,7 +251,7 @@
/**
* Set the number of the first page
- *
+ *
* @param int $page
*/
protected function setLastPage($page)
@@ -254,7 +264,7 @@
/**
* Get the number of the current page
- *
+ *
* @return int
*/
public function getPage()
@@ -264,7 +274,7 @@
/**
* Set the number of the current page
- *
+ *
* @param int $page
*/
public function setPage($page)
@@ -275,10 +285,10 @@
$this->page = $this->getMaxPerPage() ? 1 : 0;
}
}
-
+
/**
* Get the number of the next page
- *
+ *
* @return int
*/
public function getNextPage()
@@ -288,7 +298,7 @@
/**
* Get the number of the previous page
- *
+ *
* @return int
*/
public function getPreviousPage()
@@ -298,7 +308,7 @@
/**
* Get the maximum number results per page
- *
+ *
* @return int
*/
public function getMaxPerPage()
@@ -308,7 +318,7 @@
/**
* Set the maximum number results per page
- *
+ *
* @param int $max
*/
public function setMaxPerPage($max)
@@ -361,7 +371,7 @@
{
return $this->getResults()->isEmpty();
}
-
+
/**
* Check if the current index is an odd integer
* @see PropelCollection
@@ -372,7 +382,7 @@
{
return $this->getResults()->isOdd();
}
-
+
/**
* Check if the current index is an even integer
* @see PropelCollection
@@ -383,7 +393,7 @@
{
return $this->getResults()->isEven();
}
-
+
public function getIterator()
{
return $this->getResults()->getIterator();
Index: propel/util/BasePeer.php
===================================================================
--- propel/util/BasePeer.php (revision 2294)
+++ propel/util/BasePeer.php (working copy)
@@ -29,10 +29,6 @@
*/
class BasePeer
{
-
- /** Array (hash) that contains the cached mapBuilders. */
- private static $mapBuilders = array();
-
/** Array (hash) that contains cached validators */
private static $validatorMap = array();
@@ -97,14 +93,14 @@
* Method to perform deletes based on values and keys in a
* Criteria.
*
- * @param Criteria $criteria The criteria to use.
- * @param PropelPDO $con A PropelPDO connection object.
- * @return int The number of rows affected by last statement execution. For most
+ * @param Criteria $criteria The criteria to use.
+ * @param PropelPDO $con A PropelPDO connection object.
+ * @return int 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
+ * @throws PropelException
*/
public static function doDelete(Criteria $criteria, PropelPDO $con)
{
@@ -129,7 +125,8 @@
$whereClause = array();
$params = array();
- $stmt = null;
+ $sql = null;
+
try {
$sql = $db->getDeleteFromClause($criteria, $tableName);
@@ -166,16 +163,18 @@
* }
* </code>
*
- * @param string $tableName The name of the table to empty.
- * @param PropelPDO $con A PropelPDO connection object.
- * @param string $databaseName the name of the database.
- * @return int The number of rows affected by the statement. Note
+ * @param string $tableName The name of the table to empty.
+ * @param PropelPDO $con A PropelPDO connection object.
+ * @param string $databaseName the name of the database.
+ * @return int The number of rows affected by the statement. Note
* that the return value does require that this information
* is returned (supported) by the Propel db driver.
- * @throws PropelException - wrapping SQLException caught from statement execution.
+ * @throws PropelException - wrapping SQLException caught from statement execution.
*/
public static function doDeleteAll($tableName, PropelPDO $con, $databaseName = null)
{
+ $sql = null;
+
try {
$db = Propel::getDB($databaseName);
if ($db->useQuoteIdentifier()) {
@@ -185,7 +184,8 @@
$stmt = $con->prepare($sql);
$stmt->execute();
return $stmt->rowCount();
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute DELETE ALL statement [%s]', $sql), $e);
}
@@ -208,11 +208,11 @@
* If no primary key is defined for the table the values will be
* inserted as specified in Criteria and null will be returned.
*
- * @param Criteria $criteria Object containing values to insert.
- * @param PropelPDO $con A PropelPDO connection.
- * @return mixed The primary key for the new row if (and only if!) the primary key
+ * @param Criteria $criteria Object containing values to insert.
+ * @param PropelPDO $con A PropelPDO connection.
+ * @return mixed The primary key for the new row if (and only if!) the primary key
* is auto-generated. Otherwise will return <code>null</code>.
- * @throws PropelException
+ * @throws PropelException
*/
public static function doInsert(Criteria $criteria, PropelPDO $con) {
@@ -255,6 +255,8 @@
$criteria->add($pk->getFullyQualifiedName(), $id);
}
+ $sql = null;
+
try {
$adapter = Propel::getDB($criteria->getDBName());
@@ -313,18 +315,18 @@
* <p>
* WHERE some_column = some value AND could_have_another_column =
* another value AND so on.
+ *
+ * @throws PropelException
*
- * @param $selectCriteria A Criteria object containing values used in where
- * clause.
- * @param $updateValues A Criteria object containing values used in set
- * clause.
- * @param PropelPDO $con The PropelPDO connection object to use.
- * @return int 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 Propel db driver.
- * @throws PropelException
+ * @param Criteria $selectCriteria A Criteria object containing values used in where clause.
+ * @param Criteria $updateValues A Criteria object containing values used in set clause.
+ * @param PropelPDO $con The PropelPDO connection object to use.
+ *
+ * @return integer 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 Propel db driver.
*/
public static function doUpdate(Criteria $selectCriteria, Criteria $updateValues, PropelPDO $con) {
@@ -441,35 +443,35 @@
/**
* Executes query build by createSelectSql() and returns the resultset statement.
- *
- * @param Criteria $criteria A Criteria.
- * @param PropelPDO $con A PropelPDO connection to use.
- * @return PDOStatement The resultset.
- * @throws PropelException
- * @see createSelectSql()
+ *
+ * @see createSelectSql()
+ *
+ * @param Criteria $criteria A Criteria.
+ * @param PropelPDO $con A PropelPDO connection to use.
+ *
+ * @throws PropelException
+ * @return PDOStatement
*/
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
{
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
$db = Propel::getDB($criteria->getDbName());
- $stmt = null;
+ $stmt = $sql = null;
if ($con === null) {
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
try {
-
$params = array();
$sql = self::createSelectSql($criteria, $params);
+ /** @var $stmt PDOStatement */
$stmt = $con->prepare($sql);
-
$db->bindValues($stmt, $params, $dbMap);
-
$stmt->execute();
-
- } catch (Exception $e) {
+ }
+ catch (Exception $e) {
if ($stmt) {
$stmt = null; // close
}
@@ -483,12 +485,14 @@
/**
* 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.
+ *
+ * @see createSelectSql()
*
- * @param Criteria $criteria A Criteria.
- * @param PropelPDO $con A PropelPDO connection to use.
- * @return PDOStatement The resultset statement.
- * @throws PropelException
- * @see createSelectSql()
+ * @param Criteria $criteria A Criteria.
+ * @param PropelPDO $con A PropelPDO connection to use.
+ *
+ * @throws PropelException
+ * @return PDOStatement The resultset statement.
*/
public static function doCount(Criteria $criteria, PropelPDO $con = null)
{
@@ -499,7 +503,7 @@
$con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
}
- $stmt = null;
+ $stmt = $sql = null;
$needsComplexCount = $criteria->getGroupByColumns()
|| $criteria->getOffset()
@@ -526,6 +530,7 @@
$sql = self::createSelectSql($criteria, $params);
}
+ /** @var $stmt PDOStatement */
$stmt = $con->prepare($sql);
$db->bindValues($stmt, $params, $dbMap);
$stmt->execute();
@@ -544,10 +549,12 @@
/**
* Applies any validators that were defined in the schema to the specified columns.
*
- * @param string $dbName The name of the database
- * @param string $tableName The name of the table
- * @param array $columns Array of column names as key and column values as value.
- */
+ * @param string $dbName The name of the database
+ * @param string $tableName The name of the table
+ * @param array $columns Array of column names as key and column values as value.
+ *
+ * @return array|bool
+ */
public static function doValidate($dbName, $tableName, $columns)
{
$dbMap = Propel::getDatabaseMap($dbName);
@@ -573,10 +580,11 @@
* Helper method which returns the primary key contained
* in the given Criteria object.
*
- * @param Criteria $criteria A Criteria.
- * @return ColumnMap If the Criteria object contains a primary
- * key, or null if it doesn't.
- * @throws PropelException
+ * @param Criteria $criteria A Criteria.
+ *
+ * @throws PropelException
+ * @return ColumnMap If the Criteria object contains a primary
+ * key, or null if it doesn't.
*/
private static function getPrimaryKey(Criteria $criteria)
{
@@ -599,11 +607,14 @@
return $pk;
}
- /**
- * 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)
- */
+ /**
+ * 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)
+ *
+ * @param Criteria $criteria
+ * @return boolean
+ */
public static function needsSelectAliases(Criteria $criteria)
{
$columnNames = array();
@@ -628,10 +639,11 @@
* 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.
*
- * @param Criteria $criteria Criteria for the SELECT query.
- * @param array &$params Parameters that are to be replaced in prepared statement.
- * @return string
- * @throws PropelException Trouble creating the query string.
+ * @param Criteria $criteria Criteria for the SELECT query.
+ * @param array &$params Parameters that are to be replaced in prepared statement.
+ *
+ * @throws PropelException Trouble creating the query string.
+ * @return string
*/
public static function createSelectSql(Criteria $criteria, &$params)
{
@@ -646,7 +658,7 @@
$orderBy = $criteria->getOrderByColumns();
$groupBy = $criteria->getGroupByColumns();
- $ignoreCase = $criteria->isIgnoreCase();
+ $criteria->isIgnoreCase();
// get the first part of the SQL statement, the SELECT part
$selectSql = $db->createSelectSqlPart($criteria, $fromClause);
@@ -655,7 +667,7 @@
// joins with a null join type will be added to the FROM clause and the condition added to the WHERE clause.
// joins of a specified type: the LEFT side will be added to the fromClause and the RIGHT to the joinClause
foreach ($criteria->getJoins() as $join) {
-
+
$join->setDB($db);
// add 'em to the queues..
@@ -665,14 +677,14 @@
$joinTables[] = $join->getRightTableWithAlias();
$joinClause[] = $join->getClause($params);
}
-
+
// add the criteria to WHERE clause
// this will also add the table names to the FROM clause if they are not already
// included via a LEFT JOIN
foreach ($criteria->keys() as $key) {
$criterion = $criteria->getCriterion($key);
- $table = null;
+
foreach ($criterion->getAttachedCriterion() as $attachedCriterion) {
$tableName = $attachedCriterion->getTable();
@@ -783,7 +795,7 @@
if ($criteria->hasSelectQueries()) {
foreach ($fromClause as $key => $ftable) {
if (strpos($ftable, ' ') !== false) {
- list($realtable, $tableName) = explode(' ', $ftable);
+ list(, $tableName) = explode(' ', $ftable);
} else {
$tableName = $ftable;
}
@@ -792,18 +804,18 @@
}
}
}
-
+
// from / join tables quoted if it is necessary
if ($db->useQuoteIdentifier()) {
$fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause);
$joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause);
}
-
+
// add subQuery to From after adding quotes
foreach ($criteria->getSelectQueries() as $subQueryAlias => $subQueryCriteria) {
$fromClause[] = '(' . BasePeer::createSelectSql($subQueryCriteria, $params) . ') AS ' . $subQueryAlias;
}
-
+
// build from-clause
$from = '';
if (!empty($joinClause) && count($fromClause) > 1) {
@@ -833,9 +845,13 @@
/**
* Builds a params array, like the kind populated by Criterion::appendPsTo().
* This is useful for building an array even when it is not using the appendPsTo() method.
- * @param array $columns
- * @param Criteria $values
- * @return array params array('column' => ..., 'table' => ..., 'value' => ...)
+ *
+ * array('column' => ..., 'table' => ..., 'value' => ...)
+ *
+ * @param array $columns
+ * @param Criteria $values
+ *
+ * @return array
*/
private static function buildParams($columns, Criteria $values)
{
@@ -852,9 +868,11 @@
/**
* This function searches for the given validator $name under propel/validator/$name.php,
* imports and caches it.
+ *
+ * Object or null if not able to instantiate validator class (and error will be logged in this case)
*
- * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator)
- * @return Validator object or null if not able to instantiate validator class (and error will be logged in this case)
+ * @param string $classname The dot-path name of class (e.g. myapp.propel.MyValidator)
+ * @return BasicValidator
*/
public static function getValidator($classname)
{
@@ -870,5 +888,4 @@
Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": ".$e->getMessage(), Propel::LOG_ERR);
}
}
-
}
Index: propel/exception/PropelException.php
===================================================================
--- propel/exception/PropelException.php (revision 2294)
+++ propel/exception/PropelException.php (working copy)
@@ -16,12 +16,21 @@
*/
class PropelException extends Exception
{
- /** The nested "cause" exception. */
+ /**
+ * The nested "cause" exception.
+ *
+ * @var Exception
+ */
protected $cause;
-
- /**
- * Emulates wrapped exceptions for PHP < 5.3
- */
+
+ /**
+ * Emulates wrapped exceptions for PHP < 5.3
+ *
+ * @param string $message
+ * @param Exception $previous
+ *
+ * @return PropelException
+ */
public function __construct($message = null, Exception $previous = null)
{
if ($previous === null && $message instanceof Exception) {
@@ -45,8 +54,8 @@
/**
* Get the previous Exception
* We can't override getPrevious() since it's final
- *
- * @return Exception The previous exception
+ *
+ * @return Exception The previous exception
*/
public function getCause()
{
@@ -56,5 +65,4 @@
return $this->cause;
}
}
-
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment