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
179cde2d
Commit
179cde2d
authored
Feb 09, 2015
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added getValue function
parent
9b62b349
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
MysqliDb.php
MysqliDb.php
+17
-0
readme.md
readme.md
+7
-0
No files found.
MysqliDb.php
View file @
179cde2d
...
@@ -283,6 +283,23 @@ class MysqliDb
...
@@ -283,6 +283,23 @@ class MysqliDb
return
null
;
return
null
;
}
}
/**
* A convenient SELECT * function to get one value.
*
* @param string $tableName The name of the database table to work with.
*
* @return array Contains the returned column from the select query.
*/
public
function
getValue
(
$tableName
,
$column
)
{
$res
=
$this
->
get
(
$tableName
,
1
,
"
{
$column
}
as retval"
);
if
(
isset
(
$res
[
0
][
"retval"
]))
return
$res
[
0
][
"retval"
];
return
null
;
}
/**
/**
*
*
* @param <string $tableName The name of the table.
* @param <string $tableName The name of the table.
...
...
readme.md
View file @
179cde2d
...
@@ -121,6 +121,13 @@ $stats = $db->getOne ("users", "sum(id), count(*) as cnt");
...
@@ -121,6 +121,13 @@ $stats = $db->getOne ("users", "sum(id), count(*) as cnt");
echo
"total "
.
$stats
[
'cnt'
]
.
"users found"
;
echo
"total "
.
$stats
[
'cnt'
]
.
"users found"
;
```
```
or select one column or function result
```
php
$count
=
getValue
(
"users"
,
"count(*)"
);
echo
"
{
$count
}
users found"
;
```
### Delete Query
### Delete Query
```
php
```
php
$db
->
where
(
'id'
,
1
);
$db
->
where
(
'id'
,
1
);
...
...
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