note 107202 added to mysqli.prepare

From: Date: Sat, 14 Jan 2012 07:18:34 +0000
Subject: note 107202 added to mysqli.prepare
Groups: php.notes 
Request: Send a blank email to php-notes+get-185646@lists.php.net to get a copy of this message
My previous post had errors in the examples, it should look like what is below. Pardon for the spam, but it should be worth your time: Example(s): For a table of firstName and lastName: John Smith Mark Smith Jack Johnson Bob Johnson <?php //single query, single result $query = "SELECT * FROM names WHERE firstName=? AND lastName=?"; $params = array("Bob","Johnson"); mysqli_prepared_query($link,$query,"ss",$params) /* returns array( 0=> array('firstName' => 'Bob', 'lastName' => 'Johnson') ) */ //single query, multiple results $query = "SELECT * FROM names WHERE lastName=?"; $params = array("Smith"); mysqli_prepared_query($link,$query,"s",$params) /* returns array( 0=> array('firstName' => 'John', 'lastName' => 'Smith') 1=> array('firstName' => 'Mark', 'lastName' => 'Smith') ) */ //multiple query, multiple results $query = "SELECT * FROM names WHERE lastName=?"; $params = array(array("Smith"),array("Johnson")); mysqli_prepared_query($link,$query,"s",$params) /* returns array( 0=> array( 0=> array('firstName' => 'John', 'lastName' => 'Smith') 1=> array('firstName' => 'Mark', 'lastName' => 'Smith') ) 1=> array( 0=> array('firstName' => 'Jack', 'lastName' => 'Johnson') 1=> array('firstName' => 'Bob', 'lastName' => 'Johnson') ) ) */ Hope it helps =) ---- Server IP: 69.147.83.197 Probable Submitter: 24.5.125.223 ---- Manual Page -- http://www.php.net/manual/en/mysqli.prepare.php Edit -- https://master.php.net/note/edit/107202 Del: integrated -- https://master.php.net/note/delete/107202/integrated Del: useless -- https://master.php.net/note/delete/107202/useless Del: bad code -- https://master.php.net/note/delete/107202/bad+code Del: spam -- https://master.php.net/note/delete/107202/spam Del: non-english -- https://master.php.net/note/delete/107202/non-english Del: in docs -- https://master.php.net/note/delete/107202/in+docs Del: other reasons-- https://master.php.net/note/delete/107202 Reject -- https://master.php.net/note/reject/107202 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185646) next »