Changed all public methods to specify public access.

This commit is contained in:
predominant 2010-04-05 13:19:38 +10:00
parent 14b6a7ac5e
commit 1497ec3910
139 changed files with 1278 additions and 2551 deletions

View file

@ -41,9 +41,8 @@ class AclBehavior extends ModelBehavior {
*
* @param mixed $config
* @return void
* @access public
*/
function setup(&$model, $config = array()) {
public function setup(&$model, $config = array()) {
if (is_string($config)) {
$config = array('type' => $config);
}
@ -68,9 +67,8 @@ class AclBehavior extends ModelBehavior {
*
* @param mixed $ref
* @return array
* @access public
*/
function node(&$model, $ref = null) {
public function node(&$model, $ref = null) {
$type = $this->__typeMaps[strtolower($this->settings[$model->name]['type'])];
if (empty($ref)) {
$ref = array('model' => $model->name, 'foreign_key' => $model->id);
@ -83,9 +81,8 @@ class AclBehavior extends ModelBehavior {
*
* @param boolean $created True if this is a new record
* @return void
* @access public
*/
function afterSave(&$model, $created) {
public function afterSave(&$model, $created) {
$type = $this->__typeMaps[strtolower($this->settings[$model->alias]['type'])];
$parent = $model->parentNode();
if (!empty($parent)) {
@ -108,9 +105,8 @@ class AclBehavior extends ModelBehavior {
* Destroys the ARO/ACO node bound to the deleted record
*
* @return void
* @access public
*/
function afterDelete(&$model) {
public function afterDelete(&$model) {
$type = $this->__typeMaps[strtolower($this->settings[$model->name]['type'])];
$node = Set::extract($this->node($model), "0.{$type}.id");
if (!empty($node)) {

View file

@ -61,9 +61,8 @@ class ContainableBehavior extends ModelBehavior {
*
* @param object $Model Model using the behavior
* @param array $settings Settings to override for model.
* @access public
*/
function setup(&$Model, $settings = array()) {
public function setup(&$Model, $settings = array()) {
if (!isset($this->settings[$Model->alias])) {
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
}
@ -93,9 +92,8 @@ class ContainableBehavior extends ModelBehavior {
* @param object $Model Model using the behavior
* @param array $query Query parameters as set by cake
* @return array
* @access public
*/
function beforeFind(&$Model, $query) {
public function beforeFind(&$Model, $query) {
$reset = (isset($query['reset']) ? $query['reset'] : true);
$noContain = ((isset($this->runtime[$Model->alias]['contain']) && empty($this->runtime[$Model->alias]['contain'])) || (isset($query['contain']) && empty($query['contain'])));
$contain = array();
@ -214,9 +212,8 @@ class ContainableBehavior extends ModelBehavior {
* @param object $Model Model on which we are resetting
* @param array $results Results of the find operation
* @param bool $primary true if this is the primary model that issued the find operation, false otherwise
* @access public
*/
function afterFind(&$Model, $results, $primary) {
public function afterFind(&$Model, $results, $primary) {
if (!empty($Model->__backContainableAssociation)) {
foreach ($Model->__backContainableAssociation as $relation => $bindings) {
$Model->{$relation} = $bindings;
@ -231,9 +228,8 @@ class ContainableBehavior extends ModelBehavior {
*
* @param object $Model Model on which binding restriction is being applied
* @return void
* @access public
*/
function contain(&$Model) {
public function contain(&$Model) {
$args = func_get_args();
$contain = call_user_func_array('am', array_slice($args, 1));
$this->runtime[$Model->alias]['contain'] = $contain;
@ -246,9 +242,8 @@ class ContainableBehavior extends ModelBehavior {
*
* @param object $Model Model on which to reset bindings
* @return void
* @access public
*/
function resetBindings(&$Model) {
public function resetBindings(&$Model) {
if (!empty($Model->__backOriginalAssociation)) {
$Model->__backAssociation = $Model->__backOriginalAssociation;
unset($Model->__backOriginalAssociation);
@ -271,9 +266,8 @@ class ContainableBehavior extends ModelBehavior {
* @param array $containments Current set of containments
* @param bool $throwErrors Wether unexisting bindings show throw errors
* @return array Containments
* @access public
*/
function containments(&$Model, $contain, $containments = array(), $throwErrors = null) {
public function containments(&$Model, $contain, $containments = array(), $throwErrors = null) {
$options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery');
$keep = array();
$depth = array();
@ -375,9 +369,8 @@ class ContainableBehavior extends ModelBehavior {
* @param array $map Map of relations for given model
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
* @return array Fields
* @access public
*/
function fieldDependencies(&$Model, $map, $fields = array()) {
public function fieldDependencies(&$Model, $map, $fields = array()) {
if ($fields === false) {
foreach ($map as $parent => $children) {
foreach ($children as $type => $bindings) {
@ -421,9 +414,8 @@ class ContainableBehavior extends ModelBehavior {
*
* @param array $containments Containments
* @return array Built containments
* @access public
*/
function containmentsMap($containments) {
public function containmentsMap($containments) {
$map = array();
foreach ($containments['models'] as $name => $model) {
$instance =& $model['instance'];

View file

@ -46,9 +46,8 @@ class TranslateBehavior extends ModelBehavior {
*
* @param array $config
* @return mixed
* @access public
*/
function setup(&$model, $config = array()) {
public function setup(&$model, $config = array()) {
$db =& ConnectionManager::getDataSource($model->useDbConfig);
if (!$db->connected) {
trigger_error(
@ -68,9 +67,8 @@ class TranslateBehavior extends ModelBehavior {
* Callback
*
* @return void
* @access public
*/
function cleanup(&$model) {
public function cleanup(&$model) {
$this->unbindTranslation($model);
unset($this->settings[$model->alias]);
unset($this->runtime[$model->alias]);
@ -81,9 +79,8 @@ class TranslateBehavior extends ModelBehavior {
*
* @param array $query
* @return array Modified query
* @access public
*/
function beforeFind(&$model, $query) {
public function beforeFind(&$model, $query) {
$locale = $this->_getLocale($model);
if (empty($locale)) {
return $query;
@ -207,9 +204,8 @@ class TranslateBehavior extends ModelBehavior {
* @param array $results
* @param boolean $primary
* @return array Modified results
* @access public
*/
function afterFind(&$model, $results, $primary) {
public function afterFind(&$model, $results, $primary) {
$this->runtime[$model->alias]['fields'] = array();
$locale = $this->_getLocale($model);
@ -250,9 +246,8 @@ class TranslateBehavior extends ModelBehavior {
* beforeValidate Callback
*
* @return boolean
* @access public
*/
function beforeValidate(&$model) {
public function beforeValidate(&$model) {
$locale = $this->_getLocale($model);
if (empty($locale)) {
return true;
@ -284,9 +279,8 @@ class TranslateBehavior extends ModelBehavior {
*
* @param boolean $created
* @return void
* @access public
*/
function afterSave(&$model, $created) {
public function afterSave(&$model, $created) {
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
return true;
}
@ -327,9 +321,8 @@ class TranslateBehavior extends ModelBehavior {
* afterDelete Callback
*
* @return void
* @access public
*/
function afterDelete(&$model) {
public function afterDelete(&$model) {
$RuntimeModel =& $this->translateModel($model);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel->deleteAll($conditions);
@ -358,9 +351,8 @@ class TranslateBehavior extends ModelBehavior {
* Get instance of model for translations
*
* @return object
* @access public
*/
function &translateModel(&$model) {
public function &translateModel(&$model) {
if (!isset($this->runtime[$model->alias]['model'])) {
if (!isset($model->translateModel) || empty($model->translateModel)) {
$className = 'I18nModel';

View file

@ -55,9 +55,8 @@ class TreeBehavior extends ModelBehavior {
* @param object $Model instance of model
* @param array $config array of configuration settings.
* @return void
* @access public
*/
function setup(&$Model, $config = array()) {
public function setup(&$Model, $config = array()) {
if (!is_array($config)) {
$config = array('type' => $config);
}
@ -81,9 +80,8 @@ class TreeBehavior extends ModelBehavior {
* @param AppModel $Model Model instance.
* @param boolean $created indicates whether the node just saved was created or updated
* @return boolean true on success, false on failure
* @access public
*/
function afterSave(&$Model, $created) {
public function afterSave(&$Model, $created) {
extract($this->settings[$Model->alias]);
if ($created) {
if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) {
@ -102,9 +100,8 @@ class TreeBehavior extends ModelBehavior {
*
* @param AppModel $Model Model instance
* @return boolean true to continue, false to abort the delete
* @access public
*/
function beforeDelete(&$Model) {
public function beforeDelete(&$Model) {
extract($this->settings[$Model->alias]);
list($name, $data) = array($Model->alias, $Model->read());
$data = $data[$name];
@ -135,9 +132,8 @@ class TreeBehavior extends ModelBehavior {
* @since 1.2
* @param AppModel $Model Model instance
* @return boolean true to continue, false to abort the save
* @access public
*/
function beforeSave(&$Model) {
public function beforeSave(&$Model) {
extract($this->settings[$Model->alias]);
$this->_addToWhitelist($Model, array($left, $right));
@ -205,9 +201,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $id The ID of the record to read or false to read all top level nodes
* @param boolean $direct whether to count direct, or all, children
* @return integer number of child nodes
* @access public
*/
function childcount(&$Model, $id = null, $direct = false) {
public function childcount(&$Model, $id = null, $direct = false) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -251,9 +246,8 @@ class TreeBehavior extends ModelBehavior {
* @param integer $page Page number, for accessing paged data
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of child nodes
* @access public
*/
function children(&$Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
public function children(&$Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -308,9 +302,8 @@ class TreeBehavior extends ModelBehavior {
* @param string $spacer The character or characters which will be repeated
* @param integer $recursive The number of levels deep to fetch associated records
* @return array An associative array of records, where the id is the key, and the display field is the value
* @access public
*/
function generatetreelist(&$Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
public function generatetreelist(&$Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
$overrideRecursive = $recursive;
extract($this->settings[$Model->alias]);
if (!is_null($overrideRecursive)) {
@ -363,9 +356,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $id The ID of the record to read
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of data for the parent node
* @access public
*/
function getparentnode(&$Model, $id = null, $fields = null, $recursive = null) {
public function getparentnode(&$Model, $id = null, $fields = null, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -396,9 +388,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $fields Either a single string of a field name, or an array of field names
* @param integer $recursive The number of levels deep to fetch associated records
* @return array Array of nodes from top most parent to current node
* @access public
*/
function getpath(&$Model, $id = null, $fields = null, $recursive = null) {
public function getpath(&$Model, $id = null, $fields = null, $recursive = null) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -433,9 +424,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $id The ID of the record to move
* @param mixed $number how many places to move the node or true to move to last position
* @return boolean true on success, false on failure
* @access public
*/
function movedown(&$Model, $id = null, $number = 1) {
public function movedown(&$Model, $id = null, $number = 1) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -491,9 +481,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $id The ID of the record to move
* @param mixed $number how many places to move the node, or true to move to first position
* @return boolean true on success, false on failure
* @access public
*/
function moveup(&$Model, $id = null, $number = 1) {
public function moveup(&$Model, $id = null, $number = 1) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -555,9 +544,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to
* delete, or the id of the parent to set as the parent_id
* @return boolean true on success, false on failure
* @access public
*/
function recover(&$Model, $mode = 'parent', $missingParentAction = null) {
public function recover(&$Model, $mode = 'parent', $missingParentAction = null) {
if (is_array($mode)) {
extract (array_merge(array('mode' => 'parent'), $mode));
}
@ -672,9 +660,8 @@ class TreeBehavior extends ModelBehavior {
* @param mixed $id The ID of the record to remove
* @param boolean $delete whether to delete the node after reparenting children (if any)
* @return boolean true on success, false on failure
* @access public
*/
function removefromtree(&$Model, $id = null, $delete = false) {
public function removefromtree(&$Model, $id = null, $delete = false) {
if (is_array($id)) {
extract (array_merge(array('id' => null), $id));
}
@ -740,9 +727,8 @@ class TreeBehavior extends ModelBehavior {
* @param AppModel $Model Model instance
* @return mixed true if the tree is valid or empty, otherwise an array of (error type [index, node],
* [incorrect left/right index,node id], message)
* @access public
*/
function verify(&$Model) {
public function verify(&$Model) {
extract($this->settings[$Model->alias]);
if (!$Model->find('count', array('conditions' => $scope))) {
return true;

View file

@ -139,9 +139,8 @@ class CakeSchema extends Object {
*
* @param array $events schema object properties
* @return boolean Should process continue
* @access public
*/
function before($event = array()) {
public function before($event = array()) {
return true;
}
@ -149,9 +148,8 @@ class CakeSchema extends Object {
* After callback to be implemented in subclasses
*
* @param array $events schema object properties
* @access public
*/
function after($event = array()) {
public function after($event = array()) {
}
/**
@ -159,9 +157,8 @@ class CakeSchema extends Object {
*
* @param array $options schema object properties
* @return array Set of name and tables
* @access public
*/
function &load($options = array()) {
public function &load($options = array()) {
if (is_string($options)) {
$options = array('path' => $options);
}
@ -198,9 +195,8 @@ class CakeSchema extends Object {
*
* @param array $options schema object properties
* @return array Array indexed by name and tables
* @access public
*/
function read($options = array()) {
public function read($options = array()) {
extract(array_merge(
array(
'connection' => $this->connection,
@ -319,9 +315,8 @@ class CakeSchema extends Object {
* @param mixed $object schema object or options array
* @param array $options schema object properties to override object
* @return mixed false or string written to file
* @access public
*/
function write($object, $options = array()) {
public function write($object, $options = array()) {
if (is_object($object)) {
$object = get_object_vars($object);
$this->_build($object);
@ -427,9 +422,8 @@ class CakeSchema extends Object {
* @param mixed $old Schema object or array
* @param mixed $new Schema object or array
* @return array Tables (that are added, dropped, or changed)
* @access public
*/
function compare($old, $new = null) {
public function compare($old, $new = null) {
if (empty($new)) {
$new =& $this;
}
@ -513,9 +507,8 @@ class CakeSchema extends Object {
*
* @param array $values options keys(type, null, default, key, length, extra)
* @return array Formatted values
* @access public
*/
function __values($values) {
public function __values($values) {
$vals = array();
if (is_array($values)) {
foreach ($values as $key => $val) {
@ -535,9 +528,8 @@ class CakeSchema extends Object {
*
* @param array $Obj model object
* @return array Formatted columns
* @access public
*/
function __columns(&$Obj) {
public function __columns(&$Obj) {
$db =& ConnectionManager::getDataSource($Obj->useDbConfig);
$fields = $Obj->schema(true);
$columns = $props = array();

View file

@ -221,9 +221,8 @@ class DataSource extends Object {
*
* @param mixed $data
* @return array Array of sources available in this datasource.
* @access public
*/
function listSources($data = null) {
public function listSources($data = null) {
if ($this->cacheSources === false) {
return null;
}
@ -250,9 +249,8 @@ class DataSource extends Object {
*
* @param boolean $reset Whether or not the source list should be reset.
* @return array Array of sources available in this datasource
* @access public
*/
function sources($reset = false) {
public function sources($reset = false) {
if ($reset === true) {
$this->_sources = null;
}
@ -264,9 +262,8 @@ class DataSource extends Object {
*
* @param Model $model
* @return array Array of Metadata for the $model
* @access public
*/
function describe(&$model) {
public function describe(&$model) {
if ($this->cacheSources === false) {
return null;
}
@ -288,9 +285,8 @@ class DataSource extends Object {
* Begin a transaction
*
* @return boolean Returns true if a transaction is not in progress
* @access public
*/
function begin(&$model) {
public function begin(&$model) {
return !$this->_transactionStarted;
}
@ -298,9 +294,8 @@ class DataSource extends Object {
* Commit a transaction
*
* @return boolean Returns true if a transaction is in progress
* @access public
*/
function commit(&$model) {
public function commit(&$model) {
return $this->_transactionStarted;
}
@ -308,9 +303,8 @@ class DataSource extends Object {
* Rollback a transaction
*
* @return boolean Returns true if a transaction is in progress
* @access public
*/
function rollback(&$model) {
public function rollback(&$model) {
return $this->_transactionStarted;
}
@ -319,9 +313,8 @@ class DataSource extends Object {
*
* @param string $real Real column type (i.e. "varchar(255)")
* @return string Abstract column type (i.e. "string")
* @access public
*/
function column($real) {
public function column($real) {
return false;
}
@ -334,9 +327,8 @@ class DataSource extends Object {
* @param array $fields An Array of fields to be saved.
* @param array $values An Array of values to save.
* @return boolean success
* @access public
*/
function create(&$model, $fields = null, $values = null) {
public function create(&$model, $fields = null, $values = null) {
return false;
}
@ -348,9 +340,8 @@ class DataSource extends Object {
* @param Model $model The model being read.
* @param array $queryData An array of query data used to find the data you want
* @return mixed
* @access public
*/
function read(&$model, $queryData = array()) {
public function read(&$model, $queryData = array()) {
return false;
}
@ -363,9 +354,8 @@ class DataSource extends Object {
* @param array $fields Array of fields to be updated
* @param array $values Array of values to be update $fields to.
* @return boolean Success
* @access public
*/
function update(&$model, $fields = null, $values = null) {
public function update(&$model, $fields = null, $values = null) {
return false;
}
@ -376,9 +366,8 @@ class DataSource extends Object {
*
* @param Model $model The model class having record(s) deleted
* @param mixed $id Primary key of the model
* @access public
*/
function delete(&$model, $id = null) {
public function delete(&$model, $id = null) {
if ($id == null) {
$id = $model->id;
}
@ -389,9 +378,8 @@ class DataSource extends Object {
*
* @param unknown_type $source
* @return mixed Last ID key generated in previous INSERT
* @access public
*/
function lastInsertId($source = null) {
public function lastInsertId($source = null) {
return false;
}
@ -400,9 +388,8 @@ class DataSource extends Object {
*
* @param unknown_type $source
* @return integer Number of rows returned by last operation
* @access public
*/
function lastNumRows($source = null) {
public function lastNumRows($source = null) {
return false;
}
@ -411,9 +398,8 @@ class DataSource extends Object {
*
* @param unknown_type $source
* @return integer Number of rows affected by last query.
* @access public
*/
function lastAffected($source = null) {
public function lastAffected($source = null) {
return false;
}
@ -423,9 +409,8 @@ class DataSource extends Object {
* before establishing a connection.
*
* @return boolean Whether or not the Datasources conditions for use are met.
* @access public
*/
function enabled() {
public function enabled() {
return true;
}
/**
@ -433,9 +418,8 @@ class DataSource extends Object {
*
* @param string $interface The name of the interface (method)
* @return boolean True on success
* @access public
*/
function isInterfaceSupported($interface) {
public function isInterfaceSupported($interface) {
static $methods = false;
if ($methods === false) {
$methods = array_map('strtolower', get_class_methods($this));
@ -449,9 +433,8 @@ class DataSource extends Object {
*
* @param array $config The configuration array
* @return void
* @access public
*/
function setConfig($config = array()) {
public function setConfig($config = array()) {
$this->config = array_merge($this->_baseConfig, $this->config, $config);
}
@ -572,9 +555,8 @@ class DataSource extends Object {
* @param Model $model Model instance
* @param string $key Key name to make
* @return string Key name for model.
* @access public
*/
function resolveKey(&$model, $key) {
public function resolveKey(&$model, $key) {
return $model->alias . $key;
}
@ -582,9 +564,8 @@ class DataSource extends Object {
* Closes the current datasource.
*
* @return void
* @access public
*/
function __destruct() {
public function __destruct() {
if ($this->_transactionStarted) {
$null = null;
$this->rollback($null);

View file

@ -165,9 +165,8 @@ class DboOracle extends DboSource {
* Connects to the database using options in the given configuration array.
*
* @return boolean True if the database could be connected, else false
* @access public
*/
function connect() {
public function connect() {
$config = $this->config;
$this->connected = false;
$config['charset'] = !empty($config['charset']) ? $config['charset'] : null;
@ -246,9 +245,8 @@ class DboOracle extends DboSource {
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
* @access public
*/
function disconnect() {
public function disconnect() {
if ($this->connection) {
$this->connected = !ocilogoff($this->connection);
return !$this->connected;
@ -311,9 +309,8 @@ class DboOracle extends DboSource {
* @param integer $limit Maximum number of rows to return
* @param integer $offset Row to begin returning
* @return modified SQL Query
* @access public
*/
function limit($limit = -1, $offset = 0) {
public function limit($limit = -1, $offset = 0) {
$this->_limit = (int) $limit;
$this->_offset = (int) $offset;
}
@ -323,9 +320,8 @@ class DboOracle extends DboSource {
* this returns false.
*
* @return integer Number of rows in resultset
* @access public
*/
function lastNumRows() {
public function lastNumRows() {
return $this->_numRows;
}
@ -381,9 +377,8 @@ class DboOracle extends DboSource {
* Enter description here...
*
* @return unknown
* @access public
*/
function fetchRow() {
public function fetchRow() {
if ($this->_currentRow >= $this->_numRows) {
ocifreestatement($this->_statementId);
$this->_map = null;
@ -421,9 +416,8 @@ class DboOracle extends DboSource {
*
* @param string $sequence
* @return bool
* @access public
*/
function sequenceExists($sequence) {
public function sequenceExists($sequence) {
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
if (!$this->execute($sql)) {
return false;
@ -436,9 +430,8 @@ class DboOracle extends DboSource {
*
* @param string $sequence
* @return bool
* @access public
*/
function createSequence($sequence) {
public function createSequence($sequence) {
$sql = "CREATE SEQUENCE $sequence";
return $this->execute($sql);
}
@ -448,9 +441,8 @@ class DboOracle extends DboSource {
*
* @param unknown_type $table
* @return unknown
* @access public
*/
function createTrigger($table) {
public function createTrigger($table) {
$sql = "CREATE OR REPLACE TRIGGER pk_$table" . "_trigger BEFORE INSERT ON $table FOR EACH ROW BEGIN SELECT pk_$table.NEXTVAL INTO :NEW.ID FROM DUAL; END;";
return $this->execute($sql);
}
@ -460,9 +452,8 @@ class DboOracle extends DboSource {
* raised and the application exits.
*
* @return array tablenames in the database
* @access public
*/
function listSources() {
public function listSources() {
$cache = parent::listSources();
if ($cache != null) {
return $cache;
@ -486,9 +477,8 @@ class DboOracle extends DboSource {
*
* @param object instance of a model to inspect
* @return array Fields in table. Keys are name and type
* @access public
*/
function describe(&$model) {
public function describe(&$model) {
$table = $this->fullTableName($model, false);
if (!empty($model->sequence)) {
@ -744,9 +734,8 @@ class DboOracle extends DboSource {
*
* @param unknown_type $var
* @return unknown
* @access public
*/
function name($name) {
public function name($name) {
if (strpos($name, '.') !== false && strpos($name, '"') === false) {
list($model, $field) = explode('.', $name);
if ($field[0] == "_") {
@ -802,9 +791,8 @@ class DboOracle extends DboSource {
*
* @param string $real Real database-layer column type (i.e. "varchar(255)")
* @return string Abstract column type (i.e. "string")
* @access public
*/
function column($real) {
public function column($real) {
if (is_array($real)) {
$col = $real['name'];
@ -853,9 +841,8 @@ class DboOracle extends DboSource {
*
* @param string $data String to be prepared for use in an SQL statement
* @return string Quoted and escaped
* @access public
*/
function value($data, $column = null, $safe = false) {
public function value($data, $column = null, $safe = false) {
$parent = parent::value($data, $column, $safe);
if ($parent != null) {
@ -894,9 +881,8 @@ class DboOracle extends DboSource {
*
* @param string
* @return integer
* @access public
*/
function lastInsertId($source) {
public function lastInsertId($source) {
$sequence = $this->_sequenceMap[$source];
$sql = "SELECT $sequence.currval FROM dual";
@ -914,9 +900,8 @@ class DboOracle extends DboSource {
* Returns a formatted error message from previous database operation.
*
* @return string Error message with error number
* @access public
*/
function lastError() {
public function lastError() {
return $this->_error;
}
@ -924,9 +909,8 @@ class DboOracle extends DboSource {
* Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
*
* @return int Number of affected rows
* @access public
*/
function lastAffected() {
public function lastAffected() {
return $this->_statementId ? ocirowcount($this->_statementId): false;
}

View file

@ -389,9 +389,8 @@ class DboPostgres extends DboSource {
* @param integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset,
* and if 1, sequences are not modified
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
* @access public
*/
function truncate($table, $reset = 0) {
public function truncate($table, $reset = 0) {
if (parent::truncate($table)) {
$table = $this->fullTableName($table, false);
if (isset($this->_sequenceMap[$table]) && $reset !== 1) {

View file

@ -313,9 +313,8 @@ class DboSqlite extends DboSource {
*
* @param mixed $table A string or model class representing the table to be truncated
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
* @access public
*/
function truncate($table) {
public function truncate($table) {
return $this->execute('DELETE From ' . $this->fullTableName($table));
}

View file

@ -118,9 +118,8 @@ class DboSource extends DataSource {
*
* @param array $config Array of configuration information for the Datasource.
* @param boolean $autoConnect Whether or not the datasource should automatically connect.
* @access public
*/
function __construct($config = null, $autoConnect = true) {
public function __construct($config = null, $autoConnect = true) {
if (!isset($config['prefix'])) {
$config['prefix'] = '';
}
@ -141,9 +140,8 @@ class DboSource extends DataSource {
*
* @param array $config An array defining the new configuration settings
* @return boolean True on success, false on failure
* @access public
*/
function reconnect($config = null) {
public function reconnect($config = null) {
$this->disconnect();
$this->setConfig($config);
$this->_sources = null;
@ -158,9 +156,8 @@ class DboSource extends DataSource {
* @param string $column The column into which this data will be inserted
* @param boolean $read Value to be used in READ or WRITE context
* @return mixed Prepared value or array of values.
* @access public
*/
function value($data, $column = null, $read = true) {
public function value($data, $column = null, $read = true) {
if (is_array($data) && !empty($data)) {
return array_map(
array(&$this, 'value'),
@ -184,9 +181,8 @@ class DboSource extends DataSource {
*
* @param string $identifier
* @return object An object representing a database identifier to be used in a query
* @access public
*/
function identifier($identifier) {
public function identifier($identifier) {
$obj = new stdClass();
$obj->type = 'identifier';
$obj->value = $identifier;
@ -198,9 +194,8 @@ class DboSource extends DataSource {
*
* @param string $expression
* @return object An object representing a database expression to be used in a query
* @access public
*/
function expression($expression) {
public function expression($expression) {
$obj = new stdClass();
$obj->type = 'expression';
$obj->value = $expression;
@ -212,9 +207,8 @@ class DboSource extends DataSource {
*
* @param string $sql SQL statement
* @return boolean
* @access public
*/
function rawQuery($sql) {
public function rawQuery($sql) {
$this->took = $this->error = $this->numRows = false;
return $this->execute($sql);
}
@ -233,9 +227,8 @@ class DboSource extends DataSource {
* @param string $sql
* @param array $options
* @return mixed Resource or object representing the result set, or false on failure
* @access public
*/
function execute($sql, $options = array()) {
public function execute($sql, $options = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
@ -263,9 +256,8 @@ class DboSource extends DataSource {
* DataSource Query abstraction
*
* @return resource Result resource identifier.
* @access public
*/
function query() {
public function query() {
$args = func_get_args();
$fields = null;
$order = null;
@ -360,9 +352,8 @@ class DboSource extends DataSource {
* Returns a row from current resultset as an array
*
* @return array The fetched row as an array
* @access public
*/
function fetchRow($sql = null) {
public function fetchRow($sql = null) {
if (!empty($sql) && is_string($sql) && strlen($sql) > 5) {
if (!$this->execute($sql)) {
return null;
@ -388,9 +379,8 @@ class DboSource extends DataSource {
* @param string $sql SQL statement
* @param boolean $cache Enables returning/storing cached query results
* @return array Array of resultset rows, or false if no rows matched
* @access public
*/
function fetchAll($sql, $cache = true, $modelName = null) {
public function fetchAll($sql, $cache = true, $modelName = null) {
if ($cache && isset($this->_queryCache[$sql])) {
if (preg_match('/^\s*select/i', $sql)) {
return $this->_queryCache[$sql];
@ -458,9 +448,8 @@ class DboSource extends DataSource {
* @param string $name Name of the field
* @param string $sql SQL query
* @return mixed Value of field read.
* @access public
*/
function field($name, $sql) {
public function field($name, $sql) {
$data = $this->fetchRow($sql);
if (!isset($data[$name]) || empty($data[$name])) {
return false;
@ -507,9 +496,8 @@ class DboSource extends DataSource {
*
* @param string $data
* @return string SQL field
* @access public
*/
function name($data) {
public function name($data) {
if (is_object($data) && isset($data->type)) {
return $data->value;
}
@ -563,9 +551,8 @@ class DboSource extends DataSource {
* Checks if the source is connected to the database.
*
* @return boolean True if the database is connected, else false
* @access public
*/
function isConnected() {
public function isConnected() {
return $this->connected;
}
@ -573,9 +560,8 @@ class DboSource extends DataSource {
* Checks if the result is valid
*
* @return boolean True if the result is valid else false
* @access public
*/
function hasResult() {
public function hasResult() {
return is_resource($this->_result);
}
@ -584,9 +570,8 @@ class DboSource extends DataSource {
*
* @param boolean $sorted Get the queries sorted by time taken, defaults to false.
* @return array Array of queries run as an array
* @access public
*/
function getLog($sorted = false, $clear = true) {
public function getLog($sorted = false, $clear = true) {
if ($sorted) {
$log = sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC);
} else {
@ -628,9 +613,8 @@ class DboSource extends DataSource {
*
* @param string $sql SQL statement
* @todo: Add hook to log errors instead of returning false
* @access public
*/
function logQuery($sql) {
public function logQuery($sql) {
$this->_queriesCnt++;
$this->_queriesTime += $this->took;
$this->_queriesLog[] = array(
@ -653,9 +637,8 @@ class DboSource extends DataSource {
* and execution time in microseconds. If the query fails, an error is output instead.
*
* @param string $sql Query to show information on.
* @access public
*/
function showQuery($sql) {
public function showQuery($sql) {
$error = $this->error;
if (strlen($sql) > 200 && !$this->fullDebug && Configure::read() > 1) {
$sql = substr($sql, 0, 200) . '[...]';
@ -677,9 +660,8 @@ class DboSource extends DataSource {
* @param mixed $model Either a Model object or a string table name.
* @param boolean $quote Whether you want the table name quoted.
* @return string Full quoted table name
* @access public
*/
function fullTableName($model, $quote = true) {
public function fullTableName($model, $quote = true) {
if (is_object($model)) {
$table = $model->tablePrefix . $model->table;
} elseif (isset($this->config['prefix'])) {
@ -704,9 +686,8 @@ class DboSource extends DataSource {
* @param array $values An array of values with keys matching the fields. If null, $model->data will
* be used to generate values.
* @return boolean Success
* @access public
*/
function create(&$model, $fields = null, $values = null) {
public function create(&$model, $fields = null, $values = null) {
$id = null;
if ($fields == null) {
@ -1047,9 +1028,8 @@ class DboSource extends DataSource {
* @param string $query Association query
* @param array $ids Array of IDs of associated records
* @return array Association results
* @access public
*/
function fetchAssociated($model, $query, $ids) {
public function fetchAssociated($model, $query, $ids) {
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
if (count($ids) > 1) {
$query = str_replace('= (', 'IN (', $query);
@ -1190,9 +1170,8 @@ class DboSource extends DataSource {
* @param boolean $external
* @param array $resultSet
* @return mixed
* @access public
*/
function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
public function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
$queryData = $this->__scrubQueryData($queryData);
$assocData = $this->__scrubQueryData($assocData);
@ -1356,9 +1335,8 @@ class DboSource extends DataSource {
* @param object $model Model object
* @param array $association Association array
* @return array Conditions array defining the constraint between $model and $association
* @access public
*/
function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) {
public function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) {
$assoc = array_merge(array('external' => false, 'self' => false), $assoc);
if (array_key_exists('foreignKey', $assoc) && empty($assoc['foreignKey'])) {
@ -1453,9 +1431,8 @@ class DboSource extends DataSource {
*
* @param array $data
* @return string
* @access public
*/
function renderJoinStatement($data) {
public function renderJoinStatement($data) {
extract($data);
return trim("{$type} JOIN {$table} {$alias} ON ({$conditions})");
}
@ -1466,9 +1443,8 @@ class DboSource extends DataSource {
* @param string $type type of query being run. e.g select, create, update, delete, schema, alter.
* @param array $data Array of data to insert into the query.
* @return string Rendered SQL expression to be run.
* @access public
*/
function renderStatement($type, $data) {
public function renderStatement($type, $data) {
extract($data);
$aliases = null;
@ -1546,9 +1522,8 @@ class DboSource extends DataSource {
* @param array $values
* @param mixed $conditions
* @return boolean Success
* @access public
*/
function update(&$model, $fields = array(), $values = null, $conditions = null) {
public function update(&$model, $fields = array(), $values = null, $conditions = null) {
if ($values == null) {
$combined = $fields;
} else {
@ -1625,9 +1600,8 @@ class DboSource extends DataSource {
* @param Model $model
* @param mixed $conditions
* @return boolean Success
* @access public
*/
function delete(&$model, $conditions = null) {
public function delete(&$model, $conditions = null) {
$alias = $joins = null;
$table = $this->fullTableName($model);
$conditions = $this->_matchRecords($model, $conditions);
@ -1726,9 +1700,8 @@ class DboSource extends DataSource {
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
* @param array $params Function parameters (any values must be quoted manually)
* @return string An SQL calculation function
* @access public
*/
function calculate(&$model, $func, $params = array()) {
public function calculate(&$model, $func, $params = array()) {
$params = (array)$params;
switch (strtolower($func)) {
@ -1766,9 +1739,8 @@ class DboSource extends DataSource {
*
* @param mixed $table A string or model class representing the table to be truncated
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
* @access public
*/
function truncate($table) {
public function truncate($table) {
return $this->execute('TRUNCATE TABLE ' . $this->fullTableName($table));
}
@ -1779,9 +1751,8 @@ class DboSource extends DataSource {
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
* @access public
*/
function begin(&$model) {
public function begin(&$model) {
if (parent::begin($model) && $this->execute($this->_commands['begin'])) {
$this->_transactionStarted = true;
return true;
@ -1796,9 +1767,8 @@ class DboSource extends DataSource {
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
* @access public
*/
function commit(&$model) {
public function commit(&$model) {
if (parent::commit($model) && $this->execute($this->_commands['commit'])) {
$this->_transactionStarted = false;
return true;
@ -1813,9 +1783,8 @@ class DboSource extends DataSource {
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
* @access public
*/
function rollback(&$model) {
public function rollback(&$model) {
if (parent::rollback($model) && $this->execute($this->_commands['rollback'])) {
$this->_transactionStarted = false;
return true;
@ -1836,9 +1805,8 @@ class DboSource extends DataSource {
* @return mixed Either null, false, $conditions or an array of default conditions to use.
* @see DboSource::update()
* @see DboSource::conditions()
* @access public
*/
function defaultConditions(&$model, $conditions, $useAlias = true) {
public function defaultConditions(&$model, $conditions, $useAlias = true) {
if (!empty($conditions)) {
return $conditions;
}
@ -1863,9 +1831,8 @@ class DboSource extends DataSource {
* @param unknown_type $key
* @param unknown_type $assoc
* @return string
* @access public
*/
function resolveKey($model, $key, $assoc = null) {
public function resolveKey($model, $key, $assoc = null) {
if (empty($assoc)) {
$assoc = $model->alias;
}
@ -1880,9 +1847,8 @@ class DboSource extends DataSource {
*
* @param array $data
* @return array
* @access public
*/
function __scrubQueryData($data) {
public function __scrubQueryData($data) {
foreach (array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group') as $key) {
if (empty($data[$key])) {
$data[$key] = array();
@ -1917,9 +1883,8 @@ class DboSource extends DataSource {
* @param mixed $fields
* @param boolean $quote If false, returns fields array unquoted
* @return array
* @access public
*/
function fields(&$model, $alias = null, $fields = array(), $quote = true) {
public function fields(&$model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) {
$alias = $model->alias;
}
@ -2047,9 +2012,8 @@ class DboSource extends DataSource {
* @param boolean $where If true, "WHERE " will be prepended to the return value
* @param Model $model A reference to the Model instance making the query
* @return string SQL fragment
* @access public
*/
function conditions($conditions, $quoteValues = true, $where = true, $model = null) {
public function conditions($conditions, $quoteValues = true, $where = true, $model = null) {
if (is_object($model)) {
$cacheKey = array(
$model->useDbConfig,
@ -2110,9 +2074,8 @@ class DboSource extends DataSource {
* @param boolean $quoteValues If true, values should be quoted
* @param Model $model A reference to the Model instance making the query
* @return string SQL fragment
* @access public
*/
function conditionKeysToString($conditions, $quoteValues = true, $model = null) {
public function conditionKeysToString($conditions, $quoteValues = true, $model = null) {
$c = 0;
$out = array();
$data = $columnType = null;
@ -2346,9 +2309,8 @@ class DboSource extends DataSource {
* @param integer $limit Limit of results returned
* @param integer $offset Offset from which to start results
* @return string SQL limit/offset statement
* @access public
*/
function limit($limit, $offset = null) {
public function limit($limit, $offset = null) {
if ($limit) {
$rt = '';
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) {
@ -2372,9 +2334,8 @@ class DboSource extends DataSource {
* @param string $direction Direction (ASC or DESC)
* @param object $model model reference (used to look for virtual field)
* @return string ORDER BY clause
* @access public
*/
function order($keys, $direction = 'ASC', $model = null) {
public function order($keys, $direction = 'ASC', $model = null) {
if (!is_array($keys)) {
$keys = array($keys);
}
@ -2436,9 +2397,8 @@ class DboSource extends DataSource {
*
* @param string $group Group By Condition
* @return mixed string condition or null
* @access public
*/
function group($group, $model = null) {
public function group($group, $model = null) {
if ($group) {
if (!is_array($group)) {
$group = array($group);
@ -2458,9 +2418,8 @@ class DboSource extends DataSource {
* Disconnects database, kills the connection and says the connection is closed.
*
* @return void
* @access public
*/
function close() {
public function close() {
$this->disconnect();
}
@ -2470,9 +2429,8 @@ class DboSource extends DataSource {
* @param Model $model Model to search
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
* @return boolean True if the table has a matching record, else false
* @access public
*/
function hasAny(&$Model, $sql) {
public function hasAny(&$Model, $sql) {
$sql = $this->conditions($sql);
$table = $this->fullTableName($Model);
$alias = $this->alias . $this->name($Model->alias);
@ -2492,9 +2450,8 @@ class DboSource extends DataSource {
*
* @param string $real Real database-layer column type (i.e. "varchar(255)")
* @return mixed An integer or string representing the length of the column
* @access public
*/
function length($real) {
public function length($real) {
if (!preg_match_all('/([\w\s]+)(?:\((\d+)(?:,(\d+))?\))?(\sunsigned)?(\szerofill)?/', $real, $result)) {
trigger_error(__("FIXME: Can't parse field: " . $real, true), E_USER_WARNING);
$col = str_replace(array(')', 'unsigned'), '', $real);
@ -2553,9 +2510,8 @@ class DboSource extends DataSource {
*
* @param mixed $data Value to be translated
* @return mixed Converted boolean value
* @access public
*/
function boolean($data) {
public function boolean($data) {
if ($data === true || $data === false) {
if ($data === true) {
return 1;
@ -2590,9 +2546,8 @@ class DboSource extends DataSource {
*
* @param string $model Name of model to inspect
* @return array Fields in table. Keys are column and unique
* @access public
*/
function index($model) {
public function index($model) {
return false;
}
@ -2603,9 +2558,8 @@ class DboSource extends DataSource {
* @param string $tableName Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated.
* @return string
* @access public
*/
function createSchema($schema, $tableName = null) {
public function createSchema($schema, $tableName = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object', true), E_USER_WARNING);
return null;
@ -2665,9 +2619,8 @@ class DboSource extends DataSource {
* @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated.
* @return string
* @access public
*/
function dropSchema($schema, $table = null) {
public function dropSchema($schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object', true), E_USER_WARNING);
return null;
@ -2688,9 +2641,8 @@ class DboSource extends DataSource {
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
* where options can be 'default', 'length', or 'key'.
* @return string
* @access public
*/
function buildColumn($column) {
public function buildColumn($column) {
$name = $type = null;
extract(array_merge(array('null' => true), $column));
@ -2754,9 +2706,8 @@ class DboSource extends DataSource {
* @param array $columnData The array of column data.
* @param string $position The position type to use. 'beforeDefault' or 'afterDefault' are common
* @return string a built column with the field parameters added.
* @access public
*/
function _buildFieldParameters($columnString, $columnData, $position) {
public function _buildFieldParameters($columnString, $columnData, $position) {
foreach ($this->fieldParameters as $paramName => $value) {
if (isset($columnData[$paramName]) && $value['position'] == $position) {
if (isset($value['options']) && !in_array($columnData[$paramName], $value['options'])) {
@ -2778,9 +2729,8 @@ class DboSource extends DataSource {
* @param array $indexes
* @param string $table
* @return array
* @access public
*/
function buildIndex($indexes, $table = null) {
public function buildIndex($indexes, $table = null) {
$join = array();
foreach ($indexes as $name => $value) {
$out = '';
@ -2809,9 +2759,8 @@ class DboSource extends DataSource {
* @param array $parameters
* @param string $table
* @return array
* @access public
*/
function readTableParameters($name) {
public function readTableParameters($name) {
$parameters = array();
if ($this->isInterfaceSupported('listDetailedSources')) {
$currentTableDetails = $this->listDetailedSources($name);
@ -2830,9 +2779,8 @@ class DboSource extends DataSource {
* @param array $parameters
* @param string $table
* @return array
* @access public
*/
function buildTableParameters($parameters, $table = null) {
public function buildTableParameters($parameters, $table = null) {
$result = array();
foreach ($parameters as $name => $value) {
if (isset($this->tableParameters[$name])) {
@ -2850,9 +2798,8 @@ class DboSource extends DataSource {
*
* @param string $value
* @return void
* @access public
*/
function introspectType($value) {
public function introspectType($value) {
if (!is_array($value)) {
if ($value === true || $value === false) {
return 'boolean';

View file

@ -67,9 +67,8 @@ class AclNode extends AppModel {
*
* @param mixed $ref Array with 'model' and 'foreign_key', model object, or string value
* @return array Node found in database
* @access public
*/
function node($ref = null) {
public function node($ref = null) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$type = $this->alias;
$result = null;

View file

@ -751,9 +751,8 @@ class Model extends Overloadable {
*
* @param string $tableName Name of the custom table
* @return void
* @access public
*/
function setSource($tableName) {
public function setSource($tableName) {
$this->setDataSource($this->useDbConfig);
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
@ -837,9 +836,8 @@ class Model extends Overloadable {
* @param string $field The name of the field to be deconstructed
* @param mixed $data An array or object to be deconstructed into a field
* @return mixed The resulting data that should be assigned to a field
* @access public
*/
function deconstruct($field, $data) {
public function deconstruct($field, $data) {
if (!is_array($data)) {
return $data;
}
@ -912,9 +910,8 @@ class Model extends Overloadable {
*
* @param mixed $field Set to true to reload schema, or a string to return a specific field
* @return array Array of table metadata
* @access public
*/
function schema($field = false) {
public function schema($field = false) {
if (!is_array($this->_schema) || $field === true) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
@ -938,9 +935,8 @@ class Model extends Overloadable {
* Returns an associative array of field names and column types.
*
* @return array Field types indexed by field name
* @access public
*/
function getColumnTypes() {
public function getColumnTypes() {
$columns = $this->schema();
if (empty($columns)) {
trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
@ -957,9 +953,8 @@ class Model extends Overloadable {
*
* @param string $column The name of the model column
* @return string Column type
* @access public
*/
function getColumnType($column) {
public function getColumnType($column) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$cols = $this->schema();
$model = null;
@ -986,9 +981,8 @@ class Model extends Overloadable {
* @return mixed If $name is a string, returns a boolean indicating whether the field exists.
* If $name is an array of field names, returns the first field that exists,
* or false if none exist.
* @access public
*/
function hasField($name, $checkVirtual = false) {
public function hasField($name, $checkVirtual = false) {
if (is_array($name)) {
foreach ($name as $n) {
if ($this->hasField($n, $checkVirtual)) {
@ -1019,9 +1013,8 @@ class Model extends Overloadable {
*
* @param mixed $name Name of field to look for
* @return boolean indicating whether the field exists as a model virtual field.
* @access public
*/
function isVirtualField($field) {
public function isVirtualField($field) {
if (empty($this->virtualFields) || !is_string($field)) {
return false;
}
@ -1044,9 +1037,8 @@ class Model extends Overloadable {
* @return mixed If $field is string expression bound to virtual field $field
* If $field is null, returns an array of all model virtual fields
* or false if none $field exist.
* @access public
*/
function getVirtualField($field = null) {
public function getVirtualField($field = null) {
if ($field == null) {
return empty($this->virtualFields) ? false : $this->virtualFields;
}
@ -1464,9 +1456,8 @@ class Model extends Overloadable {
* @param boolean $created True if a new record was created, otherwise only associations with
* 'counterScope' defined get updated
* @return void
* @access public
*/
function updateCounterCache($keys = array(), $created = false) {
public function updateCounterCache($keys = array(), $created = false) {
$keys = empty($keys) ? $this->data[$this->alias] : $keys;
$keys['old'] = isset($keys['old']) ? $keys['old'] : array();
@ -1964,9 +1955,8 @@ class Model extends Overloadable {
* to ascertain the existence of the record in persistent storage.
*
* @return boolean True if such a record exists
* @access public
*/
function exists() {
public function exists() {
if ($this->getID() === false) {
return false;
}
@ -1980,9 +1970,8 @@ class Model extends Overloadable {
*
* @param array $conditions SQL conditions array
* @return boolean True if such a record exists
* @access public
*/
function hasAny($conditions = null) {
public function hasAny($conditions = null) {
return ($this->find('count', array('conditions' => $conditions, 'recursive' => -1)) != false);
}
@ -2339,9 +2328,8 @@ class Model extends Overloadable {
* to those originally defined in the model.
*
* @return boolean Success
* @access public
*/
function resetAssociations() {
public function resetAssociations() {
if (!empty($this->__backAssociation)) {
foreach ($this->__associations as $type) {
if (isset($this->__backAssociation[$type])) {
@ -2368,9 +2356,8 @@ class Model extends Overloadable {
* @param array $fields Field/value pairs to search (if no values specified, they are pulled from $this->data)
* @param boolean $or If false, all fields specified must match in order for a false return value
* @return boolean False if any records matching any fields are found
* @access public
*/
function isUnique($fields, $or = true) {
public function isUnique($fields, $or = true) {
if (!is_array($fields)) {
$fields = func_get_args();
if (is_bool($fields[count($fields) - 1])) {
@ -2639,9 +2626,8 @@ class Model extends Overloadable {
* @param string $field The name of the field to invalidate
* @param mixed $value Name of validation rule that was not failed, or validation message to
* be returned. If no validation key is provided, defaults to true.
* @access public
*/
function invalidate($field, $value = true) {
public function invalidate($field, $value = true) {
if (!is_array($this->validationErrors)) {
$this->validationErrors = array();
}
@ -2653,9 +2639,8 @@ class Model extends Overloadable {
*
* @param string $field Returns true if the input string ends in "_id"
* @return boolean True if the field is a foreign key listed in the belongsTo array.
* @access public
*/
function isForeignKey($field) {
public function isForeignKey($field) {
$foreignKeys = array();
if (!empty($this->belongsTo)) {
foreach ($this->belongsTo as $assoc => $data) {
@ -2672,9 +2657,8 @@ class Model extends Overloadable {
* @param string $field Field to escape (e.g: id)
* @param string $alias Alias for the model (e.g: Post)
* @return string The name of the escaped field for this Model (i.e. id becomes `Post`.`id`).
* @access public
*/
function escapeField($field = null, $alias = null) {
public function escapeField($field = null, $alias = null) {
if (empty($alias)) {
$alias = $this->alias;
}
@ -2693,9 +2677,8 @@ class Model extends Overloadable {
*
* @param integer $list Index on which the composed ID is located
* @return mixed The ID of the current record, false if no ID
* @access public
*/
function getID($list = 0) {
public function getID($list = 0) {
if (empty($this->id) || (is_array($this->id) && isset($this->id[0]) && empty($this->id[0]))) {
return false;
}
@ -2725,9 +2708,8 @@ class Model extends Overloadable {
* Returns the ID of the last record this model inserted.
*
* @return mixed Last inserted ID
* @access public
*/
function getLastInsertID() {
public function getLastInsertID() {
return $this->getInsertID();
}
@ -2735,9 +2717,8 @@ class Model extends Overloadable {
* Returns the ID of the last record this model inserted.
*
* @return mixed Last inserted ID
* @access public
*/
function getInsertID() {
public function getInsertID() {
return $this->__insertID;
}
@ -2745,9 +2726,8 @@ class Model extends Overloadable {
* Sets the ID of the last record this model inserted
*
* @param mixed Last inserted ID
* @access public
*/
function setInsertID($id) {
public function setInsertID($id) {
$this->__insertID = $id;
}
@ -2755,9 +2735,8 @@ class Model extends Overloadable {
* Returns the number of rows returned from the last query.
*
* @return int Number of rows
* @access public
*/
function getNumRows() {
public function getNumRows() {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
return $db->lastNumRows();
}
@ -2766,9 +2745,8 @@ class Model extends Overloadable {
* Returns the number of rows affected by the last query.
*
* @return int Number of rows
* @access public
*/
function getAffectedRows() {
public function getAffectedRows() {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
return $db->lastAffected();
}
@ -2778,9 +2756,8 @@ class Model extends Overloadable {
*
* @param string $dataSource The name of the DataSource, as defined in app/config/database.php
* @return boolean True on success
* @access public
*/
function setDataSource($dataSource = null) {
public function setDataSource($dataSource = null) {
$oldConfig = $this->useDbConfig;
if ($dataSource != null) {
@ -2807,9 +2784,8 @@ class Model extends Overloadable {
* Not safe for use with some versions of PHP4, because this class is overloaded.
*
* @return object A DataSource object
* @access public
*/
function &getDataSource() {
public function &getDataSource() {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
return $db;
}
@ -2818,9 +2794,8 @@ class Model extends Overloadable {
* Get associations
*
* @return array
* @access public
*/
function associations() {
public function associations() {
return $this->__associations;
}
@ -2829,9 +2804,8 @@ class Model extends Overloadable {
*
* @param string $type Only result associations of this type
* @return array Associations
* @access public
*/
function getAssociated($type = null) {
public function getAssociated($type = null) {
if ($type == null) {
$associated = array();
foreach ($this->__associations as $assoc) {
@ -2876,9 +2850,8 @@ class Model extends Overloadable {
* @param mixed $with The 'with' key of the model association
* @param array $keys Any join keys which must be merged with the keys queried
* @return array
* @access public
*/
function joinModel($assoc, $keys = array()) {
public function joinModel($assoc, $keys = array()) {
if (is_string($assoc)) {
return array($assoc, array_keys($this->{$assoc}->schema()));
} elseif (is_array($assoc)) {

View file

@ -58,9 +58,8 @@ class ModelBehavior extends Object {
*
* @param object $model Model using this behavior
* @param array $config Configuration settings for $model
* @access public
*/
function setup(&$model, $config = array()) { }
public function setup(&$model, $config = array()) { }
/**
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
@ -82,9 +81,8 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
* @return boolean True if the operation should continue, false if it should abort
* @access public
*/
function beforeFind(&$model, $query) { }
public function beforeFind(&$model, $query) { }
/**
* After find callback. Can be used to modify any results returned by find and findAll.
@ -93,36 +91,32 @@ class ModelBehavior extends Object {
* @param mixed $results The results of the find operation
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
* @return mixed Result of the find operation
* @access public
*/
function afterFind(&$model, $results, $primary) { }
public function afterFind(&$model, $results, $primary) { }
/**
* Before validate callback
*
* @param object $model Model using this behavior
* @return boolean True if validate operation should continue, false to abort
* @access public
*/
function beforeValidate(&$model) { }
public function beforeValidate(&$model) { }
/**
* Before save callback
*
* @param object $model Model using this behavior
* @return boolean True if the operation should continue, false if it should abort
* @access public
*/
function beforeSave(&$model) { }
public function beforeSave(&$model) { }
/**
* After save callback
*
* @param object $model Model using this behavior
* @param boolean $created True if this save created a new record
* @access public
*/
function afterSave(&$model, $created) { }
public function afterSave(&$model, $created) { }
/**
* Before delete callback
@ -130,26 +124,23 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return boolean True if the operation should continue, false if it should abort
* @access public
*/
function beforeDelete(&$model, $cascade = true) { }
public function beforeDelete(&$model, $cascade = true) { }
/**
* After delete callback
*
* @param object $model Model using this behavior
* @access public
*/
function afterDelete(&$model) { }
public function afterDelete(&$model) { }
/**
* DataSource error callback
*
* @param object $model Model using this behavior
* @param string $error Error generated in DataSource
* @access public
*/
function onError(&$model, $error) { }
public function onError(&$model, $error) { }
/**
* Overrides Object::dispatchMethod to account for PHP4's broken reference support
@ -276,9 +267,8 @@ class BehaviorCollection extends Object {
* @param string $behavior CamelCased name of the behavior to load
* @param array $config Behavior configuration parameters
* @return boolean True on success, false on failure
* @access public
*/
function attach($behavior, $config = array()) {
public function attach($behavior, $config = array()) {
list($plugin, $name) = pluginSplit($behavior);
$class = $name . 'Behavior';
@ -369,9 +359,8 @@ class BehaviorCollection extends Object {
*
* @param string $name CamelCased name of the behavior to unload
* @return void
* @access public
*/
function detach($name) {
public function detach($name) {
if (isset($this->{$name})) {
$this->{$name}->cleanup(ClassRegistry::getObject($this->modelName));
unset($this->{$name});
@ -389,9 +378,8 @@ class BehaviorCollection extends Object {
*
* @param mixed $name CamelCased name of the behavior(s) to enable (string or array)
* @return void
* @access public
*/
function enable($name) {
public function enable($name) {
$this->_disabled = array_diff($this->_disabled, (array)$name);
}
@ -401,9 +389,8 @@ class BehaviorCollection extends Object {
*
* @param mixed $name CamelCased name of the behavior(s) to disable (string or array)
* @return void
* @access public
*/
function disable($name) {
public function disable($name) {
foreach ((array)$name as $behavior) {
if (in_array($behavior, $this->_attached) && !in_array($behavior, $this->_disabled)) {
$this->_disabled[] = $behavior;
@ -418,9 +405,8 @@ class BehaviorCollection extends Object {
* returns an array of currently-enabled behaviors
* @return mixed If $name is specified, returns the boolean status of the corresponding behavior.
* Otherwise, returns an array of all enabled behaviors.
* @access public
*/
function enabled($name = null) {
public function enabled($name = null) {
if (!empty($name)) {
return (in_array($name, $this->_attached) && !in_array($name, $this->_disabled));
}
@ -431,9 +417,8 @@ class BehaviorCollection extends Object {
* Dispatches a behavior method
*
* @return array All methods for all behaviors attached to this object
* @access public
*/
function dispatchMethod(&$model, $method, $params = array(), $strict = false) {
public function dispatchMethod(&$model, $method, $params = array(), $strict = false) {
$methods = array_keys($this->__methods);
foreach ($methods as $key => $value) {
$methods[$key] = strtolower($value);
@ -476,9 +461,8 @@ class BehaviorCollection extends Object {
* @param array $params
* @param array $options
* @return mixed
* @access public
*/
function trigger(&$model, $callback, $params = array(), $options = array()) {
public function trigger(&$model, $callback, $params = array(), $options = array()) {
if (empty($this->_attached)) {
return true;
}
@ -509,9 +493,8 @@ class BehaviorCollection extends Object {
* Gets the method list for attached behaviors, i.e. all public, non-callback methods
*
* @return array All public methods for all behaviors attached to this collection
* @access public
*/
function methods() {
public function methods() {
return $this->__methods;
}
@ -522,9 +505,8 @@ class BehaviorCollection extends Object {
* returns an array of currently-attached behaviors
* @return mixed If $name is specified, returns the boolean status of the corresponding behavior.
* Otherwise, returns an array of all attached behaviors.
* @access public
*/
function attached($name = null) {
public function attached($name = null) {
if (!empty($name)) {
return (in_array($name, $this->_attached));
}