mahmoudafer
mahmoudafer

Reputation: 1181

what is the return type of an SQL SELECT query in php, is it array, object, or what?

I'm documenting functions in a REST API in php but I couldn't figure out the return type of a get all query, is it array, object, or what

Upvotes: 1

Views: 1855

Answers (1)

Andrei Todorut
Andrei Todorut

Reputation: 4526

This returns an object or a boolean.

In case you have an error in your SQL statement then the return value will be a boolean. In general, if no errors in your SQL your query will return a mysqli_result object.

That's an output example of a SQL query:

class mysqli_result#2 (5) {
  public $current_field =>
  int(0)
  public $field_count =>
  int(79)
  public $lengths =>
  NULL
  public $num_rows =>
  int(1457)
  public $type =>
  int(0)
}

Upvotes: 1

Related Questions