Exemple #1
0
 static function deleteOnId($mediaId)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     settype($mediaId, "integer");
     $sql = " delete from sc_media where id = ? ";
     MySQL\Helper::executeSQL($mysqli, $sql);
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("i", $mediaId);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Exemple #2
0
Fichier : Mail.php Projet : rjha/sc
 static function capture($emails, $message)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = " insert into sc_email_capture(email,message,created_on) values ";
     //sanitize message
     $message = $mysqli->real_escape_string($message);
     $isize = sizeof($emails);
     if ($isize == 0) {
         return;
     }
     for ($index = 0; $index < $isize; $index++) {
         //last one?
         $suffix = $index == $isize - 1 ? "" : ",";
         $email = $emails[$index];
         //sanitize email
         $email = $mysqli->real_escape_string($email);
         $sql .= sprintf(" ('%s','%s',now())%s ", $email, $message, $suffix);
     }
     MySQL\Helper::executeSQL($mysqli, $sql);
 }
Exemple #3
0
function process_activities($mysqli)
{
    /* 
     * process activities data 
     * @imp activities should be brought in the order that they have happened
     * so sort on id ASC 
     */
    $sql = " select * from sc_activity where op_bit = 0 order by id limit 50";
    $rows = MySQL\Helper::fetchRows($mysqli, $sql);
    $activityDao = new \com\indigloo\sc\dao\Activity();
    foreach ($rows as $row) {
        try {
            $sql2 = " update sc_activity set op_bit = 1 where id = " . $row["id"];
            $feed = $activityDao->pushToRedis($row);
            $activityDao->sendMail($row, $feed);
            //flip the op_bit for this activity
            MySQL\Helper::executeSQL($mysqli, $sql2);
        } catch (\Exception $ex) {
            Logger::getInstance()->error($ex->getMessage());
        }
    }
}