Esempio n. 1
0
function render_result($array, $wrapper = "array", $type = "json")
{
    switch ($type) {
        // XML
        case "xml":
            echo array2xml($array, $wrapper);
            break;
            //JSON
        //JSON
        case "json":
            echo json_encode($array);
            // php internal function, input is array
            break;
            //JSON - human-readable ( only for debug)
        //JSON - human-readable ( only for debug)
        case "json_read":
            echo make_readable(json_encode($array));
            // php internal function, input is array
            break;
            //HTML
        //HTML
        case "html":
            html_show_array($array);
            break;
            //HTML Table
        //HTML Table
        case "html_table":
            html_table_show_array($array);
            break;
            //RAW
        //RAW
        case "raw":
            print_r($array);
            // php internal function, input is array (only for debug)
            break;
    }
}
Esempio n. 2
0
<?php

$Include_Dir = $_SERVER["DOCUMENT_ROOT"] . "/includes/";
include $Include_Dir . "dbopen.php";
$containing_dir = basename(dirname(__FILE__));
$sql_manyfields1row = mysql_query("SELECT * FROM table WHERE id = '1' LIMIT 1") or die(mysql_error());
$sql_1fieldmanyrows = mysql_query("SELECT id FROM table WHERE id > 0") or die(mysql_error());
while ($row_many = mysql_fetch_array($sql_manyfields1row)) {
    $a = $row_many['a'];
    // get a from database
    $b = $row_many['b'];
    // get b from database
    $c = substr($row_many['c'], 0, 250);
    // get first 250 characters of c from database
    $d = $row_many['d'];
    $e = $row_many['e'];
    $f = $row_many['f'];
    $g = $row_many['g'];
}
while ($row_one = mysql_fetch_array($sql_1fieldmanyrows)) {
    $one[] = $row_one['id'];
}
include $Include_Dir . "dbclose.php";
include $Include_Dir . "html_show_array.php";
html_show_array($row_one);
 public function data_type_converter()
 {
     $input = \Request::all();
     switch ($input['from-type']) {
         case "xml":
             $from = new \xml($input['data-content']);
             $from = $from->data;
             break;
         case "json":
             $from = json_decode($input['data-content'], true);
             break;
         case "yaml":
             $from = \Spyc::YAMLLoad($input['data-content']);
             break;
         case "csv":
             foreach (preg_split("/((\r?\n)|(\r\n?))/", $input['data-content']) as $line) {
                 $rec[] = str_getcsv($line);
             }
             $from = $rec;
             break;
         case "php_array":
             $current_input = $input['data-content'];
             eval("\$from = {$current_input};");
             break;
         case "php_object":
             $current_input = $input['data-content'];
             eval("\$from = {$current_input};");
             $from = json_decode(json_encode($from), true);
             break;
     }
     $php_data = $from;
     //echo "<pre>";var_export($from);die;
     //dd($php_data);
     if ($input['to-type'] == "json") {
         $output_data = json_encode($php_data, JSON_PRETTY_PRINT);
     } elseif ($input['to-type'] == "sql") {
         $output_data = '';
         foreach ($php_data as $line) {
             $fields = implode(",", array_keys($line));
             $prams = implode("','", array_values($line));
             $output_data .= "INSERT INTO table_name ({$fields}) VALUES ('{$prams}');\n";
         }
     } elseif ($input['to-type'] == "yaml") {
         $output_data = \Spyc::YAMLDump($php_data);
     } elseif ($input['to-type'] == "csv") {
         $lines = "";
         $lines .= implode(",", array_keys($php_data[0])) . "\n";
         foreach ($php_data as $array) {
             $lines .= implode(",", $array) . "\n";
         }
         $output_data = $lines;
     } elseif ($input['to-type'] == "xml") {
         //            $xml = new \SimpleXMLElement('<root/>');
         //            array_walk_recursive($php_data,array($xml,'addChild'));
         //            $output_data = $xml->asXML();
         $output_data = array2xml($php_data);
         dd($output_data);
     } elseif ($input['to-type'] == "php_array") {
         $output_data = var_export($php_data, true);
     } elseif ($input['to-type'] == "php_object") {
         $object_array = json_decode(json_encode($php_data), false);
         //            dd($object_array[0]->name);
         //            dd($object_array);
         $output_data = str_replace("stdClass::__set_state", "(object)", var_export($object_array, true));
     } elseif ($input['to-type'] == "html_table_multi") {
         html_show_array($php_data);
         die;
     } elseif ($input['to-type'] == "html_table_single") {
         phpArray_to_htmlTable_single($php_data);
         die;
     }
     //        dd($output_data);
     //        echo "<pre>";
     if ($output_data && $output_data != null) {
         echo $output_data;
     } else {
         http_response_code(500);
     }
     die;
 }
			'event'	=> 'BW-140629',
			'salariedYn'=>'1',
			'payrate' => '2300',
			'ficaYTD' => '6500',
			'ficaPercent' => '.015',
			'state'=>'AZ',
			'overtimeMultiplier' => '1.5'
		),
		'4' => array(
			'entity' => 'TAG-Simson-00002',
			'hoursWorked' => '23',
			'overtimeHours' => '5',
			'event'	=> 'BW-140629',
			'salariedYn'=>'0',
			'payrate' => '12.22',
			'ficaYTD' => '500',
			'ficaPercent' => '.015',
			'state'=>'AZ',
			'overtimeMultiplier' => '1.5'
		)
	);
**/
$TranTest = new transactionalEngine($Rules, $Data);
$TranTest->process();
html_show_array($TranTest->getData());
echo '<br>';
echo '<br>';
html_show_array($TranTest->getResultSet());
echo '<br>';
echo '<br>';
echo $TranTest->getTime();