public static function delete($table, $where = array()) { $sql = "DELETE FROM {$table} WHERE " . \Meta\Core\Db::where($where); return \Meta\Core\Db::execute($sql); }
return $page; }); Page::beforeRender('frame-user-groups', function ($page) { // modify $page array here // prevent unauthorized actions if (is_demo() && isset($_REQUEST['action']) && isset($_REQUEST['id'])) { if (is_post() || $_REQUEST['action'] == 'delete') { $user_id = \Meta\Core\Db::query('SELECT user_id FROM user_groups WHERE id = ?', array($_REQUEST['id']))->fetchColumn(); if ($user_id == 1) { \Meta\Core\Flash::error(t('Sorry, but you cannot modify the Admin user in demo mode')); header("Location: " . urldecode($_GET['url_from'])); exit; } } } return $page; }); Page::beforeRender('manage-files', function ($page) { // scan all files. if the number is different than the table, then re populate all entirely table $files = \Meta\Core\FileSystem::listAll(); $dbCountFiles = \Meta\Core\Db::query('SELECT COUNT(*) FROM files')->fetchColumn(); if (count($files) > 0 && count($files) != $dbCountFiles) { // delete all and insert files list \Meta\Core\Db::execute('DELETE FROM files'); foreach ($files as $file) { \Meta\Core\Db::save('files', array('name' => basename($file), 'size' => filesize($file))); } \Meta\Core\Flash::info(t('The files base was been updated')); } return $page; });
<?php use Meta\Core\Db; try { Db::execute('DROP TABLE group_permissions'); } catch (Exception $e) { } try { Db::execute('ALTER TABLE sample ADD fld_file VARCHAR(255);'); Db::execute('CREATE TABLE files(id serial primary key auto_increment, name varchar(255) not null, size bigint, type varchar(255));'); } catch (Exception $e) { }