php MySqli: Как я могу переписать fetch для fetch_assoc? КАК КОНКАТ

Helo, я использую «bind_result», «LIKE CONCAT» … для полнотекстового поиска и разбиения на страницы по двум строкам запроса.

но как я могу изменить методы bind_result для fetch_assoc?

<?php $mysqli = new mysqli("localhost", "", "", "test"); $query_string="hello"; //keywords $sqltxt="SELECT * FROM `table` WHERE text1 LIKE CONCAT('%', ?, '%')"; //first query : for get the total number of data $stmt = $mysqli->prepare($sqltxt); $stmt->bind_param("s",$query_string); $stmt->execute(); $stmt->store_result(); $total =$stmt->num_rows; $lastpage = ceil($total/20);//obtain the last page $page=$_GET["page"]; $startpoint = ($page * 20) - 20; //second query : for get the true data $stmt = $mysqli->prepare($sqltxt ." LIMIT {$startpoint}, 20"); $stmt->bind_param("s",$query_string); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($id,$title,$tel); //<= hits!! I want to using fetch_assoc methods while($stmt->fetch()){ //<= hits!! I want to using fetch_assoc methods echo $id; echo $atitle; echo $tel; } ?> 

Благодаря!

Related of "php MySqli: Как я могу переписать fetch для fetch_assoc? КАК КОНКАТ"

Из примеров документации mysql:

 <?php // ... document's example code: /* bind parameters for markers */ $stmt->bind_param("s", $city); /* execute query */ $stmt->execute(); /* instead of bind_result: */ $result = $stmt->get_result(); //with get_result ;) /* now you can fetch the results into an array - NICE */ while ($myrow = $result->fetch_assoc()) { //now you can use fetch_assoc // use your $myrow array as you would with any other fetch printf("%s is in district %s\n", $city, $myrow['district']); } ?> 

———– EDITED ———————-

Пожалуйста, прочтите примечания пользователя для этого метода:

http://php.net/manual/en/mysqli-stmt.get-result.php

Для этого требуется драйвер mysqlnd … если он не установлен на вашем веб-пространстве, вам придется работать с BIND_RESULT & FETCH!

http://www.php.net/manual/en/mysqli-stmt.bind-result.php

http://www.php.net/manual/en/mysqli-stmt.fetch.php

Функция Только родной драйвер MySQL MySQL

Доступно только с mysqlnd: http://www.php.net/manual/en/book.mysqlnd.php

Примечание: mysqli_stmt :: get_result () доступен только на PHP v5.3.0 или выше

Я собираюсь искать другую альтернативу.

Салудос;)