Example #1
0
 public static function val($sid)
 {
     $cache = Z_Cache::getInstance();
     $model = new Z_Model_Config();
     if (!($data = $cache->load('kap_config'))) {
         $data = $model->fetchPairs(array('sid', 'value'));
         $cache->save($data, 'kap_config');
     }
     if (isset($data[$sid])) {
         return $data[$sid];
     } else {
         return '';
     }
 }
Example #2
0
 public function mysqlData($name, $type)
 {
     $model = new Z_Model_Config();
     $db = $model->getAdapter();
     $dumpData = "\n\n";
     if ($type != "VIEW") {
         // backup tables
         $tableData = $db->fetchAll("SELECT * FROM `" . $name . "`");
         foreach ($tableData as $row) {
             $cells = array();
             foreach ($row as $cell) {
                 $cells[] = $db->quote($cell);
             }
             $dumpData .= "INSERT INTO `" . $name . "` VALUES (" . implode(",", $cells) . ");";
             $dumpData .= "\n";
         }
     } else {
         // dump view structure
         $dumpData .= "\n\n";
         $dumpData .= "DROP VIEW IF EXISTS `" . $name . "`;";
         $dumpData .= "\n";
         try {
             $viewData = $db->fetchRow("SHOW CREATE VIEW `" . $name . "`");
             $dumpData .= $viewData["Create View"] . ";";
         } catch (Exception $e) {
         }
     }
     $dumpData .= "\n\n";
     $backup_dir = $this->getBackupDir();
     $h = fopen($backup_dir . "/backup-dump.sql", "a+");
     fwrite($h, $dumpData);
     fclose($h);
     return array("success" => true);
 }