Php? Mysql

Source: Internet
Author: User
Php? Returned results of mysql:
Array
(
[0] => 3
[1] => 59
[2] => 23
[3] => 4
[4] => 61
)
....  $data = array();        if (!$error=$this->query($sql)) {            $results = array();            while (!($error=$this->fetchArray($results))) {                $data[] = $results;            }        }        $this->free();        return $data;....


Reply to discussion (solution)

What does your php code mean?

What does your php code mean?


Read data from the database
public getInfo(){     $sql="select * from table";     $result=$this->db->getAllone($sql);     return $result;}

function getAllone($sql) {        $data = array();        if (!$error=$this->query($sql)) {            $results = array();            while (!($error=$this->fetchArray($results))) {                $data[] = $results;            }        }        $this->free();        return $data;    }

Where does the data in your texture get from?

Where does the data in your texture get from?



Read from the database
It is an Array nested Array.
What I want is to directly query the value in Array (only one field in the table is queried)
Modify the following function.
function getAllone($sql) {        $data = array();        if (!$error=$this->query($sql)) {            $results = array();            while (!($error=$this->fetchArray($results))) {                $data[] = $results;            }        }        $this->free();        return $data;    }

The problem is:
$ Results = array (); // This is an empty array
While (! ($ Error = $ this-> fetchArray ($ results ))){
$ Data [] = $ results; // You assign an empty array to $ data []. how can this problem be solved?
}

The problem is:
$ Results = array (); // This is an empty array
While (! ($ Error = $ this-> fetchArray ($ results ))){
$ Data [] = $ results; // You assign an empty array to $ data []. how can this problem be solved?
}



My fault
FetchArray () is a user-defined function,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.