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
c6ef7ec9
Commit
c6ef7ec9
authored
Sep 06, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved Command::getPdoType() to Schema
this allows different implementation in different DBMS CUBRID does not supprt PDO::TYPE_BOOL, so we use STRING here which will be casted by the DBMS
parent
e446a118
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
23 deletions
+42
-23
Command.php
framework/yii/db/Command.php
+3
-22
Schema.php
framework/yii/db/Schema.php
+19
-0
QueryBuilder.php
framework/yii/db/cubrid/QueryBuilder.php
+1
-1
Schema.php
framework/yii/db/cubrid/Schema.php
+19
-0
No files found.
framework/yii/db/Command.php
View file @
c6ef7ec9
...
...
@@ -181,7 +181,7 @@ class Command extends \yii\base\Component
{
$this
->
prepare
();
if
(
$dataType
===
null
)
{
$this
->
pdoStatement
->
bindParam
(
$name
,
$value
,
$this
->
getPdoType
(
$value
));
$this
->
pdoStatement
->
bindParam
(
$name
,
$value
,
$this
->
db
->
schema
->
getPdoType
(
$value
));
}
elseif
(
$length
===
null
)
{
$this
->
pdoStatement
->
bindParam
(
$name
,
$value
,
$dataType
);
}
elseif
(
$driverOptions
===
null
)
{
...
...
@@ -208,7 +208,7 @@ class Command extends \yii\base\Component
{
$this
->
prepare
();
if
(
$dataType
===
null
)
{
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$this
->
getPdoType
(
$value
));
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$this
->
db
->
schema
->
getPdoType
(
$value
));
}
else
{
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$dataType
);
}
...
...
@@ -236,7 +236,7 @@ class Command extends \yii\base\Component
$type
=
$value
[
1
];
$value
=
$value
[
0
];
}
else
{
$type
=
$this
->
getPdoType
(
$value
);
$type
=
$this
->
db
->
schema
->
getPdoType
(
$value
);
}
$this
->
pdoStatement
->
bindValue
(
$name
,
$value
,
$type
);
$this
->
_params
[
$name
]
=
$value
;
...
...
@@ -246,25 +246,6 @@ class Command extends \yii\base\Component
}
/**
* Determines the PDO type for the give PHP data value.
* @param mixed $data the data whose PDO type is to be determined
* @return integer the PDO type
* @see http://www.php.net/manual/en/pdo.constants.php
*/
private
function
getPdoType
(
$data
)
{
static
$typeMap
=
array
(
'boolean'
=>
\PDO
::
PARAM_BOOL
,
'integer'
=>
\PDO
::
PARAM_INT
,
'string'
=>
\PDO
::
PARAM_STR
,
'resource'
=>
\PDO
::
PARAM_LOB
,
'NULL'
=>
\PDO
::
PARAM_NULL
,
);
$type
=
gettype
(
$data
);
return
isset
(
$typeMap
[
$type
])
?
$typeMap
[
$type
]
:
\PDO
::
PARAM_STR
;
}
/**
* Executes the SQL statement.
* This method should only be used for executing non-query SQL statement, such as `INSERT`, `DELETE`, `UPDATE` SQLs.
* No result set will be returned.
...
...
framework/yii/db/Schema.php
View file @
c6ef7ec9
...
...
@@ -376,4 +376,23 @@ abstract class Schema extends Object
return
'string'
;
}
}
/**
* Determines the PDO type for the give PHP data value.
* @param mixed $data the data whose PDO type is to be determined
* @return integer the PDO type
* @see http://www.php.net/manual/en/pdo.constants.php
*/
public
function
getPdoType
(
$data
)
{
static
$typeMap
=
array
(
// php type => PDO type
'boolean'
=>
\PDO
::
PARAM_BOOL
,
'integer'
=>
\PDO
::
PARAM_INT
,
'string'
=>
\PDO
::
PARAM_STR
,
'resource'
=>
\PDO
::
PARAM_LOB
,
'NULL'
=>
\PDO
::
PARAM_NULL
,
);
$type
=
gettype
(
$data
);
return
isset
(
$typeMap
[
$type
])
?
$typeMap
[
$type
]
:
\PDO
::
PARAM_STR
;
}
}
framework/yii/db/cubrid/QueryBuilder.php
View file @
c6ef7ec9
...
...
@@ -10,7 +10,7 @@ namespace yii\db\cubrid;
use
yii\base\InvalidParamException
;
/**
* QueryBuilder is the query builder for CUBRID databases.
* QueryBuilder is the query builder for CUBRID databases
(version 9.1.x and higher)
.
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
...
...
framework/yii/db/cubrid/Schema.php
View file @
c6ef7ec9
...
...
@@ -243,4 +243,23 @@ class Schema extends \yii\db\Schema
}
return
$tableNames
;
}
/**
* Determines the PDO type for the give PHP data value.
* @param mixed $data the data whose PDO type is to be determined
* @return integer the PDO type
* @see http://www.php.net/manual/en/pdo.constants.php
*/
public
function
getPdoType
(
$data
)
{
static
$typeMap
=
array
(
'boolean'
=>
\PDO
::
PARAM_STR
,
// CUBRID PDO does not support PARAM_BOOL
'integer'
=>
\PDO
::
PARAM_INT
,
'string'
=>
\PDO
::
PARAM_STR
,
'resource'
=>
\PDO
::
PARAM_LOB
,
'NULL'
=>
\PDO
::
PARAM_NULL
,
);
$type
=
gettype
(
$data
);
return
isset
(
$typeMap
[
$type
])
?
$typeMap
[
$type
]
:
\PDO
::
PARAM_STR
;
}
}
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