PHP Classes

File: Controller.php

Recommend this page to a friend!
  Classes of adscript   DABAJAX Toolkit   Controller.php   Download  
File: Controller.php
Role: Example script
Content type: text/plain
Description: example of a controller
Class: DABAJAX Toolkit
Auto-complete fields with Oracle database data
Author: By
Last change: added the extension for the file
Date: 16 years ago
Size: 1,311 bytes
 

Contents

Class file image Download
<?php
  
/**
     EXAMPLE OF A CONTROLLER
   **/
   
require_once "AjaxControlFiller.class.php";
    require_once
"AjaxOptionsValidator.interface.php";
    require_once
"BusValidator.example.php";
   
   
/* retrieving values from XMLHttpRequest */
   
$jsons = $_POST["jsonstring"];
   
$jsons = str_replace("\\", "", $jsons);
   
$data = json_decode($jsons);
   
$options = $_POST;
   
   
// cria a variavel de resolucao do TNS
   
$db = "(DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)
            (HOST = yourhost)(PORT=1521))
        (SERVICE_NAME = yourSID)
           (FAILOVER_MODE =
               (TYPE = SELECT)
               (METHOD = BASIC)
               (RETRIES = 180)
               (DELAY = 5)
           )
        ))"
;
   
    if (!
$conn = @oci_connect("user", "passwd", $db)) {
       echo
"could not connect to database";
       exit();
    } else {
   
      
// example of a validator
      
$validator = new UserValidator( $conn );
      
      
$control = new AjaxControlFiller( $conn );
      
$control->setAjaxf( $data );
      
$control->setOptions( $options );
      
//$control->setOptionValidator( $validator );
      
$ret = $control->getResults();
       if (!
$ret) {
          echo
json_encode( $control->getErrors() );
       }
       echo
$ret;
    }
?>