Beispiel #1
0
 public function createAction()
 {
     $entity = new Suscriptor();
     $entity->load_from_array($this->request->getParam("suscriptor"));
     $same_email = load_suscriptor_where("email = '" . $entity->email . "'");
     if ($same_email != null) {
         $this->flash->error("Dude! Chill, you're already suscribed, just relax and browse the list of repos...");
     } else {
         if (save_suscriptor($entity)) {
             $this->flash->setSuccess("Thanks for suscribing! Stay tuned!");
         } else {
             $this->flash->setError("Please enter a valid email address and try again");
         }
     }
     $this->redirect_to(home_root_path_path());
 }
Beispiel #2
0
/** 
Retrieves a list of Suscriptor
@order = Optional, can be an array of keys or just a single key to order by the results
@limit = Optional
*/
function list_suscriptor($order = null, $limit = null)
{
    global $__db_conn;
    $sql = "SELECT * FROM suscriptor";
    if ($order != null) {
        $order_str = $order;
        if (is_array($order)) {
            $order_str = implode(",", $order);
        }
        $sql .= " order by {$order_str}";
    }
    if ($limit != null) {
        $sql .= " limit {$limit}";
    }
    $result = mysql_query($sql, $__db_conn);
    $results = array();
    while ($row = mysql_fetch_assoc($result)) {
        $tmp = new Suscriptor();
        $tmp->load_from_array($row);
        $results[] = $tmp;
    }
    return $results;
}