Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use fetch in php

Shulou Source: shulou.com Published: 2022-05-31 22:39:55 09月29日 Update

Today Xiaobian to share with you how to use fetch in php related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you have some harvest after reading this article, let's learn about it together.

Usage: 1."mysql_fetch_row" is used to fetch a row from the result set as a numeric array;2."mysql_fetch_array" is used to fetch a row from the result set as an associative array;3."mysql_fetch_object" is used to fetch a row from the result set as an object.

Operating environment: Windows 10, PHP 7.1, Dell G3

What is the use of fetch in PHP?

The fetch usage and differences of php query data are summarized as follows:

mysql_fetch_row;

The mysql_fetch_row() function fetches a row from the result set as an array of numbers.

The syntax is:

mysql_fetch_row(data)

Data is required. Pointer to the data to be used. This data pointer is the result returned from mysql_query().

mysql_fetch_array;

The mysql_fetch_array() function fetches a row from the result set as an associative array, a numeric array, or both

Returns an array generated from rows taken from the result set, or false if there are no more rows.

mysql_fetch_array(data,array_type)

Data is optional. Specifies the data pointer to be used. This data pointer is the result of the mysql_query() function.

array_type Optional. Specify which results are returned. Possible values:

MYSQL_ASSOC -associative array

MYSQL_NUM -Numeric array

MYSQL_BOTH -Default. Generate associative and numeric arrays simultaneously

mysql_fetch_assoc;

The mysql_fetch_assoc() function fetches a row from the result set as an associative array.

Returns an associative array generated from rows taken from the result set, or false if there are no more rows.

mysql_fetch_assoc(data)

Data is required. Pointer to the data to be used. This data pointer is the result returned from mysql_query().

mysql_fetch_object;

The mysql_fetch_object() function fetches a row from the result set (recordset) as an object.

If successful, this function takes a line from mysql_query() and returns an object. Returns false if it fails or if there are no more rows.

mysql_fetch_object(data)

Data is required. Pointer to the data to be used. This data pointer is the result returned from mysql_query().

The above is "how to use fetch in php" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Results arrays data one line pointers functions associations numbers more knowledge articles objects content generation different big successful and for the most part Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Apple NVidia MariaDB