Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67310 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69453 invoked from network); 5 May 2013 13:55:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 May 2013 13:55:43 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.98 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.98 blu0-omc2-s23.blu0.hotmail.com Windows 2000 SP4, XP SP1 Received: from [65.55.111.98] ([65.55.111.98:51392] helo=blu0-omc2-s23.blu0.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/B4-33933-DD466815 for ; Sun, 05 May 2013 09:55:43 -0400 Received: from BLU0-SMTP177 ([65.55.111.71]) by blu0-omc2-s23.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 5 May 2013 06:55:39 -0700 X-EIP: [a7FSWQAEq8AUXQn6SnMr9r+uN8kCuIeR] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Received: from bob-weinands-imac.fritz.box ([87.240.218.8]) by BLU0-SMTP177.phx.gbl over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 5 May 2013 06:55:37 -0700 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Sun, 5 May 2013 15:55:34 +0200 To: PHP Developers Mailing List MIME-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) X-Mailer: Apple Mail (2.1499) X-OriginalArrivalTime: 05 May 2013 13:55:37.0846 (UTC) FILETIME=[38E12960:01CE4998] Subject: Adding a new mysqli::bind_value method From: bobwei9@hotmail.com (Bob Weinand) I propose to add, contrary to the mysqli::bind_param method which = accepts parameters only by ref (and triggers a fatal error when passing = non-ref variables or values), a mysqli::bind_value method which accepts = the variables by value. There are a few problems when using bind_param which bind_value tries to = solve: a) When you aren't binding in a small scope, you have to make attention = to not reusing the variable before execute()'ing the mysqli_stmt = instance. b) You have to pass values per reference, so that you cannot do for = example in a function: call_user_func_array([$stmt, "bind_param"], = array_merge([str_repeat("s", func_num_args())], func_get_args())); this would fail in a message you couldn't pass them by value (when = you cannot write the function expecting references as variable for some = reason). A workaround would be to array_walk the array and pass the = variable by ref to a new array, which is not really handy. c) When you try to pass raw values instead of a reference, it results in = a "Fatal error: Cannot pass parameter 2 by reference". =20 d) Executing $stmt->bind_param("s", $a?$b:$c); would result in a "Strict = Standards: Only variables should be passed by reference". Yeah, it's = only a strict error, but I think it's best practice to code error = free... For c) and d): Yes, you could assign the result / raw value to a = variable and then pass it to the function, but this are only a variable = more, a code line more and a fraction of a nanosecond more = (microoptimization, I just wanted to say it). The PR for this request is at: https://github.com/php/php-src/pull/338 Bob