connect(); $client = new Client($db); $client->cid = $data->id; $result = $client->read(); $num = $result->rowCount(); $tempObject = new stdClass(); $tempObject->data = NULL; if ($num > 0) { $row = $result->fetch(PDO::FETCH_ASSOC); extract($row); $item = array( "id" => $cid, "name" => $name, "poc" => $poc, "email" => $email, "mobile" => $mobile, "address" => $address, "country" => $country ); $tempObject->data = $item; } echo json_encode($tempObject);