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
7133f129
Commit
7133f129
authored
Mar 24, 2014
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added count variable which stores returned rows count
parent
009cd11a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
MysqliDb.php
MysqliDb.php
+9
-0
readme.md
readme.md
+6
-4
No files found.
MysqliDb.php
View file @
7133f129
...
@@ -68,6 +68,12 @@ class MysqliDb
...
@@ -68,6 +68,12 @@ class MysqliDb
* @var array
* @var array
*/
*/
protected
$_bindParams
=
array
(
''
);
// Create the empty 0 index
protected
$_bindParams
=
array
(
''
);
// Create the empty 0 index
/**
* Variable which holds an amount of returned rows during get/getOne/select queries
*
* @var string
*/
public
$count
=
0
;
/**
/**
* @param string $host
* @param string $host
...
@@ -118,6 +124,7 @@ class MysqliDb
...
@@ -118,6 +124,7 @@ class MysqliDb
$this
->
_query
=
null
;
$this
->
_query
=
null
;
$this
->
_whereTypeList
=
null
;
$this
->
_whereTypeList
=
null
;
$this
->
_paramTypeList
=
null
;
$this
->
_paramTypeList
=
null
;
$this
->
count
=
0
;
}
}
/**
/**
...
@@ -615,6 +622,8 @@ class MysqliDb
...
@@ -615,6 +622,8 @@ class MysqliDb
}
}
array_push
(
$results
,
$x
);
array_push
(
$results
,
$x
);
}
}
$this
->
count
=
$stmt
->
num_rows
;
return
$results
;
return
$results
;
}
}
...
...
readme.md
View file @
7133f129
...
@@ -30,7 +30,8 @@ if($id)
...
@@ -30,7 +30,8 @@ if($id)
```
```
### Select Query
### Select Query
After any select/get function calls amount or returned rows
is stored in $count variable
```
php
```
php
$users
=
$db
->
get
(
'users'
);
//contains an array of all users
$users
=
$db
->
get
(
'users'
);
//contains an array of all users
$users
=
$db
->
get
(
'users'
,
10
);
//contains an array 10 users
$users
=
$db
->
get
(
'users'
,
10
);
//contains an array 10 users
...
@@ -44,9 +45,10 @@ echo "total ".$stats['cnt']. "users found";
...
@@ -44,9 +45,10 @@ echo "total ".$stats['cnt']. "users found";
$cols
=
Array
(
"id, name, email"
);
$cols
=
Array
(
"id, name, email"
);
$users
=
$db
->
get
(
"users"
,
null
,
$cols
);
$users
=
$db
->
get
(
"users"
,
null
,
$cols
);
foreach
(
$users
as
$user
)
{
if
(
$db
->
count
>
0
)
foreach
(
$users
as
$user
)
{
print_r
(
$user
);
print_r
(
$user
);
}
}
```
```
or select just one row
or select just one row
...
...
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