Пример #1
0
 /**
  * Garbage collector for those that don't properly end 
  * a session or the session times out. 
  * 
  * It receives an integer argument for the “time to live” (TTL) 
  * value for a session. In our class method, gc, we delete any 
  * session record where the last access time is less then the 
  * current time, minus the TTL value
  * 
  * @param $ttl
  * @access public
  * @return bool
  */
 public function db_gc($ttl)
 {
     $end = time() - $ttl;
     $sql = "DELETE FROM sessions WHERE sess_last_acc < {$end}";
     $result = Pixelpost_DB::query($sql);
     //Pixelpost_DB::debug();
     // may want to consider optimizing the table at a given rate to clean up all the
     // deletes of a high traffic site - maybe use OPTIMIZE
     // Pixelpost_DB::query('OPTIMIZE sessions');
     return $result;
 }
Пример #2
0
 /**
  * @Delete a node and all its children
  * @access public
  * @param string $node_name
  */
 public function deleteNodeRecursive($node_permalink)
 {
     try {
         $sql = "SELECT left_node, right_node FROM " . $this->tablename . " \n\t\t\t\tWHERE permalink = '" . Pixelpost_DB::escape($node_permalink) . "'";
         $result = (array) Pixelpost_DB::get_results($sql);
         $result[0]->width_node = $result[0]->right_node - $result[0]->left_node + 1;
         Pixelpost_DB::query("DELETE FROM " . $this->tablename . " \n\t\t\t\tWHERE left_node BETWEEN " . $result[0]->left_node . " \n\t\t\t\tAND " . $result[0]->right_node);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " \n\t\t\t\tSET right_node = right_node - " . $result[0]->width_node . " \n\t\t\t\tWHERE right_node > " . $result[0]->right_node);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " \n\t\t\t \tSET left_node = left_node - " . $result[0]->width_node . " \n\t\t\t\t WHERE left_node > " . $result[0]->right_node);
     } catch (exception $e) {
         throw new Exception($e);
     }
 }