function selectSearchSignupGadget($keyword) { // Split search line into keywords $keywords = split(" ", $keyword); // clear previous entry forms $this->removeAll(); $whereclause = "WHERE"; $isFirst = true; foreach ($keywords as $word) { if ($isFirst) { $whereclause = $whereclause . " title LIKE '%{$word}%'"; $isFirst = false; } else { // I'm not sure if AND is better than OR... $whereclause = $whereclause . " AND title LIKE '%{$word}%'"; } } $sql = "SELECT id, opens, closes, title, description, eventdate, send_confirmation, confirmation_message " . "FROM ilmo_masiinat {$whereclause} ORDER BY id DESC"; /* print_r(get_class_methods($whereclause)); print($whereclause->getDebugInfo()); die(); */ $result = $this->database->doSelectQuery($sql, array(), array()); // Adds gadgets to signupGadgets variable while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) { $singleGadget = new SignupGadget($row['id'], $row['title'], $row['description'], strtotime($row['eventdate']), strtotime($row['opens']), strtotime($row['closes']), CommonTools::sqlToBoolean($row['send_confirmation']), $row['confirmation_message']); array_push($this->signupGadgets, $singleGadget); } }
/** * Gets user's position from database */ function selectPositionFromDatabase() { $sql = "SELECT ilmo_id, id_string, confirmed FROM ilmo_users WHERE " . "ilmo_id = {$this->newSignupid} ORDER BY time"; $result = $this->database->doQuery($sql); $position = 1; $unconfirmedSignups = 0; $foundIdFromQueue = false; // Tries to find current users while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) { $this->debugger->debug("id_string: " . $row['id_string'] . ", sessionId: " . $this->sessionId, "selectPositionFromDatabase"); if ($row['id_string'] == $this->sessionId) { // User's id found! $foundIdFromQueue = true; break; } else { $position++; if (CommonTools::sqlToBoolean($row['confirmed']) == false) { $unconfirmedSignups++; } } } // Sets position if ($foundIdFromQueue) { $this->position = $position; $this->unconfirmedSignups = $unconfirmedSignups; } else { $this->position = -1; $this->unconfirmedSignups = -1; } }
function selectSignupGadgetById() { // Gets data from database $sql = "SELECT opens, closes, title, description, eventdate, password, send_confirmation, confirmation_message FROM " . "ilmo_masiinat WHERE id = {$this->id} "; $result = $this->database->doQuery($sql); $this->debugger->debug("The query selected " . $result->numRows() . " rows", "selectSignupGadgetById"); // Check that got one and only one result if ($result->numRows() == 1) { $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC); // Set values to signup gadget object $this->opens = strtotime($row['opens']); $this->closes = strtotime($row['closes']); $this->title = $row['title']; $this->description = $row['description']; $this->eventdate = strtotime($row['eventdate']); $this->password = $row['password']; $this->send_confirmation = CommonTools::sqlToBoolean($row['send_confirmation']); $this->confirmation_message = $row['confirmation_message']; $this->debugger->debug("Data for signup gadget (ID {$this->id}) found from database", "selectSignupGadgetById"); } else { $this->debugger->error("Couln't find a signup by ID " . $this->id, "selectSignupGadgetById"); } }