예제 #1
0
    public static function get_from_email($email)
    {
        global $g_pdo;
        $request = <<<EOF
SELECT id FROM `guest`
WHERE `email`= :email
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $pst->execute(array(":email" => $email));
        $record = $pst->fetch(PDO::FETCH_ASSOC);
        if (!isset($record['id'])) {
            return NULL;
        }
        $guest = Record::get_from_id("guest", $record['id']);
        return $guest;
    }
예제 #2
0
    public static function pop()
    {
        global $g_pdo;
        $request = <<<EOF
SELECT id FROM task
WHERE start_t < :now AND status = :status
LIMIT 1
EOF;
        debug($request);
        $pst = $g_pdo->prepare($request);
        $pst->execute(array(":now" => time(), ":status" => TASK_STATUS_PENDING));
        $record = $pst->fetch(PDO::FETCH_ASSOC);
        if (!isset($record['id'])) {
            return null;
        }
        return Record::get_from_id("task", $record['id']);
    }
예제 #3
0
 public function execute_action($action)
 {
     $record = null;
     if (isset($_GET["id"])) {
         $record = Record::get_from_id($this->name, $_GET["id"]);
     } else {
         $record = new $this->classname();
     }
     $record->{$action}();
 }
예제 #4
0
 public static function multi_action($action)
 {
     //$id_array = explode("_", $_GET["ids"]);
     $id_array = $_GET["ids"];
     foreach ($id_array as $id) {
         $record = Record::get_from_id($_GET["type"], $id);
         if ($record != null) {
             $record->{$action}();
         }
     }
 }