Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pquery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pquery
Commits
72b6e456
Commit
72b6e456
authored
Dec 05, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added result_count method to SQL plugin.
parent
1d53c44e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
pquery.sql.php
pquery.sql.php
+14
-0
test/test_sql.php
test/test_sql.php
+8
-2
No files found.
pquery.sql.php
View file @
72b6e456
...
@@ -140,6 +140,20 @@ class pQuerySql extends pQuery implements pQueryExtension {
...
@@ -140,6 +140,20 @@ class pQuerySql extends pQuery implements pQueryExtension {
return
$this
;
return
$this
;
}
}
/**
* Find the number of resulting rows of the current query.
*
* @returns int The number of rows.
*/
function
result_count
()
{
$this
->
assert_execution
();
if
(
!
$this
->
result
)
return
0
;
return
mysql_num_rows
(
$this
->
result
);
}
/**
/**
* Fetch a row from the current result.
* Fetch a row from the current result.
*
*
...
...
test/test_sql.php
View file @
72b6e456
...
@@ -53,8 +53,14 @@ class pQuerySqlTest extends UnitTestCase {
...
@@ -53,8 +53,14 @@ class pQuerySqlTest extends UnitTestCase {
function
test_select_simple
()
{
function
test_select_simple
()
{
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$results
=
$sql
->
fetch_all
(
'object'
);
$result
=
$sql
->
fetch
(
'object'
);
$this
->
assertEqual
(
$results
[
0
]
->
bar
,
'test1'
);
$this
->
assertEqual
(
$result
->
bar
,
'test1'
);
$this
->
assertIdentical
(
$sql
->
fetch
(),
false
);
}
function
test_result_count
()
{
$sql
=
_sql
(
"select bar from foo where id in (1, 2)"
);
$this
->
assertEqual
(
$sql
->
result_count
(),
2
);
}
}
}
}
...
...
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