当前位置: 首页>>代码示例>>PHP>>正文


PHP db::build方法代码示例

本文整理汇总了PHP中db::build方法的典型用法代码示例。如果您正苦于以下问题:PHP db::build方法的具体用法?PHP db::build怎么用?PHP db::build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在db的用法示例。


在下文中一共展示了db::build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     // Set up a new admin page for the quotas module.
     $view = new Admin_View("admin.html");
     $view->page_title = t("Users and groups");
     $view->page_type = "collection";
     $view->page_subtype = "admin_users_quotas";
     $view->content = new View("admin_quotas.html");
     $page_size = module::get_var("user", "page_size", 10);
     $page = Input::instance()->get("page", "1");
     $builder = db::build();
     $user_count = $builder->from("users")->count_records();
     $view->page = $page;
     $view->page_size = $page_size;
     $view->children_count = $user_count;
     $view->max_pages = ceil($view->children_count / $view->page_size);
     $view->content->pager = new Pagination();
     $view->content->pager->initialize(array("query_string" => "page", "total_items" => $user_count, "items_per_page" => $page_size, "style" => "classic"));
     if ($page < 1) {
         url::redirect(url::merge(array("page" => 1)));
     } else {
         if ($page > $view->content->pager->total_pages) {
             url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
         }
     }
     $view->content->users = ORM::factory("user")->order_by("users.name", "ASC")->find_all($page_size, $view->content->pager->sql_offset);
     $view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
     $view->content->quota_options = $this->_get_quota_settings_form();
     print $view;
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:30,代码来源:admin_quotas.php

