Let's start with the basics - obtaining a list of current users from the database. If you've been following along, you already know that right now, the database has only a single user, "joe". Let's add a couple more: You can verify the result with a quick SQL query to the "users" table: Now, let's try doing the same with patUser: The first part of this script should be easily recognizable to you by now - it consists of the code needed to instantiate a patUser object instance and prepare it for use. Once the object has been prepared, the getUsers() function is used to retrieve a list of all the users in the database. The return value of the getUsers() method is an associative array containing user records, one element for each record. The first argument to the getUsers() function is an array containing the names of the fields to be included in the result set - these field names appear as keys in the returned array, and can be used to access the corresponding values. Here's the output: ![]() You're not restricted to using just the default fields built into the patUser database schema - you can just as easily add your own. Find out how, on the next page.
blog comments powered by Disqus |