How does the $query of the query come into the data array?

Source: Internet
Author: User
$query = $this->db->select (' Select dep_id, dep_name from Xy_departments ORDER by dep_id ASC ');


How did the $query of the query come into
$data = Array (
' Finance ' and ' finance ',
' Philosophy ' = ' philosophy '
);
The array form of this


Reply to discussion (solution)

Print_r ($query);

What are you looking at?

Print_r ($query);

What are you looking at?



Ci_db_mysql_result Object
(
[CONN_ID] = Resource ID #51
[RESULT_ID] = Resource ID #59
[Result_array] = = Array
(
)

[Result_object] = = Array
(
)

[Custom_result_object] = = Array
(
)

[Current_row] = 0
[Num_rows] = 3
[Row_data] =
)

http://blog.csdn.net/cindylu520/article/details/4098360

$rows = Mysql_fetch_assoc ($query);

You can use the mysql_fetch_array (data,array_type) function
Parameters:
data--The result set of the query
ARRAY_TYPE--MYSQL_ASSOC (produces associative array), Mysql_num (produces a numeric array), Mysql_both (default, simultaneously produces associative and numeric arrays)

Remove the array, and the For loop is assembled into a new array form.

CI Framework with Var_dump ($result->result_array ()); Print out associative arrays

Manual Description:
Result_array ()
When the method executes successfully, the recordset is returned as an associative array. Returns an empty array upon failure. In general, we use the following method to iterate through the results, as the code looks like:

$query = $this->db->query ("SQL to execute");

foreach ($query->result_array () as $row)
{
echo $row [' title '];
echo $row [' name '];
echo $row [' body '];
}

$result = Array (), while ($row = Mysql_fetch_assoc ($query)) {    $result [] = $row;} Print_r ($result);
  • Related Article

    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.