delete() static public method

Runs a DELETE query
static public delete ( string $table, mixed $where = '' ) : mixed
$table string The table name
$where mixed Either a key/value array as AND connected where clause or a simple MySQL where clause string
return mixed The number of affected rows or an error response
Ejemplo n.º 1
0
 public function borrar_usuario($id)
 {
     parent::__construct($this->db, $this->tabla);
     $args = array();
     $args["where"] = array("idUsuario=:id");
     $args["valores"] = array(":id" => $id);
     parent::delete($array);
 }
Ejemplo n.º 2
0
Archivo: trash.php Proyecto: rigidus/ea
 function delete($log_id)
 {
     db::table('admin_log_trash');
     db::where('log_id', $log_id);
     db::delete();
     @unlink(SYS_ROOT . 'var/trash/' . $log_id . '_conf.zip');
     @unlink(SYS_ROOT . 'var/trash/' . $log_id . '_base.zip');
     @unlink(SYS_ROOT . 'var/trash/' . $log_id . '_files.zip');
 }
Ejemplo n.º 3
0
function remove_note($id)
{
    $db = new db();
    $result = $db->read("notes", "id = :id", array(":id" => $id), "super_note");
    if (!$result || $result[0]['super_note']) {
        return false;
    }
    $result = $db->delete("notes", "id = :id", array(":id" => $id));
    return $result;
}
Ejemplo n.º 4
0
 function delete($id)
 {
     $db = new db("components");
     $all = $db->convert($db->all());
     foreach ($all as $a) {
         if ($a['id'] == $id) {
             $db->delete($a['title']);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 5
0
 public function delete()
 {
     error_log(__METHOD__);
     if ($this->g->in['i']) {
         $res = db::delete([['id', '=', $this->g->in['i']]]);
         $this->g->in['i'] = 0;
         header("Location: ?o=" . $this->o);
         exit;
     } else {
         return 'Error with Delete';
     }
 }
Ejemplo n.º 6
0
 function delete()
 {
     $img_id = params::get('img_id');
     db::table('images');
     db::where('img_id', $img_id);
     db::delete();
     $dir = IMAGES_ROOT . 'index/';
     $file = $dir . $img_id . '.jpg';
     $file_m = $dir . $img_id . '_m.jpg';
     @unlink($file);
     @unlink($file_m);
 }
Ejemplo n.º 7
0
 function delete($block_id = false, $dump = true)
 {
     if (!$block_id) {
         $block_id = params::get('block_id');
     }
     if ($dump) {
         trash::tables('blocks');
         trash::conf('blocks');
         trash::dump();
     }
     db::table('blocks');
     db::where('block_id', $block_id);
     db::delete();
     conf::delete('blocks', $block_id);
 }
Ejemplo n.º 8
0
 function saveVersion($tmpl_id, $code)
 {
     db::table('templates_versions');
     db::where('tmpl_id', $tmpl_id);
     db::where('version_code', $code);
     db::order('version_date', 'DESC');
     db::limit(1);
     db::select();
     if (db::rows() == 0) {
         /*
         	delete over 20
         */
         db::table('templates_versions');
         db::where('tmpl_id', $tmpl_id);
         db::order('version_date', 'DESC');
         db::limit(20, 100);
         db::delete();
         db::table('templates_versions');
         db::insert('', 'NOW()', $code, '', '', $tmpl_id, ADMIN_USER_ID, ADMIN_SITE_ID);
     }
 }
Ejemplo n.º 9
0
Archivo: test.php Proyecto: rlm80/Glue
 private function test_queries()
 {
     // Test insert :
     $query = db::insert('glusers')->columns('login', 'password')->values('test1', 'test1')->values('test2', 'test2')->values('test3', 'test3');
     db::cn()->exec($query);
     // Test prepared insert :
     $query = db::insert('glprofiles')->columns('id', 'email')->values(null, 'test1')->values(null, 'test2')->values(null, 'test3');
     $stmt = db::cn()->prepare($query);
     $stmt->execute();
     // Test update :
     $query = db::update('glusers', $u)->set('password', db::select('glprofiles')->columns("count(*)"))->where("{$u->login} = ?", 'test2');
     db::cn()->exec($query);
     // Test Delete :
     $query = db::delete('glprofiles', $u)->where("{$u->id} = ?", 3);
     db::cn()->exec($query);
     // Test Select :
     $query = db::select('glusers', $a)->left('glusers', $b)->on("{$a->id} = {$b->id}")->where("{$a->login} LIKE ?", 'test%')->columns($a->id, $a->login, $b->id, $b->login)->where("{$a->id} = ?", 3)->groupby($a->id, $a->login, $b->id, $b->login)->orderby($a->id, $a->login, $b->id, $b->login)->limit(1)->offset(0);
     $stmt = db::cn()->query($query);
     $query = db::delete('users', $u)->where("NOT EXISTS ( ? )", $sub = db::select());
     $sub->from('posts', $ps)->where("{$ps->user_id} = {$u->id}");
     echo db::cn()->compile($query);
     /*foreach($stmt as $row) {
     			var_dump($row);
     			var_dump($a->id($row));
     		}*/
     /*
     		$query = db::select('glusers', $u)->columns($u->id, $u->login, $u->password);
     		$statement = db::cn()->prepare($query);
     		$statement->execute();
     		while($res = $statement->fetch(PDO::FETCH_BOTH)) {
     			//var_dump($u['login']);
     			var_dump($res);
     			echo $test;
     		}*/
     /*
     $stmt = db::cn()->query("select login as login from glusers");
     //$stmt->bindColumn('login', $test);
     $stmt->setFetchMode(PDO::FETCH_BOTH);
     while($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
     	print_r($res);
     	//echo $test;
     }
     */
     //$arr = $statement->fetchAll();
     //print_r($arr);
 }
Ejemplo n.º 10
0
 function deletePoint($point_id = false)
 {
     if (!$point_id) {
         $point_id = params::get('point_id');
     }
     db::table('menus_points');
     db::where('point_id', $point_id);
     db::delete();
 }
Ejemplo n.º 11
0
 function deletesection()
 {
     $section_id = params::get('section_id');
     db::table('info_sections');
     db::where('section_id', $section_id);
     db::delete();
     db::table('info_items');
     db::where('section_id', $section_id);
     db::delete();
 }
Ejemplo n.º 12
0
 function delete($KID)
 {
     $abfrage = new db();
     $abfrage->delete("kategorie", "KID='{$KID}'");
 }
Ejemplo n.º 13
0
 /**
  * Deletes the current object's associated database row.
  * The object will still contain valid data until it is destroyed.
  *
  * @return integer
  */
 public function delete()
 {
     if (AutoModeler::STATE_LOADED) {
         $this->_state = AutoModeler::STATE_DELETED;
         return db::delete($this->_table_name)->where($this->_primary_key, '=', $this->_data[$this->_primary_key])->execute($this->_db);
     }
     throw new AutoModeler_Exception('Cannot delete a non-loaded model ' . get_class($this) . '!', array(), array());
 }
Ejemplo n.º 14
0
$op = $_POST['operation'];
$db = new db();
if ($op == "edit") {
    $id = $_POST['id'];
    $title = $_POST['title'];
    $text = $_POST['text'];
    if ($db->update("content", "title='" . $title . "', content='" . $text . "'", " id = '" . $id . "'")) {
        echo '0';
    } else {
        echo '1';
    }
} elseif ($op == "add") {
    $title = $_POST['title'];
    $text = $_POST['text'];
    $col[] = "title";
    $col[] = "content";
    $var[] = $title;
    $var[] = $text;
    //db::setDebug(2);
    if ($db->insert("content", $col, $var)) {
        if ($db->insert("navigation_links", array("link", "type", "content_id", "titel", "tpl"), array("content", "1", $db->getLastId(), $title, "1"))) {
            echo '0';
        }
    } else {
        echo '1';
    }
} elseif ($op == "delete") {
    $id = $_POST['id'];
    $db->delete("content", "id = '" . $id . "'");
    $db->delete("navigation_links", "content_id = '" . $id . "'");
}
Ejemplo n.º 15
0
    $var[] = $link;
    $var[] = $position;
    $var[] = $parent;
    $var[] = $admin;
    $var[] = $visible;
    //db::setDebug(2);
    if ($db->insert("navigation", $col, $var)) {
        echo '0';
    } else {
        echo '1';
    }
} elseif ($op == "edit") {
    $id = $_POST['id'];
    $name = $_POST['name'];
    $link = $_POST['link'];
    $position = $_POST['position'];
    $parent = $_POST['parent'];
    $admin = $_POST['admin'];
    $visible = $_POST['visible'];
    if ($admin == "") {
        $admin = 0;
    }
    if ($db->update("navigation", "name='" . $name . "', link_id='" . $link . "', position='" . $position . "', parent='" . $parent . "',admin='" . $admin . "',visible='" . $visible . "'", " id = '" . $id . "'")) {
        echo '0';
    } else {
        echo '1';
    }
} elseif ($op == "delete") {
    $id = $_POST['id'];
    $db->delete("navigation", "id = '" . $id . "'");
}
Ejemplo n.º 16
0
 public function delete_post($id)
 {
     return $query = db::delete('posts')->where('id', '=', array($id))->execute();
 }
Ejemplo n.º 17
0
 /**
  * Delete all objects in the associated table. This does NOT destroy
  * relationships that have been created with other objects.
  *
  * @chainable
  * @param   array  ids to delete
  * @return  ORM
  */
 public function delete_all($ids = NULL)
 {
     if (is_array($ids)) {
         // Delete only given ids
         db::delete($this->table_name)->where($this->primary_key, 'IN', $ids)->execute($this->db);
     } elseif ($ids === NULL) {
         // Delete all records
         db::delete($this->table_name)->execute($this->db);
     } else {
         // Do nothing - safeguard
         return $this;
     }
     // Clear the per-request database cache
     $this->db->clear_cache(NULL, Database::PER_REQUEST);
     return $this->clear();
 }
Ejemplo n.º 18
0
 public function testAffected()
 {
     db::delete('users');
     $this->assertEquals(3, db::affected());
 }
Ejemplo n.º 19
0
 /**
  * Removes a parent relationship of a belongs_to
  *
  * @param string $key the model name to look for in plural form, without Model_ prefix
  *
  * @return integer
  */
 public function remove_parent($key)
 {
     return db::delete(AutoModeler::factory(inflector::singular($key))->get_table_name() . '_' . $this->_table_name)->where(inflector::singular($this->_table_name) . '_id', '=', $this->id)->execute($this->_db);
 }
Ejemplo n.º 20
0
     if (isset($_GET['delete'])) {
         $db->delete($_GET['delete']);
     }
     $render->render("admin.variables", ["system" => $config->system, "variables" => $db->all()]);
 });
 //Extensions
 $route->respond("/extensions", function ($request, $response, $service, $app) {
     $app->isUser;
     $render = new render();
     $config = new config();
     $db = new db("extensions");
     if (isset($request->title) && isset($request->filename) && strpos($request->filename, '.php') !== FALSE) {
         $db->set($request->title, $request->filename);
     }
     if (isset($_GET['delete'])) {
         $db->delete($_GET['delete']);
     }
     $render->render("admin.extensions", ["system" => $config->system, "extensions" => $db->all()]);
 });
 //Extension
 $route->respond("/extension/[:extension]", function ($request, $response, $service, $app) {
     $app->isUser;
     if (!isset($request->extension) || !file_exists("app/resources/backend/extensions/" . $request->extension . ".twig")) {
         $response->redirect(BACKEND . "/pages");
         return;
     }
     $ext = $request->extension;
     $render = new render();
     $config = new config();
     $db = new db("extensions");
     $render->render("../extensions/{$ext}", ["system" => $config->system, "extensions" => $db->all()]);
Ejemplo n.º 21
0
 public function gc($maxlifetime)
 {
     // Delete all expired sessions
     $query = db::delete($this->table)->where('last_activity', '<', time() - $maxlifetime)->execute($this->db);
     Kohana_Log::add('debug', 'Session garbage collected: ' . $query->count() . ' row(s) deleted.');
     return TRUE;
 }
Ejemplo n.º 22
0
    } else {
        if (strlen($_POST['code']) != 9 or is_numeric($_POST['code']) === false) {
            $errors[] = $lang[$p]['error_invalid_code'];
        }
    }
    if (count($errors) > 0) {
        foreach ($errors as $error) {
            echo baltsms::alert($error, "danger");
        }
    } else {
        $baltsms = new baltsms();
        $baltsms->setPrice($_POST['price']);
        $baltsms->setCode($_POST['code']);
        $baltsms->sendRequest();
        if ($baltsms->getResponse() === true) {
            $db->delete("DELETE FROM `bans` WHERE `name` = '" . $_POST['nickname'] . "'");
            echo baltsms::alert($lang[$p]['money_purchased'], "success");
            ?>
			<script type="text/javascript">
				setTimeout(function(){
					loadPlugin('<?php 
            echo $p;
            ?>
');
				}, 3000);
			</script>
			<?php 
        } else {
            echo $baltsms->getResponse();
        }
    }
Ejemplo n.º 23
0
 public function _deleteById($id)
 {
     return db::delete(':table:')->where('id = %i', $id)->execute();
 }
Ejemplo n.º 24
0
 function deleteFilesFileForce($a)
 {
     $dir = FILES_ROOT . 'items/';
     $file = $dir . $a['file_id'] . $a['file_type'];
     @unlink($file);
     db::table('catalog_items_files');
     db::where('file_id', $a['file_id']);
     db::delete();
 }
Ejemplo n.º 25
0
                ?>
</td>
						</tr>
					<?php 
            }
            ?>
				<?php 
        }
        ?>
			</tbody>
		</table>
	<?php 
    }
}
/*
    Neaiztikt!!! Grupas termiņa pārbaude un attiecīga dzēšana!
    Neliela informācija: grupa tiks dzēsta no saraksta UN servera tikai un vienīgi, ja serveris būs tiešsaistē. Uz katru ielādi, tiks veikta termiņu pārbaude un ja serveris būs sasniedzams - tā tiks dzēsta gan no servera, gan no datubāzes.
*/
$purchases = $db->fetchAll("SELECT `id`, `nickname`, `server`, `mc_group`, `expires` FROM `" . $c[$p]['db']['table'] . "`");
foreach ($purchases as $purchase) {
    if ($purchase['expires'] <= time()) {
        if ($mc['rcon'][$purchase['server']]->connect() != false) {
            $removeGroup = str_replace(array("<NICKNAME>", "<GROUP>"), array($purchase['nickname'], $purchase['mc_group']), $c[$p]['commands']['removeGroup']);
            $mc['rcon'][$purchase['server']]->send_command($removeGroup);
            $db->delete("DELETE FROM `" . $c[$p]['db']['table'] . "` WHERE `id` = ?", array($purchase['id']));
        }
    }
}
/*
    Neaiztikt!!! Grupas termiņa pārbauda un attiecīga dzēšana!
*/
Ejemplo n.º 26
0
 public function deleteRelated($partial_slug)
 {
     $partial_slug = '%' . $partial_slug;
     db::delete(':table:')->where('url like %s', $partial_slug)->execute();
 }
Ejemplo n.º 27
0
 function delete()
 {
     $tmpl_file = params::get('tmpl_file');
     $app = params::get('app');
     @unlink(SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/' . $app . '/' . $tmpl_file);
     db::table('templates_versions');
     db::where('app', $app);
     db::where('tmpl_file', $tmpl_file);
     db::delete();
 }
Ejemplo n.º 28
0
 public function deleteById($id)
 {
     db::delete(':table:')->where('id = %i', $id)->execute();
     db::delete(':menu_items:')->where('menu_id = %i', $id)->execute();
 }
Ejemplo n.º 29
0
 public function gc($maxlifetime)
 {
     // Delete all expired sessions
     $query = db::delete($this->table)->where('last_activity', '<', time() - $maxlifetime)->execute($this->db);
     return TRUE;
 }
Ejemplo n.º 30
0
 function delete()
 {
     db::table('news');
     db::where('news_id', params::get('news_id'));
     db::delete();
 }