예제 #1
0
파일: DB.php 프로젝트: kelvinj/Giiki
 /**
  * deletes a row from the database, unless there's an is_deleted column, in which case the flag is set to 1
  *
  * Fu_Event triggers: before_delete, after_delete
  *
  * @param array options
  * @return bool false on failure, true on success
  */
 public function delete($options = array())
 {
     $conditions = $options['conditions'];
     $id = $options['id'] ? $options['id'] : $this->id;
     if (!$id && !$conditions) {
         throw new Fu_DB_Exception('Delete failed: nothing to delete');
     }
     if ($this->field_exists('is_deleted')) {
         $sql = 'UPDATE `' . $this->_table . '` SET is_deleted=1';
         if ($this->field_exists('deleted_at')) {
             $sql .= ', deleted_at=NOW()';
         } else {
             if ($this->field_exists('deleted_on')) {
                 $sql .= ', deleted_on=NOW()';
             }
         }
         $sql .= ' WHERE 1';
     } else {
         $sql = 'DELETE FROM `' . $this->_table . '` WHERE 1';
     }
     if (is_numeric($id)) {
         $sql .= ' AND id=?';
         $sql_params = array($id);
     }
     if ($conditions) {
         list($clean_sql, $clean_params) = $this->_clean_conditions($conditions);
         $sql .= " AND {$clean_sql}";
         $sql_params = array_merge((array) $sql_params, $clean_params);
     }
     $this->_event->trigger('before_delete');
     $st = $this->_dbh->prepare($sql);
     $result = $st->execute($sql_params);
     Fu_DB_Debug::debug($sql, $sql_params);
     $this->_event->trigger('after_delete');
     return $result;
 }
예제 #2
0
파일: functions.php 프로젝트: kelvinj/Giiki
function app_debug()
{
    $dbg = Fu_DB_Debug::debug();
    if ($dbg) {
        var_dump($dbg);
    }
}