|
Posted by Rik on 07/05/06 10:42
Dodger wrote:
> $dbh = new mysqli('localhost','user','password','database');
> if ($err = mysqli_connect_errno()) {
> print "Connect failed: $err";
> exit();
> }
>
> $query = <<<EOF
> SELECT *
> FROM cities
> WHERE Country = ?
> EOF;
> $statement = $dbh->prepare($query);
> $statement->bind_param('USA');
> $statement->execute();
> $statement->store_result();
> $cities = array();
> $i = 0;
> while ($city = $statement->fetch_assoc()) {
> $cities[$i] = $city;
> $i++;
> }
mysqli_stmt_fetch_assoc doesn't exist, mysqli_stmt_fetch does.
$statement->bind_results($city);
while ($statement->fetch()) {
$cities[] = $city;
}
Look at the example at
http://www.php.net/manual/en/function.mysqli-stmt-bind-result.php
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|