Exemple #1
0
 public function __construct()
 {
     require APPLICATION . 'config.php';
     foreach ($CONFIG as $key => $val) {
         $this->{$key} = Library_tools::array_to_object($val);
     }
 }
Exemple #2
0
 /**
  * ID: Kirimkan pesan error ke halaman error template
  * EN: Send error message to error template file
  *
  * @param string $file
  */
 public function error_template_view($data = array())
 {
     $defaults = array('error_code' => 404, 'header_page_title' => 'Page Not Found - Error 404', 'template_file' => '40x', 'content' => '<h1>Error: Page not Found!</h1>');
     $data = array_merge($defaults, $data);
     extract($data, EXTR_SKIP);
     Library_tools::set_status_header($error_code);
     $path = APPLICATION . 'view/error_templates/' . $template_file . '.php';
     include_once $path;
     exit;
 }
Exemple #3
0
 /**
  * EN: Wrap results from mongo output into object or array.
  *
  * @param array $cursor The array data given from Mongodb
  * @param string $output The output type: object | array
  * @return boolean | object | array
  */
 public function cursor_results($cursor, $output = 'object')
 {
     if (!$cursor) {
         return false;
     }
     /**
      * ID: Jika outputnya ingin berbentuk array, maka
      *      lakukan proses di bawah. Jika tidak abaikan.
      */
     if ($output == 'array') {
         foreach ($cursor as $value) {
             $return[] = $value;
         }
         return $return;
     }
     foreach ($cursor as $value) {
         $return[] = (object) Library_tools::array_to_object($value);
     }
     return $return;
 }
Exemple #4
0
 public function wrap_response_output($data, $format = 'json')
 {
     header('Content-type: text/' . $format);
     if ($format == 'xml') {
         return Library_tools::xml_encode($data);
     } else {
         return json_encode($data);
     }
 }
Exemple #5
0
 /**
  * Get single record
  *
  * @param string $query The sql query
  * @param string $type return data type option. the default is "object"
  */
 public function row($query = null, $type = 'object')
 {
     if (is_null($query)) {
         $query = $this->_command();
     }
     if (is_null($this->link)) {
         $this->init();
     }
     $result = $this->query($query);
     $return = $result->fetchArray(SQLITE3_ASSOC);
     if ($type == 'object') {
         if ($this->instantiate_class == 'stdClass') {
             return (object) $return;
         } else {
             return Library_tools::array_to_object($return, $this->instantiate_class, false);
         }
     } else {
         return $return;
     }
 }