PHP Classes

File: fwphp/glomodul/z_examples/ora11g/ACXE2/equip_getjson_count.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/z_examples/ora11g/ACXE2/equip_getjson_count.php   Download  
File: fwphp/glomodul/z_examples/ora11g/ACXE2/equip_getjson_count.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/z_examples/ora11g/ACXE2/equip_getjson_count.php
Date: 1 year ago
Size: 1,096 bytes


Class file image Download
/* H:\dev_web\htdocs\t_oci8\ACXE2\equip_getjson_count.php
 Service returning detail counts (statistics) in JSON format
 There is no authentication in this web service. It is "external" to
 this app. All it requires is a username entry in the POST data
 Script queries details and uses PHPs json_encode()
 Output returned by the web service e.g is :
{"cardboard box":1,"pen":4,"computer":2,"telephone":3,"paper":3,"car":1}

JSON format is often used to efficiently transfer data between
browser and PHP server. This web service could be used
directly in many of available JSON graphics libraries.
if (!isset($_POST['username'])) {
header('Location: index.php');
$db = new \Oracle\Db("Equipment", $_POST['username']);
$sql = "select equip_name, count(equip_name) as cn
        from equipment
        group by equip_name"
$res = $db->execFetchAll($sql, "Get Equipment Counts");
$mydata = array();
foreach (
$res as $row) {
$mydata[$row['EQUIP_NAME']] = (int) $row['CN'];