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
b3b8fadf
Commit
b3b8fadf
authored
Mar 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor adjustment of db exception.
parent
8c7b1efa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
9 deletions
+10
-9
Command.php
framework/db/Command.php
+3
-3
Connection.php
framework/db/Connection.php
+2
-2
Exception.php
framework/db/Exception.php
+4
-3
QueryBuilder.php
framework/db/mysql/QueryBuilder.php
+1
-1
No files found.
framework/db/Command.php
View file @
b3b8fadf
...
...
@@ -134,7 +134,7 @@ class Command extends \yii\base\Component
}
catch
(
\Exception
$e
)
{
\Yii
::
error
(
$e
->
getMessage
()
.
"
\n
Failed to prepare SQL:
$sql
"
,
__CLASS__
);
$errorInfo
=
$e
instanceof
\PDOException
?
$e
->
errorInfo
:
null
;
throw
new
Exception
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$errorInfo
);
throw
new
Exception
(
$e
->
getMessage
(),
$errorInfo
,
(
int
)
$e
->
getCode
()
);
}
}
}
...
...
@@ -292,7 +292,7 @@ class Command extends \yii\base\Component
\Yii
::
error
(
"
$message
\n
Failed to execute SQL:
{
$sql
}{
$paramLog
}
"
,
__CLASS__
);
$errorInfo
=
$e
instanceof
\PDOException
?
$e
->
errorInfo
:
null
;
throw
new
Exception
(
$message
,
(
int
)
$e
->
getCode
(),
$errorInfo
);
throw
new
Exception
(
$message
,
$errorInfo
,
(
int
)
$e
->
getCode
()
);
}
}
...
...
@@ -431,7 +431,7 @@ class Command extends \yii\base\Component
$message
=
$e
->
getMessage
();
\Yii
::
error
(
"
$message
\n
Command::
$method
() failed:
{
$sql
}{
$paramLog
}
"
,
__CLASS__
);
$errorInfo
=
$e
instanceof
\PDOException
?
$e
->
errorInfo
:
null
;
throw
new
Exception
(
$message
,
(
int
)
$e
->
getCode
(),
$errorInfo
);
throw
new
Exception
(
$message
,
$errorInfo
,
(
int
)
$e
->
getCode
()
);
}
}
...
...
framework/db/Connection.php
View file @
b3b8fadf
...
...
@@ -320,7 +320,7 @@ class Connection extends Component
{
if
(
$this
->
pdo
===
null
)
{
if
(
empty
(
$this
->
dsn
))
{
throw
new
InvalidConfigException
(
'Connection
.
dsn cannot be empty.'
);
throw
new
InvalidConfigException
(
'Connection
::
dsn cannot be empty.'
);
}
try
{
\Yii
::
trace
(
'Opening DB connection: '
.
$this
->
dsn
,
__CLASS__
);
...
...
@@ -330,7 +330,7 @@ class Connection extends Component
catch
(
\PDOException
$e
)
{
\Yii
::
error
(
"Failed to open DB connection (
{
$this
->
dsn
}
): "
.
$e
->
getMessage
(),
__CLASS__
);
$message
=
YII_DEBUG
?
'Failed to open DB connection: '
.
$e
->
getMessage
()
:
'Failed to open DB connection.'
;
throw
new
Exception
(
$message
,
(
int
)
$e
->
getCode
(),
$e
->
errorInfo
);
throw
new
Exception
(
$message
,
$e
->
errorInfo
,
(
int
)
$e
->
getCode
()
);
}
}
}
...
...
framework/db/Exception.php
View file @
b3b8fadf
...
...
@@ -24,13 +24,14 @@ class Exception extends \yii\base\Exception
/**
* Constructor.
* @param string $message PDO error message
* @param integer $code PDO error code
* @param mixed $errorInfo PDO error info
* @param integer $code PDO error code
* @param \Exception $previous The previous exception used for the exception chaining.
*/
public
function
__construct
(
$message
,
$
code
=
0
,
$errorInfo
=
null
)
public
function
__construct
(
$message
,
$
errorInfo
=
null
,
$code
=
0
,
\Exception
$previous
=
null
)
{
$this
->
errorInfo
=
$errorInfo
;
parent
::
__construct
(
$message
,
$code
);
parent
::
__construct
(
$message
,
$code
,
$previous
);
}
/**
...
...
framework/db/mysql/QueryBuilder.php
View file @
b3b8fadf
...
...
@@ -52,7 +52,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
$quotedTable
=
$this
->
db
->
quoteTableName
(
$table
);
$row
=
$this
->
db
->
createCommand
(
'SHOW CREATE TABLE '
.
$quotedTable
)
->
queryRow
();
if
(
$row
===
false
)
{
throw
new
Exception
(
"Unable to find '
$oldName
' in table '
$table
'."
);
throw
new
Exception
(
"Unable to find
column
'
$oldName
' in table '
$table
'."
);
}
if
(
isset
(
$row
[
'Create Table'
]))
{
$sql
=
$row
[
'Create Table'
];
...
...
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