Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
fee2c998
Commit
fee2c998
authored
Nov 10, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated the default value of scenarios()
parent
da786f65
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
9 deletions
+30
-9
Model.php
framework/base/Model.php
+10
-1
ActiveRecord.php
framework/db/ar/ActiveRecord.php
+12
-0
BaseQuery.php
framework/db/dao/BaseQuery.php
+1
-1
DataReader.php
framework/db/dao/DataReader.php
+4
-4
QueryBuilder.php
framework/db/dao/QueryBuilder.php
+3
-3
No files found.
framework/base/Model.php
View file @
fee2c998
...
@@ -137,11 +137,20 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -137,11 +137,20 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* If an attribute should NOT be massively assigned (thus considered unsafe),
* If an attribute should NOT be massively assigned (thus considered unsafe),
* please prefix the attribute with an exclamation character (e.g. '!attribute').
* 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.
* @return array a list of scenarios and the corresponding relevant attributes.
*/
*/
public
function
scenarios
()
public
function
scenarios
()
{
{
return
array
();
return
array
(
'default'
=>
$this
->
attributes
(),
);
}
}
/**
/**
...
...
framework/db/ar/ActiveRecord.php
View file @
fee2c998
...
@@ -594,6 +594,18 @@ abstract class ActiveRecord extends Model
...
@@ -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.
* Returns the named attribute value.
* If this is a new record and the attribute is not set before,
* If this is a new record and the attribute is not set before,
* the default column value will be returned.
* the default column value will be returned.
...
...
framework/db/dao/BaseQuery.php
View file @
fee2c998
...
@@ -67,7 +67,7 @@ class BaseQuery extends \yii\base\Component
...
@@ -67,7 +67,7 @@ class BaseQuery extends \yii\base\Component
public
$group
;
public
$group
;
/**
/**
* @var string|array how to join with other tables. This refers to the JOIN clause in a SQL statement.
* @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')`).
* `array('LEFT JOIN tbl_user ON tbl_user.id=author_id', 'LEFT JOIN tbl_team ON tbl_team.id=team_id')`).
* @see join()
* @see join()
*/
*/
...
...
framework/db/dao/DataReader.php
View file @
fee2c998
...
@@ -94,7 +94,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -94,7 +94,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
/**
* Advances the reader to the next row in a result set.
* 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
()
public
function
read
()
{
{
...
@@ -104,7 +104,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -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.
* Returns a single column from the next row of a result set.
* @param integer $columnIndex zero-based column index
* @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
)
public
function
readColumn
(
$columnIndex
)
{
{
...
@@ -115,7 +115,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -115,7 +115,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
* Returns an object populated with the next row of data.
* Returns an object populated with the next row of data.
* @param string $className class name of the object to be created and populated
* @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
* @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
)
public
function
readObject
(
$className
,
$fields
)
{
{
...
@@ -149,7 +149,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
...
@@ -149,7 +149,7 @@ class DataReader extends \yii\base\Object implements \Iterator, \Countable
/**
/**
* Closes the reader.
* Closes the reader.
* This frees up the resources allocated for executing this SQL statement.
* This frees up the resources allocated for executing this SQL statement.
* Read attemps after this method call are unpredictable.
* Read attemp
t
s after this method call are unpredictable.
*/
*/
public
function
close
()
public
function
close
()
{
{
...
...
framework/db/dao/QueryBuilder.php
View file @
fee2c998
...
@@ -92,7 +92,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -92,7 +92,7 @@ class QueryBuilder extends \yii\base\Object
*
*
* @param string $table the table that new rows will be inserted into.
* @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.
* @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
)
public
function
insert
(
$table
,
$columns
)
{
{
...
@@ -139,7 +139,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -139,7 +139,7 @@ class QueryBuilder extends \yii\base\Object
* @param mixed $condition the condition that will be put in the WHERE part. Please
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the parameters to be bound to the query.
* @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
())
public
function
update
(
$table
,
$columns
,
$condition
=
''
,
$params
=
array
())
{
{
...
@@ -180,7 +180,7 @@ class QueryBuilder extends \yii\base\Object
...
@@ -180,7 +180,7 @@ class QueryBuilder extends \yii\base\Object
* @param mixed $condition the condition that will be put in the WHERE part. Please
* @param mixed $condition the condition that will be put in the WHERE part. Please
* refer to [[Query::where()]] on how to specify condition.
* refer to [[Query::where()]] on how to specify condition.
* @param array $params the parameters to be bound to the query.
* @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
())
public
function
delete
(
$table
,
$condition
=
''
,
$params
=
array
())
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment