/**
  * Reads all titles into the static property, $all
  */
 public static function load_all_from_db()
 {
     Title::$all = array();
     $db = DB::get_db();
     $rows = DB::fetchall(sprintf("SELECT * FROM titles ORDER BY LOWER(title)"));
     foreach ($rows as $row) {
         $title = Title::from_row($row);
         array_push(Title::$all, $title);
     }
 }
 public static function all()
 {
     $db = DB::get_db();
     $users = array();
     $rows = DB::fetchall(sprintf("SELECT id, login, roles FROM users"));
     foreach ($rows as $row) {
         $users[] = new User($row["login"], $row["roles"], $row["id"]);
     }
     return $users;
 }
 /**
  * Returns textual error messages for anything which prevent this issue from
  * being queued for review
  */
 public function errors()
 {
     $err = array();
     // Missing publication
     if ($this->publication() == NULL) {
         $err[] = "unable to infer publication due to missing LCCN or bad title list";
     }
     // Missing required metadata
     if ($this->missing_metadata()) {
         $err[] = "not all metadata has been filled in";
     }
     // Dupe of an already-ingested issue
     $db = DB::get_db();
     $rows = DB::fetchall(sprintf("SELECT * FROM issues_processed WHERE issue_key = '%s'", $db->real_escape_string($this->key())));
     if (count($rows) > 0) {
         $batch_name = $rows[0]["batch_name"];
         $err[] = "an issue with the same lccn, date, and edition was ingested in '{$batch_name}'";
     }
     // Not all pages filled out
     if (count($this->meta->page_labels) < count($this->pages())) {
         $err[] = "the number of page labels doesn't match the number of pages";
     }
     foreach ($this->meta->page_labels as $label) {
         if ($label == NULL || $label == "") {
             $err[] = "not all pages have been labeled";
             break;
         }
     }
     return $err;
 }
<?php

require_once __DIR__ . "/includes/root.php";
must_allow("list audit logs");
$db = DB::get_db();
$rows = DB::fetchall(sprintf("SELECT * FROM audit_logs order by `when` desc LIMIT 1000"));
$logs = array();
foreach ($rows as $row) {
    array_push($logs, $row);
}
$renderer->variable("logs", $logs);
$renderer->variable("title", "Audit logs");
$renderer->render("audit-logs-list");
示例#5
0
/**
 * 获得数据表的序列化结构
 *
 * @param DB $db  数据库操作对象
 * @param string  $dbname 数据库名
 * @return string $result 序列后的数据表结构
 *
 */
function db_table_serialize($db, $dbname)
{
    $tables = $db->fetchall('SHOW TABLES');
    if (empty($tables)) {
        return '';
    }
    $struct = array();
    foreach ($tables as $value) {
        $structs[] = db_table_schema($db, substr($value['Tables_in_' . $dbname], strpos($value['Tables_in_' . $dbname], '_') + 1));
    }
    return iserializer($structs);
}
 /**
  * Returns the MOC with the given id
  */
 public static function find($id)
 {
     $db = DB::get_db();
     $rows = DB::fetchall(sprintf("SELECT * FROM mocs WHERE id = %d", $id));
     return MOC::from_row($rows[0]);
 }