Exemplo n.º 1
0
 public function write($data)
 {
     return @_file_put_contents($this->_path, $data);
 }
Exemplo n.º 2
0
 function dump($tables = null)
 {
     /**
      * Dumps db to a fileto a file
      * @param array $tables
      */
     //getting all the tables
     if (!$tables) {
         $rs = mysql_list_tables($this->dbname);
         while ($row = mysql_fetch_array($rs)) {
             $tables[] = $row[0];
         }
     }
     //saving records from tables
     $script = "";
     foreach ($tables as $table_name) {
         $rs = $this->query("SELECT * FROM {$table_name}");
         while ($row = mysql_fetch_assoc($rs)) {
             $fields = "";
             $values = "";
             foreach ($row as $field => $value) {
                 if ($fields != "") {
                     $fields .= ', ';
                     $values .= ', ';
                 }
                 $fields .= $field;
                 $values .= "'" . $this->normalize($value) . "'";
             }
             $script .= "INSERT INTO {$table_name} ({$fields}) VALUES ({$values});\n";
         }
     }
     //saving script
     $file_name = date("Y_m_d_H_i") . ".sql";
     _file_put_contents($file_name, $script);
 }
Exemplo n.º 3
0
 /**
  * @desc   WHAT?
  * @author
  * @since  2013-07-14 15:55:31
  * @throws 注意:无DB异常处理
  */
 function set($key, $data)
 {
     $unserialize = _file_put_contents($this->_dir($key), serialize($data));
     _status(1, VHOST . "(本机缓存)", "写入缓存");
     return $unserialize;
 }