示例2: index

 public function index()
 {
     $view = new Admin_View("admin.html");
     $view->page_title = t("Users and groups");
     $view->page_type = "collection";
     $view->page_subtype = "admin_users";
     $view->content = new View("admin_users.html");
     // @todo: add this as a config option
     $page_size = module::get_var("user", "page_size", 10);
     $page = Input::instance()->get("page", "1");
     $builder = db::build();
     $user_count = $builder->from("users")->count_records();
     // Pagination info
     $view->page = $page;
     $view->page_size = $page_size;
     $view->children_count = $user_count;
     $view->max_pages = ceil($view->children_count / $view->page_size);
     $view->content->pager = new Pagination();
     $view->content->pager->initialize(array("query_string" => "page", "total_items" => $user_count, "items_per_page" => $page_size, "style" => "classic"));
     // Make sure that the page references a valid offset
     if ($page < 1) {
         url::redirect(url::merge(array("page" => 1)));
     } else {
         if ($page > $view->content->pager->total_pages) {
             url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
         }
     }
     // Join our users against the items table so that we can get a count of their items
     // in the same query.
     $view->content->users = ORM::factory("user")->order_by("users.name", "ASC")->find_all($page_size, $view->content->pager->sql_offset);
     $view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
     print $view;
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:33,代码来源:admin_users.php

示例3: identity_provider_changed

 static function identity_provider_changed($old_provider, $new_provider)
 {
     $admin = identity::admin_user();
     db::build()->update("tasks")->set("owner_id", $admin->id)->execute();
     db::build()->update("items")->set("owner_id", $admin->id)->execute();
     db::build()->update("logs")->set("user_id", $admin->id)->execute();
 }
开发者ID:andyst,项目名称:gallery3,代码行数:7,代码来源:gallery_event.php

示例4: stats

 static function stats()
 {
     $remaining = db::build()->from("items")->join("search_records", "items.id", "search_records.item_id", "left")->and_open()->where("search_records.item_id", "IS", null)->or_where("search_records.dirty", "=", 1)->close()->count_records();
     $total = ORM::factory("item")->count_all();
     $percent = round(100 * ($total - $remaining) / $total);
     return array($remaining, $total, $percent);
 }
开发者ID:viosca,项目名称:gallery3,代码行数:7,代码来源:search.php

示例5: available_tasks

 static function available_tasks()
 {
     // Delete extra exif_records
     db::build()->delete("exif_records")->where("item_id", "NOT IN", db::build()->select("id")->from("items")->where("type", "=", "photo"))->execute();
     list($remaining, $total, $percent) = exif::stats();
     return array(Task_Definition::factory()->callback("exif_task::update_index")->name(t("Extract Exif data"))->description($remaining ? t2("1 photo needs to be scanned", "%count (%percent%) of your photos need to be scanned", $remaining, array("percent" => 100 - $percent)) : t("Exif data is up-to-date"))->severity($remaining ? log::WARNING : log::SUCCESS));
 }
开发者ID:andyst,项目名称:gallery3,代码行数:7,代码来源:exif_task.php

示例6: fix_internet_addresses

 static function fix_internet_addresses($task)
 {
     $start = microtime(true);
     $total = $task->get("total");
     if (empty($total)) {
         $task->set("total", $total = db::build()->count_records("items"));
         $task->set("last_id", 0);
         $task->set("completed", 0);
     }
     $last_id = $task->get("last_id");
     $completed = $task->get("completed");
     foreach (ORM::factory("item")->where("id", ">", $last_id)->find_all(100) as $item) {
         $item->slug = item::convert_filename_to_slug($item->slug);
         $item->save();
         $last_id = $item->id;
         $completed++;
         if ($completed == $total || microtime(true) - $start > 1.5) {
             break;
         }
     }
     $task->set("completed", $completed);
     $task->set("last_id", $last_id);
     if ($total == $completed) {
         $task->done = true;
         $task->state = "success";
         $task->percent_complete = 100;
         db::build()->update("items")->set("relative_path_cache", null)->set("relative_url_cache", null)->execute();
     } else {
         $task->percent_complete = round(100 * $completed / $total);
     }
     $task->status = t2("One row updated", "%count / %total rows updated", $completed, array("total" => $total));
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:32,代码来源:rescue_task.php

示例7: get_uas_and_ips

 private function get_uas_and_ips()
 {
     $uas = array();
     $ips = array();
     $sample_size = 0;
     $d = new Session_Database_Driver();
     foreach (db::build()->select("session_id")->from("sessions")->execute() as $r) {
         $data = $this->unserialize_session($d->read($r->session_id));
         $ua = $data["user_agent"];
         $ip = $data["ip_address"];
         if (!isset($uas[$ua])) {
             $uas[$ua] = 0;
         }
         if (!isset($ips[$ip])) {
             $ips[$ip] = 0;
         }
         $uas[$ua]++;
         $ips[$ip]++;
         // Limit the sample size once we've found N user agents
         if (++$sample_size == 5000) {
             break;
         }
     }
     arsort($uas);
     arsort($ips);
     // Top N only
     array_splice($uas, 15);
     array_splice($ips, 15);
     return array($uas, $ips, $sample_size);
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:30,代码来源:admin_session_explorer.php

示例8: rearrange

 function rearrange($target_id, $before_or_after)
 {
     access::verify_csrf();
     $target = ORM::factory("item", $target_id);
     $album = $target->parent();
     access::required("view", $album);
     access::required("edit", $album);
     $source_ids = Input::instance()->post("source_ids", array());
     if ($album->sort_column != "weight") {
         $i = 0;
         foreach ($album->children() as $child) {
             // Do this directly in the database to avoid sending notifications
             db::build()->update("items")->set("weight", ++$i)->where("id", "=", $child->id)->execute();
         }
         $album->sort_column = "weight";
         $album->sort_order = "ASC";
         $album->save();
         $target->reload();
     }
     // Find the insertion point
     $target_weight = $target->weight;
     if ($before_or_after == "after") {
         $target_weight++;
     }
     // Make a hole
     $count = count($source_ids);
     db::build()->update("items")->set("weight", new Database_Expression("`weight` + {$count}"))->where("weight", ">=", $target_weight)->where("parent_id", "=", $album->id)->execute();
     // Insert source items into the hole
     foreach ($source_ids as $source_id) {
         db::build()->update("items")->set("weight", $target_weight++)->where("id", "=", $source_id)->execute();
     }
     module::event("album_rearrange", $album);
     print json_encode(array("grid" => self::_get_micro_thumb_grid($album, 0)->__toString(), "sort_column" => $album->sort_column, "sort_order" => $album->sort_order));
 }
开发者ID:viosca,项目名称:gallery3,代码行数:34,代码来源:organize.php

示例9: _dump_database

 private function _dump_database()
 {
     // We now have a clean install with just the packages that we want.  Make sure that the
     // database is clean too.
     $i = 1;
     foreach (array("dashboard_sidebar", "dashboard_center", "site_sidebar") as $key) {
         $blocks = array();
         foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) {
             $blocks[++$i] = $value;
         }
         module::set_var("gallery", "blocks_{$key}", serialize($blocks));
     }
     Database::instance()->query("TRUNCATE {caches}");
     Database::instance()->query("TRUNCATE {sessions}");
     Database::instance()->query("TRUNCATE {logs}");
     db::build()->update("users")->set(array("password" => ""))->where("id", "in", array(1, 2))->execute();
     $dbconfig = Kohana::config('database.default');
     $conn = $dbconfig["connection"];
     $sql_file = DOCROOT . "installer/install.sql";
     if (!is_writable($sql_file)) {
         print "{$sql_file} is not writeable";
         return;
     }
     $command = sprintf("mysqldump --compact --skip-extended-insert --add-drop-table %s %s %s %s > {$sql_file}", escapeshellarg("-h{$conn['host']}"), escapeshellarg("-u{$conn['user']}"), $conn['pass'] ? escapeshellarg("-p{$conn['pass']}") : "", escapeshellarg($conn['database']));
     exec($command, $output, $status);
     if ($status) {
         print "<pre>";
         print "{$command}\n";
         print "Failed to dump database\n";
         print implode("\n", $output);
         return;
     }
     // Post-process the sql file
     $buf = "";
     $root = ORM::factory("item", 1);
     $root_created_timestamp = $root->created;
     $root_updated_timestamp = $root->updated;
     $table_name = "";
     foreach (file($sql_file) as $line) {
         // Prefix tables
         $line = preg_replace("/(CREATE TABLE|IF EXISTS|INSERT INTO) `{$dbconfig['table_prefix']}(\\w+)`/", "\\1 {\\2}", $line);
         if (preg_match("/CREATE TABLE {(\\w+)}/", $line, $matches)) {
             $table_name = $matches[1];
         }
         // Normalize dates
         $line = preg_replace("/,{$root_created_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         $line = preg_replace("/,{$root_updated_timestamp},/", ",UNIX_TIMESTAMP(),", $line);
         // Remove ENGINE= specifications execpt for search records, it always needs to be MyISAM
         if ($table_name != "search_records") {
             $line = preg_replace("/ENGINE=\\S+ /", "", $line);
         }
         // Null out ids in the vars table since it's an auto_increment table and this will result in
         // more stable values so we'll have less churn in install.sql.
         $line = preg_replace("/^INSERT INTO {vars} VALUES \\(\\d+/", "INSERT INTO {vars} VALUES (NULL", $line);
         $buf .= $line;
     }
     $fd = fopen($sql_file, "wb");
     fwrite($fd, $buf);
     fclose($fd);
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:60,代码来源:packager.php

示例10: update

 public function update()
 {
     //Get the ordered list of modules
     $modulerawlist = explode("&", trim($_POST['modulelist'], "&"));
     //Make sure that gallery and user modules are first in the list
     $current_weight = 2;
     $identity_provider = module::get_var("gallery", "identity_provider");
     foreach ($modulerawlist as $row) {
         $currentry = explode("=", $row);
         $currentry = explode(":", $currentry[1]);
         if ($currentry[0] == "gallery") {
             $modulelist[0] = $row;
         } elseif ($currentry[0] == $identity_provider) {
             $modulelist[1] = $row;
         } else {
             $modulelist[$current_weight] = $row;
             $current_weight++;
         }
     }
     ksort($modulelist);
     //Write the correct weight values
     $current_weight = 0;
     foreach ($modulelist as $row) {
         $current_weight++;
         $currentry = explode("=", $row);
         $currentry = explode(":", $currentry[1]);
         db::build()->update("modules")->set("weight", $current_weight)->where("id", "=", $currentry[1])->execute();
     }
     message::success(t("Your settings have been saved."));
     url::redirect("admin/moduleorder");
     print $this->_get_view();
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:32,代码来源:admin_moduleorder.php

示例11: _get_modules

 private static function _get_modules()
 {
     $modules = array();
     foreach (db::build()->select("*")->from("modules")->order_by("weight")->execute() as $row) {
         $modules["{$row->name}:{$row->id}"] = $row->name;
     }
     return $modules;
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:8,代码来源:moduleorder.php

示例12: item_deleted

 static function item_deleted($item)
 {
     // If an album is deleted, remove any associated passwords.
     $existingPasswords = ORM::factory("items_albumpassword")->where("album_id", "=", $item->id)->find_all();
     if (count($existingPasswords) > 0) {
         db::build()->delete("items_albumpassword")->where("album_id", "=", $item->id)->execute();
     }
 }
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:8,代码来源:albumpassword_event.php

示例13: available_tasks

 static function available_tasks()
 {
     // Automatically delete extra exif_coordinates whenever the maintance screen is loaded.
     db::build()->delete("exif_coordinates")->where("item_id", "NOT IN", db::build()->select("id")->from("items"))->execute();
     // Display an option on the maintance screen for scanning existing photos
     // for GPS data (in case photos were uploaded before the module was active).
     return array(Task_Definition::factory()->callback("exif_gps_task::update_gps_index")->name(t("Extract Exif GPS data"))->description(t("Scan all photos for missing GPS data"))->severity(log::SUCCESS));
 }
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:8,代码来源:exif_gps_task.php

示例14: _remove_tag

 private function _remove_tag($tag, $delete)
 {
     $name = $tag->name;
     db::build()->delete("items_tags")->where("tag_id", "=", $tag->id)->execute();
     if ($delete) {
         $tag->delete();
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:8,代码来源:admin_photoannotation.php

示例15: user_before_delete

 static function user_before_delete($user)
 {
     try {
         db::build()->delete("subscriptions")->where("user_id", "=", $user->id)->execute();
     } catch (Exception $e) {
         Kohana_Log::add("error", "@todo notification_event::user_before_delete() failed");
         Kohana_Log::add("error", $e->getMessage() . "\n" . $e->getTraceAsString());
     }
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:9,代码来源:notification_event.php


注:本文中的db::build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。