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
58f8293b
Commit
58f8293b
authored
Sep 06, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom bindValue test for cubrid
parent
791f9d3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
cubrid.sql
tests/unit/data/cubrid.sql
+1
-0
CubridCommandTest.php
tests/unit/framework/db/cubrid/CubridCommandTest.php
+63
-0
No files found.
tests/unit/data/cubrid.sql
View file @
58f8293b
...
...
@@ -66,6 +66,7 @@ CREATE TABLE `tbl_type` (
`char_col`
char
(
100
)
NOT
NULL
,
`char_col2`
varchar
(
100
)
DEFAULT
'something'
,
`char_col3`
string
,
`enum_col`
enum
(
'a'
,
'b'
),
`float_col`
double
NOT
NULL
,
`float_col2`
double
DEFAULT
'1.23'
,
`blob_col`
blob
,
...
...
tests/unit/framework/db/cubrid/CubridCommandTest.php
View file @
58f8293b
...
...
@@ -10,4 +10,67 @@ class CubridCommandTest extends CommandTest
$this
->
driverName
=
'cubrid'
;
parent
::
setUp
();
}
public
function
testBindParamValue
()
{
$db
=
$this
->
getConnection
();
// bindParam
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, :name, :address)'
;
$command
=
$db
->
createCommand
(
$sql
);
$email
=
'user4@example.com'
;
$name
=
'user4'
;
$address
=
'address4'
;
$command
->
bindParam
(
':email'
,
$email
);
$command
->
bindParam
(
':name'
,
$name
);
$command
->
bindParam
(
':address'
,
$address
);
$command
->
execute
();
$sql
=
'SELECT name FROM tbl_customer WHERE email=:email'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindParam
(
':email'
,
$email
);
$this
->
assertEquals
(
$name
,
$command
->
queryScalar
());
$sql
=
"INSERT INTO tbl_type (int_col, char_col, char_col2, enum_col, float_col, blob_col, numeric_col, bool_col, bool_col2) VALUES (:int_col, '', :char_col, :enum_col, :float_col, CHAR_TO_BLOB(:blob_col), :numeric_col, :bool_col, :bool_col2)"
;
$command
=
$db
->
createCommand
(
$sql
);
$intCol
=
123
;
$charCol
=
'abc'
;
$enumCol
=
'a'
;
$floatCol
=
1.23
;
$blobCol
=
"
\x10\x11\x12
"
;
$numericCol
=
'1.23'
;
$boolCol
=
false
;
$boolCol2
=
true
;
$command
->
bindParam
(
':int_col'
,
$intCol
);
$command
->
bindParam
(
':char_col'
,
$charCol
);
$command
->
bindParam
(
':enum_col'
,
$enumCol
);
$command
->
bindParam
(
':float_col'
,
$floatCol
);
$command
->
bindParam
(
':blob_col'
,
$blobCol
);
$command
->
bindParam
(
':numeric_col'
,
$numericCol
);
$command
->
bindParam
(
':bool_col'
,
$boolCol
);
$command
->
bindParam
(
':bool_col2'
,
$boolCol2
);
$this
->
assertEquals
(
1
,
$command
->
execute
());
$sql
=
'SELECT * FROM tbl_type'
;
$row
=
$db
->
createCommand
(
$sql
)
->
queryOne
();
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$enumCol
,
$row
[
'enum_col'
]);
$this
->
assertEquals
(
$charCol
,
$row
[
'char_col2'
]);
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
$this
->
assertEquals
(
$blobCol
,
fread
(
$row
[
'blob_col'
],
3
));
$this
->
assertEquals
(
$numericCol
,
$row
[
'numeric_col'
]);
$this
->
assertEquals
(
$boolCol
,
$row
[
'bool_col'
]);
$this
->
assertEquals
(
$boolCol2
,
$row
[
'bool_col2'
]);
// bindValue
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, \'user5\', \'address5\')'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':email'
,
'user5@example.com'
);
$command
->
execute
();
$sql
=
'SELECT email FROM tbl_customer WHERE name=:name'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':name'
,
'user5'
);
$this
->
assertEquals
(
'user5@example.com'
,
$command
->
queryScalar
());
}
}
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