public function doUpgrade() { $sql = "ALTER TABLE " . Database::$prefix . "photos CHANGE modified modified VARCHAR(255);"; $result = Database::run($sql); $sql = "UPDATE " . Database::$prefix . "photos SET modified = NULL where modified = 0;"; $result = Database::run($sql); return true; }
public function doUpgrade() { $sql = "ALTER TABLE " . Database::$prefix . "users MODIFY COLUMN password varchar(255) NOT NULL;"; $result = Database::run($sql); $sql = "ALTER TABLE " . Database::$prefix . "users ADD COLUMN id INT(10) NOT NULL AUTO_INCREMENT UNIQUE FIRST;"; $result = Database::run($sql); return true; }
/** * Reset the sequence values. */ protected function databaseFinalPgsql() { /** * 'table' +> 'primary_key_column' */ $map = ['airship_auth_tokens' => 'tokenid', 'airship_custom_dir' => 'directoryid', 'airship_custom_page' => 'pageid', 'airship_custom_page_version' => 'versionid', 'airship_custom_redirect' => 'redirectid', 'airship_dirs' => 'directoryid', 'airship_files' => 'fileid', 'airship_groups' => 'groupid', 'airship_perm_actions' => 'actionid', 'airship_perm_contexts' => 'contextid', 'airship_perm_rules' => 'ruleid', 'airship_users' => 'userid', 'airship_user_preferences' => 'preferenceid', 'hull_blog_authors' => 'authorid', 'hull_blog_author_photos' => 'photoid', 'hull_blog_categories' => 'categoryid', 'hull_blog_comments' => 'commentid', 'hull_blog_comment_versions' => 'versionid', 'hull_blog_tags' => 'tagid', 'hull_blog_posts' => 'postid', 'hull_blog_post_versions' => 'versionid', 'hull_blog_series' => 'seriesid', 'hull_blog_series_items' => 'itemid']; foreach ($map as $table => $primary_key_name) { $this->db->run("SELECT setval(\n '" . $table . "_" . $primary_key_name . "_seq',\n COALESCE(\n (\n SELECT MAX(" . $primary_key_name . ") + 1 FROM " . $table . "\n ),\n 1\n ),\n FALSE\n );"); } }
public function doUpgrade() { $sql = "ALTER TABLE " . Database::$prefix . "photos ADD UNIQUE INDEX (filename, path);"; $result = Database::run($sql); $sql = "UPDATE " . Database::$prefix . "photos SET path = mid(path,2) WHERE path LIKE '/%';"; $result = Database::run($sql); $sql = "UPDATE " . Database::$prefix . "photos SET path = mid(path,1,length(path)-1) WHERE path LIKE '%/';"; $result = Database::run($sql); $sql = "UPDATE " . Database::$prefix . "photos SET path = concat('/',path);"; $result = Database::run($sql); return true; }
public function getUser(string $username = null) : array { if (!$this->user) { if (!$username) { throw new \RuntimeException('No user was authenticated yet, the username parameter is mandatory'); } // IDEA separate into AuthDao / UsersDao, both to clean things up // and to show an example of how to work with a child of Dao $data = Database::run('SELECT id, username, email, password FROM users WHERE username = ?', [$username], [Col::INT()]); if (!$data) { return $res->build(HttpStatus::NotFound, [], ['title' => 'User not found', 'detail' => 'No user exists with the provided username']); } $this->user = $data[0]; } return $this->user; }
function nova_cotacao_pedido($tipo) { $db = new Database($this); if (!$db->conexao) { return; } switch ($tipo) { case 'cc': $sql = ' SP_Cotacao_Compra_Inc '; break; case 'cv': $sql = ' SP_Cotacao_Venda_Inc '; break; case 'pc': $sql = ' SP_Pedido_Compra_Inc '; break; case 'pv': $sql = ' SP_Pedido_Venda_Inc '; break; default: return; break; } $data = ' call ' . $sql . '(' . String($GLOBALS['CodFilial']) . ',' . String($this->CodCliFor) . ',' . String($GLOBALS['CodUsuario']) . ');'; if (!$db->run('sistema', $data)) { return; } // pega ID if (!($linha = $db->line())) { return; } return $linha['CodId']; }
public function doUpgrade() { $sql = "ALTER TABLE " . Database::$prefix . "logs DROP COLUMN value_old;"; $result = Database::run($sql); return true; }