예제 #1
0
 public function table($table_name = null)
 {
     if (empty($table_name)) {
         $ex_res = NutrientLib::class_explode(get_class($this));
         $table = array_shift($ex_res);
         $table_name = $this->_db_prefix . lcfirst($table);
     }
     $res = parent::table($table_name);
     if (!$res) {
         trigger_error('Table name is null or no exist!', E_USER_WARNING);
     } else {
         return $table_name;
     }
 }
예제 #2
0
 public static function log($message, $show = false)
 {
     if (!empty($show)) {
         echo $message . "\n";
     } else {
         $log = sprintf("%s\t%s\n", date('Y-m-d H:i:s'), $message);
         !defined('LOG_FILE_PATH') ? define('LOG_FILE_PATH', ROOT_DIR . '/../logs/{date}.log') : '';
         if (stripos(LOG_FILE_PATH, '{date}') !== false) {
             $logfile = str_replace('{date}', date('Y_m_d'), LOG_FILE_PATH);
         } else {
             $logfile = $logfile . time();
         }
         if (!is_file($logfile)) {
             NutrientLib::mkfile($logfile);
             $logfile_h = "<?php exit(); ?>\n";
             file_put_contents($logfile, $logfile_h);
         }
         error_log($log, 3, $logfile);
     }
 }
예제 #3
0
 public function model($model_name = '')
 {
     if (class_exists($model_name)) {
         return Blood::single($model_name);
     } else {
         $ex_res = NutrientLib::class_explode(get_class($this));
         array_pop($ex_res);
         return Blood::single(implode('', $ex_res) . 'Mod');
     }
 }