simplify parser a bit
This commit is contained in:
23
db.class.php
23
db.class.php
@@ -471,13 +471,7 @@ class MeekroDB {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse($query) {
|
protected function preParse($query, $args) {
|
||||||
$args = func_get_args();
|
|
||||||
array_shift($args);
|
|
||||||
$query = trim($query);
|
|
||||||
|
|
||||||
if (! $args) return $query;
|
|
||||||
|
|
||||||
$arg_ct = 0;
|
$arg_ct = 0;
|
||||||
$max_numbered_arg = 0;
|
$max_numbered_arg = 0;
|
||||||
$use_numbered_args = false;
|
$use_numbered_args = false;
|
||||||
@@ -521,6 +515,17 @@ class MeekroDB {
|
|||||||
return $this->nonSQLError(sprintf('Expected %d args, but only got %d!', $max_numbered_arg+1, count($args)));
|
return $this->nonSQLError(sprintf('Expected %d args, but only got %d!', $max_numbered_arg+1, count($args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $queryParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parse($query) {
|
||||||
|
$args = func_get_args();
|
||||||
|
array_shift($args);
|
||||||
|
$query = trim($query);
|
||||||
|
|
||||||
|
if (! $args) return $query;
|
||||||
|
$queryParts = $this->preParse($query, $args);
|
||||||
|
|
||||||
$array_types = array('ls', 'li', 'ld', 'lb', 'll', 'lt', 'l?', 'll?', 'hc', 'ha', 'ho');
|
$array_types = array('ls', 'li', 'ld', 'lb', 'll', 'lt', 'l?', 'll?', 'hc', 'ha', 'ho');
|
||||||
$Map = $this->paramsMap();
|
$Map = $this->paramsMap();
|
||||||
$query = '';
|
$query = '';
|
||||||
@@ -534,7 +539,7 @@ class MeekroDB {
|
|||||||
$is_array_type = in_array($Part['type'], $array_types, true);
|
$is_array_type = in_array($Part['type'], $array_types, true);
|
||||||
|
|
||||||
$val = null;
|
$val = null;
|
||||||
if ($use_named_args && !is_null($Part['named_arg'])) {
|
if (!is_null($Part['named_arg'])) {
|
||||||
$key = $Part['named_arg'];
|
$key = $Part['named_arg'];
|
||||||
if (! array_key_exists($key, $args[0])) {
|
if (! array_key_exists($key, $args[0])) {
|
||||||
return $this->nonSQLError("Couldn't find named arg {$key}!");
|
return $this->nonSQLError("Couldn't find named arg {$key}!");
|
||||||
@@ -542,7 +547,7 @@ class MeekroDB {
|
|||||||
|
|
||||||
$val = $args[0][$key];
|
$val = $args[0][$key];
|
||||||
}
|
}
|
||||||
else if ($use_numbered_args && !is_null($Part['arg'])) {
|
else if (!is_null($Part['arg'])) {
|
||||||
$key = $Part['arg'];
|
$key = $Part['arg'];
|
||||||
$val = $args[$key];
|
$val = $args[$key];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user