From c82d05ef502fb1fcc130a83e8d553f6fb1b9f95f Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Thu, 23 Jul 2015 21:35:02 +0300 Subject: [PATCH] Example.php: Some comment modifications. --- application/controllers/api/Example.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/api/Example.php b/application/controllers/api/Example.php index 72da4cc2..479d790c 100644 --- a/application/controllers/api/Example.php +++ b/application/controllers/api/Example.php @@ -33,7 +33,6 @@ function __construct() public function users_get() { // Users from a data store e.g. database - // $user = $this->some_model->getSomething($id); $users = [ ['id' => 1, 'name' => 'John', 'email' => 'john@example.com', 'fact' => 'Loves coding'], ['id' => 2, 'name' => 'Jim', 'email' => 'jim@example.com', 'fact' => 'Developed on CodeIgniter'], @@ -42,7 +41,8 @@ public function users_get() $id = $this->get('id'); - // If the id parameter and query parameter don't exist, return all users instead + // If the id parameter doesn't exist return all the users + if ($id === NULL) { // Check if the users data store contains users (in case the database result returns NULL) @@ -61,6 +61,8 @@ public function users_get() } } + // Find and return a single record for a particular user. + $id = (int) $id; // Validate the id.