Commit fee2c998 by Qiang Xue

updated the default value of scenarios()

parent da786f65
......@@ -137,11 +137,20 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* If an attribute should NOT be massively assigned (thus considered unsafe),
* please prefix the attribute with an exclamation character (e.g. '!attribute').
*
* WARNING: The default implementation returns the 'default' scenario and the result of
* [[attributes()]]. This means if the model is in 'default' scenario, all
* public member variables can be massively assigned and will be validated when
* calling [[validate()]]. Make sure you override this method if you do not want
* this behavior (e.g. you only want some of the attributes to be massively assigned
* and validated.)
*
* @return array a list of scenarios and the corresponding relevant attributes.
*/
public function scenarios()
{
return array();
return array(
'default' => $this->attributes(),
);
}
/**
......
......@@ -594,6 +594,18 @@ abstract class ActiveRecord extends Model
}
/**
* Returns a list of scenarios and the corresponding relevant attributes.
* Please refer to [[\yii\base\Model::scenarios()]] for more details.
* The implementation here simply returns an empty array. You may override
* this method to return the scenarios that you want to use with this AR class.
* @return array a list of scenarios and the corresponding relevant attributes.
*/
public function scenarios()
{
return array();
}
/**
* Returns the named attribute value.
* If this is a new record and the attribute is not set before,
* the default column value will be returned.
......
......@@ -67,7 +67,7 @@ class BaseQuery extends \yii\base\Component
public $group;
/**
* @var string|array how to join with other tables. This refers to the JOIN clause in a SQL statement.
* It can either a string (e.g. `'LEFT JOIN tbl_user ON tbl_user.id=author_id'`) or an array (e.g.
* It can be either a string (e.g. `'LEFT JOIN tbl_user ON tbl_user.id=author_id'`) or an array (e.g.
* `array('LEFT JOIN tbl_user ON tbl_user.id=author_id', 'LEFT JOIN tbl_team ON tbl_team.id=team_id')`).
* @see join()
*/
......
......@@ -94,7 +94,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
* Advances the reader to the next row in a result set.
* @return array|false the current row, false if no more row available
* @return array the current row, false if no more row available
*/
public function read()
{
......@@ -104,7 +104,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
* Returns a single column from the next row of a result set.
* @param integer $columnIndex zero-based column index
* @return mixed|false the column of the current row, false if no more row available
* @return mixed the column of the current row, false if no more row available
*/
public function readColumn($columnIndex)
{
......@@ -115,7 +115,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
* Returns an object populated with the next row of data.
* @param string $className class name of the object to be created and populated
* @param array $fields Elements of this array are passed to the constructor
* @return mixed|false the populated object, false if no more row of data available
* @return mixed the populated object, false if no more row of data available
*/
public function readObject($className, $fields)
{
......@@ -149,7 +149,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
* Closes the reader.
* This frees up the resources allocated for executing this SQL statement.
* Read attemps after this method call are unpredictable.
* Read attempts after this method call are unpredictable.
*/
public function close()
{
......
......@@ -92,7 +92,7 @@ class QueryBuilder extends \yii\base\Object
*
* @param string $table the table that new rows will be inserted into.
* @param array $columns the column data (name=>value) to be inserted into the table.
* @return integer number of rows affected by the execution.
* @return string the INSERT SQL
*/
public function insert($table, $columns)
{
......@@ -139,7 +139,7 @@ class QueryBuilder extends \yii\base\Object
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the parameters to be bound to the query.
* @return integer number of rows affected by the execution.
* @return string the UPDATE SQL
*/
public function update($table, $columns, $condition = '', $params = array())
{
......@@ -180,7 +180,7 @@ class QueryBuilder extends \yii\base\Object
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the parameters to be bound to the query.
* @return integer number of rows affected by the execution.
* @return string the DELETE SQL
*/
public function delete($table, $condition = '', $params = array())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment