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
f3c17594
Commit
f3c17594
authored
May 07, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes issue #155.
parent
34b0da0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
ActiveRecord.php
framework/db/ActiveRecord.php
+7
-1
No files found.
framework/db/ActiveRecord.php
View file @
f3c17594
...
...
@@ -8,6 +8,7 @@
namespace
yii\db
;
use
yii\base\InvalidConfigException
;
use
yii\base\Model
;
use
yii\base\InvalidParamException
;
use
yii\base\ModelEvent
;
...
...
@@ -112,6 +113,7 @@ class ActiveRecord extends Model
* @return ActiveQuery|ActiveRecord|null When `$q` is null, a new [[ActiveQuery]] instance
* is returned; when `$q` is a scalar or an array, an ActiveRecord object matching it will be
* returned (null will be returned if there is no matching).
* @throws InvalidConfigException if the AR class does not have a primary key
* @see createQuery()
*/
public
static
function
find
(
$q
=
null
)
...
...
@@ -122,7 +124,11 @@ class ActiveRecord extends Model
}
elseif
(
$q
!==
null
)
{
// query by primary key
$primaryKey
=
static
::
primaryKey
();
return
$query
->
where
(
array
(
$primaryKey
[
0
]
=>
$q
))
->
one
();
if
(
isset
(
$primaryKey
[
0
]))
{
return
$query
->
where
(
array
(
$primaryKey
[
0
]
=>
$q
))
->
one
();
}
else
{
throw
new
InvalidConfigException
(
get_called_class
()
.
' must have a primary key.'
);
}
}
return
$query
;
}
...
...
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