mysqli resultset görüntüler null olarak

0 Cevap php

Ben verileri görüntülemek için mysqli kullanmak çalışıyorum, ama hiçbir şey gösterir.

ne benim koduyla yanlış?

php class:

/* the database object */
        private $_db;

        public function __construct($db=NULL)
        {
            if(is_object($db))
            {
                $this->_db = $db;
            }
            else
            {

                $this->_db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
            }
        }

        public function displayQuotes()
        {
            $sql = "SELECT cQuotes, vAuthor, cArabic, vReference 
                          FROM thquotes 
                          ORDER BY RAND()
                      LIMIT 1;";



                      $query = $this->_db->prepare($sql);
                      $query->execute();
                  $query->store_result();

                      /* bind variables to prepared statement */
                      $query->bind_result($cQuotes, $vAuthor, $cArabic, $vReference);


                      if(!$query->num_rows==0)
                      {
                        while($row = $query->fetch())
                        {
                            //echo $this->formatQuotes($row);
                            $formatHTML = new formatHTML();
                            echo $formatHTML->formatQuotes($row);
                        }


                      }
                      else
                         {
                            echo "There are no Quotes!";
                         }
                       $query->free_result();
                      $query->close();



        }

o if(!$query->num_rows==0) beyanı okumak yok ve başka bir bölümüne gitmez bu yana veri resultset var, ama bir şey göstermiyor neden ben bilemiyorum.

php dosyası:

include "base.php";
include_once "inc/class.quotes-m.inc.php";
$quotes = new Quotes($db);

$quotes->displayQuotes();

php base.php:

include_once("inc/constants.inc.php");

error_reporting(E_ALL);
ini_set("display_errors", 1);



        $db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

         if (!$db) {
            echo 'db link fail';
        }

0 Cevap