Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

SELECT QUERIES from PHP

  • SELECT queries return a ‘table’ of data known as a result set.
  • SELECT queries are run using MySQLi->query() and will return a MySQLi_Result object, which is a class is used to represent result sets returned from SELECT queries.
    • It has the property num_rows which holds the number of rows in the result set.
    • It has the following methods for processing the result set, which will return NULL if there are no more rows in the result set:
      • fetch_assoc() – fetch a row of the result set & return it as an associative array
      • fetch_object() – fetch a row of the result set & return it as an object of class stdClass
  • fetch_assoc() returns the next row of a result set as an associative array with the keys of the array being the names of the columns in the result set.
  • PHP has a built-in class called stdClass that can be used to hold data in object form as object properties. All of the properties of an instance of a stdClass object are publicly accessible.
  • fetch_object() returns the next row of a result set as a stdClass object with property names matching the names of the columns in the result set.
  • MySQLi_Result->free()is used to free memory used by a result set. It should always be called after the processing of a result set is finished.
  • Additional Resources:

SELECT QUERIES from PHP

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Advanced PHP Training with MySQL