summaryrefslogtreecommitdiff
path: root/it_dbi.class
diff options
context:
space:
mode:
authorChristian Schneider2021-02-03 10:30:22 +0100
committerChristian Schneider2021-02-03 10:30:22 +0100
commit21ccdefc4aea4c2439f7d41ece7d8216d8ba8b40 (patch)
tree3cb6969d9e34580fb0b2eaa64016850e048afb56 /it_dbi.class
parent039792e13581ebfd0ddc05bb115bc5f6bfa9cf46 (diff)
downloaditools-21ccdefc4aea4c2439f7d41ece7d8216d8ba8b40.tar.gz
itools-21ccdefc4aea4c2439f7d41ece7d8216d8ba8b40.tar.bz2
itools-21ccdefc4aea4c2439f7d41ece7d8216d8ba8b40.zip
Code cleanup: Switch to new style varargs
Diffstat (limited to 'it_dbi.class')
-rw-r--r--it_dbi.class18
1 files changed, 5 insertions, 13 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 65c083e..d8a3393 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -61,7 +61,7 @@ class it_dbi
* @param $p optional array(key => value) of configuration data
* @param $query Optional initial query to run
*/
-function __construct($p = array(), $query = null)
+function __construct($p = array(), $query = null, ...$args)
{
# Shortcut: String config means use this table with default values
if (!is_array($p))
@@ -90,12 +90,7 @@ function __construct($p = array(), $query = null)
$this->_p += $this->_get_field_info(); # Get $this->_fields and p[keyfield, autoincrement, randomid]
if (is_array($query))
- {
- # Call with all arguments except first one
- $args = func_get_args();
- array_shift($args);
- call_user_func_array(array($this, "select"), $args);
- }
+ $this->select($query, ...$args); # Call with all arguments except first one
else if (isset($query))
$this->read($query);
}
@@ -183,11 +178,8 @@ static function createclass($p)
$parentname = static::$_global_key;
$code = "class $classname extends $parentname $interface
{
- function __construct(/* \$query ... */)
+ function __construct(\$query = null, ...\$args)
{
- \$args = func_get_args();
- \$query = array_shift(\$args); # Preserve type (scalar/array) in single parameter case
-
foreach (\$args as \$arg)
\$query = array_merge((array)\$query, (array)\$arg);
@@ -651,10 +643,10 @@ function read($id=null)
* @see iterate()
* @see _where()
*/
-function select(/* $query = array|string, ... */)
+function select(...$args)
{
$query = array();
- foreach (func_get_args() as $arg)
+ foreach ($args as $arg)
$query = array_merge($query, (array)$arg);
$this->_connect();