Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
wfpl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of /home/jason/dev/git/wfpl
[wfpl.git]
/
db.php
diff --git
a/db.php
b/db.php
index
065ac0e
..
0a1369f
100644
(file)
--- a/
db.php
+++ b/
db.php
@@
-111,7
+111,6
@@
function db_printf($str) {
# This function does the work, but takes the parameters in an array
function _db_printf($str, $args) {
# This function does the work, but takes the parameters in an array
function _db_printf($str, $args) {
- $args = array_reverse($args); # because array_pop() takes from the end
$out = '';
while($str) {
$pos = strpos($str, '%');
$out = '';
while($str) {
$pos = strpos($str, '%');
@@
-129,9
+128,11
@@
function _db_printf($str, $args) {
$str = substr($str, $pos + 2);
if($chr == '"') {
$str = substr($str, $pos + 2);
if($chr == '"') {
- $out .= '"' . enc_sql(array_pop($args)) . '"';
+ $out .= '"' . enc_sql(array_shift($args)) . '"';
+ } elseif($chr == 's') {
+ $out .= enc_sql(array_shift($args));
} elseif($chr == 'i') {
} elseif($chr == 'i') {
- $int = format_int(array_pop($args));
+ $int = format_int(array_shift($args));
if($int == '') $int = '0';
$out .= $int;
} else {
if($int == '') $int = '0';
$out .= $int;
} else {
@@
-210,6
+211,12
@@
function db_get_value($table, $columns, $where = '') {
return $value;
}
return $value;
}
+function db_count($table, $where = '') {
+ $args = func_get_args();
+ array_splice($args, 1, 0, array('count(*)'));
+ return call_user_func_array('db_get_value', $args);
+}
+
# call either of these ways:
#
# db_insert('people', 'name,company', 'jason', 'widgets ltd');
# call either of these ways:
#
# db_insert('people', 'name,company', 'jason', 'widgets ltd');