Site icon Learn Web Development & Programming, Artificial Intelligence, WordPress, Shopify Articles

In how many ways can you retrieve data in the result set of MySQL using PHP? What is the difference between mysql_fetch_object and mysql_fetch_array?

We can retrieve data in the result set of MySQL using PHP in four Ways

  1. mysqli_fetch_row >> Get a result row as an enumerated array
  2. mysqli_fetch_array >> Fetch a result row as associative and numeric array
  3. mysqli_fetch_object >> Returns the current row of a result set as an object
  4. mysqli_fetch_assoc >> Fetch a result row as an associative array
    mysqli_fetch_object() is similar to mysqli_fetch_array(), with one difference –
    an object is returned instead of an array, which implies that that we can only access the data by the field names, and not by their offsets (numbers are illegal property names).
Exit mobile version