Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PHP-MySQLi-Database-Class
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
PHP-MySQLi-Database-Class
Commits
0cd7ef84
Commit
0cd7ef84
authored
Feb 15, 2015
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests
parent
00529ef3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
14 deletions
+29
-14
tests.php
tests.php
+29
-14
No files found.
tests.php
View file @
0cd7ef84
...
...
@@ -153,6 +153,10 @@ if ($db->count != 1) {
exit
;
}
$q
=
"drop table
{
$prefix
}
test;"
;
$db
->
rawQuery
(
$q
);
$db
->
orderBy
(
"id"
,
"asc"
);
$users
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
3
)
{
...
...
@@ -253,7 +257,7 @@ if ($db->count != 2) {
echo
"Invalid users count on where() with between"
;
exit
;
}
///
$db
->
where
(
"id"
,
2
);
$db
->
orWhere
(
"customerId"
,
11
);
$r
=
$db
->
get
(
"users"
);
...
...
@@ -261,14 +265,14 @@ if ($db->count != 2) {
echo
"Invalid users count on orWhere()"
;
exit
;
}
///
$db
->
where
(
"lastName"
,
NULL
,
'<=>'
);
$r
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
1
)
{
echo
"Invalid users count on null where()"
;
exit
;
}
///
$db
->
join
(
"users u"
,
"p.userId=u.id"
,
"LEFT"
);
$db
->
where
(
"u.login"
,
'user2'
);
$db
->
orderBy
(
"CONCAT(u.login, u.firstName)"
);
...
...
@@ -277,7 +281,7 @@ if ($db->count != 2) {
echo
"Invalid products count on join ()"
;
exit
;
}
///
$db
->
where
(
"id = ? or id = ?"
,
Array
(
1
,
2
));
$res
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
2
)
{
...
...
@@ -285,26 +289,40 @@ if ($db->count != 2) {
exit
;
}
///
$db
->
where
(
"id = 1 or id = 2"
);
$res
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
2
)
{
echo
"Invalid users count on select with multiple params"
;
exit
;
}
///
$usersQ
=
$db
->
subQuery
();
$usersQ
->
where
(
"login"
,
"user2"
);
$usersQ
->
getOne
(
"users"
,
"id"
);
$db2
=
$db
->
copy
();
$db2
->
where
(
"userId"
,
$usersQ
);
$cnt
=
$db2
->
getValue
(
"products"
,
"count(id)"
);
$db
->
where
(
"userId"
,
$usersQ
);
$cnt
=
$db
->
getValue
(
"products"
,
"count(id)"
);
if
(
$cnt
!=
2
)
{
echo
"Invalid select result with subquery"
;
exit
;
}
///
$dbi_sub
=
$db
->
subQuery
();
$dbi_sub
->
where
(
'active'
,
1
);
$dbi_sub
->
get
(
'users'
,
null
,
'id'
);
$db
->
where
(
'id'
,
$dbi_sub
,
'IN'
);
$cnt
=
$db
->
copy
();
$count_members
=
$cnt
->
getValue
(
'users'
,
"COUNT(id)"
);
echo
"count
{
$count_members
}
\n
"
;
echo
$cnt
->
getLastQuery
()
.
"
\n
"
;
$data
=
$db
->
get
(
'users'
);
print_r
(
$data
);
echo
$cnt
->
getLastQuery
()
.
"
\n
"
;
///
$usersQ
=
$db
->
subQuery
(
"u"
);
$usersQ
->
where
(
"active"
,
1
);
$usersQ
->
get
(
"users"
);
...
...
@@ -319,7 +337,7 @@ if ($db->count != 5) {
echo
"invalid join with subquery count"
;
exit
;
}
///
//TODO: insert test
$db
->
delete
(
"users"
);
$db
->
get
(
"users"
);
...
...
@@ -329,9 +347,6 @@ if ($db->count != 0) {
}
$db
->
delete
(
"products"
);
$q
=
"drop table
{
$prefix
}
test;"
;
$db
->
rawQuery
(
$q
);
echo
"All done"
;
//print_r($db->rawQuery("CALL simpleproc(?)",Array("test")));
...
...
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