/** * constructor */ public function __construct() { try { $json = ""; $counter = 0; parent::__construct(); if (isset($this->statuses)) { $items = $this->getData(); $json .= "["; if ($items) { foreach ($items as $item) { $item = array_map('utf8_encode', $item); if ($counter > 0) { $json .= ","; } $json .= json_encode($item); $counter++; } } $json .= "]"; //print json echo $this->getWrapper($json); } //close the database connection $this->db = NULL; } catch (PDOException $ex) { print "Exception: " . $ex->getMessage(); } }
/** * constructor */ public function __construct() { try { $json = ""; $counter = 0; $counter1 = 0; $counter2 = 0; parent::__construct(); if (isset($this->statuses)) { $items = $this->getData(); $items1 = $this->getKeyword1(); $items2 = $this->getKeyword2(); $json .= "["; if ($items) { foreach ($items as $item) { if ($counter > 0) { $json .= ","; } $json .= json_encode($item); $counter++; } } $json .= ',{ "keyword1": ['; foreach ($items1 as $item1) { if ($counter > 1) { $json .= ","; } $json .= json_encode($item1); $counter++; } //$json .= ' ],'; $json .= '], "keyword2": ['; foreach ($items2 as $item2) { if ($counter > 1) { $json .= ","; } $json .= json_encode($item2); $counter++; } $json .= ' ]'; // //$json .= "}"; //Horrible Hack :-( $json = str_replace(": [,", ": [", $json); $json .= '} ]'; //print json; echo $this->getWrapper($json); } //close the database connection $this->db = NULL; } catch (PDOException $ex) { print "Exception: " . $ex->getMessage(); } }
/** * constructor */ public function __construct() { $html = ""; try { parent::__construct(); if (isset($this->statuses)) { $items = $this->getData(); if ($items) { foreach ($items as $item) { $html .= $this->getHTML($item); } } //print html echo $this->getHTMLWrapper($html); } //close the database connection $this->db = NULL; } catch (PDOException $ex) { print "Exception: " . $ex->getMessage(); } }
/** * constructor */ public function __construct() { $xml = ""; try { parent::__construct(); if (isset($this->statuses)) { $items = $this->getData(); if ($items) { foreach ($items as $item) { $xml .= $this->getXML($item); } } } //set xml header header('Content-type: application/xml'); //print xml ob_clean(); echo trim($this->getWrapper($xml)); //close the database connection $this->db = NULL; } catch (PDOException $ex) { print "Exception: " . $ex->getMessage(); } }