php - How to write a wrapper around bind_params? -
php - How to write a wrapper around bind_params? -
i'd write wrapper function around mysqli's bind_param. in documentation (oo style) function signature bool mysqli_stmt::bind_param ( string $types , mixed &$var1 [, mixed &$... ] ), wonder function's signature should , how pass parameters bind_param.
i know func_get_args function turn parameters array , have no thought happen reference values. possible?
okay, first commented, summarise situation quite , lay finger wound gets stuck:
passing reference variable number of parameters.this state of fine art in answer "php mysqli wrapper: passing reference __call() , call_user_func_array()" apr 2010 same topic.
so new year's day variadic functions new php 5.6 (rfc) by-reference capture possible. , illustration in section has code you're looking for:
class mysql implements db { public function prepare($query, &...$params) { $stmt = $this->pdo->prepare($query); foreach ($params $i => &$param) { $stmt->bindparam($i + 1, $param); } homecoming $stmt; } // ... } find out more feature in php manual: http://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list
php mysqli
Comments
Post a Comment