本文整理汇总了PHP中Subscription::CreateFromQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::CreateFromQuery方法的具体用法?PHP Subscription::CreateFromQuery怎么用?PHP Subscription::CreateFromQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::CreateFromQuery方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flash_error
require "modules/landing.php";
return;
}
if (empty($_POST['currency'])) {
flash_error("Please pick a valid currency.");
require "modules/landing.php";
return;
}
if (empty($_POST['amount']) || preg_match("([0-9]*[.,][0-9]+|[0-9]+)", $_POST['amount']) == false) {
flash_error("Please enter a valid amount.");
require "modules/landing.php";
return;
}
try {
$exists = false;
Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `EmailAddress` = :EmailAddress AND `Confirmed` = 0", array(":EmailAddress" => $_POST['email']));
$exists = true;
} catch (NotFoundException $e) {
$exists = false;
}
if ($exists) {
flash_error("That e-mail address has subscribed before and is currently awaiting confirmation.");
require "modules/landing.php";
return;
}
try {
$exists = false;
foreach (Subscription::FindByEmail($_POST['email']) as $sSubscription) {
if ($sSubscription->sCampaignId == $sCampaign->sId && $sSubscription->sIsActive == true) {
$exists = true;
$sExistingSubscription = $sSubscription;
示例2: UpdateStatistics
public function UpdateStatistics()
{
global $database, $cphp_config;
if (!empty($cphp_config->debugmode) || $this->sLastStatisticsUpdate < time() - 60 * 5) {
/* Update subscriber count */
if ($result = $database->CachedQuery("SELECT COUNT(*) FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId))) {
$this->uSubscriberCount = $result->data[0]["COUNT(*)"];
}
/* Update total monthly donations */
try {
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `CampaignId` = :CampaignId AND `Confirmed` = 1 AND `Active` = 1", array(":CampaignId" => $this->sId));
$sTotalDonations = 0;
foreach ($sSubscriptions as $sSubscription) {
$sTotalDonations += Currency::Convert("usd", $sSubscription->sCurrency, $sSubscription->sAmount);
}
$this->uMonthlyTotal = $sTotalDonations;
} catch (NotFoundException $e) {
$this->uMonthlyTotal = 0;
}
/* Update donation rate */
try {
$sDonationsAsked = LogEntry::CreateFromQuery("SELECT * FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::DONATION_ASKED));
$have_data = true;
} catch (NotFoundException $e) {
/* We don't have any data to work from yet. */
$sDonationsAsked = array();
$have_data = false;
}
if ($have_data) {
try {
$sDonationsMade = LogEntry::CreateFromQuery("SELECT * FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::DONATION_MADE));
$this->uDonationRate = count($sDonationsMade) / count($sDonationsAsked) * 100;
$this->uHaveData = true;
} catch (NotFoundException $e) {
$sDonationsMade = array();
$this->uDonationRate = 0;
$this->uHaveData = false;
}
} else {
$sDonationsMade = array();
$this->uDonationRate = 100;
$this->uHaveData = false;
}
/* Update projected monthly donations */
$this->uMonthlyProjection = $this->uMonthlyTotal * ($this->uDonationRate / 100);
/* Update past-month subscription count */
if ($result = $database->CachedQuery("SELECT COUNT(*) FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::SUBSCRIPTION_CONFIRMED), 0)) {
$this->uPastMonthSubscriptions = $result->data[0]["COUNT(*)"];
}
/* Update past-month unsubscription count */
if ($result = $database->CachedQuery("SELECT COUNT(*) FROM log_entries WHERE `CampaignId` = :CampaignId AND `Type` = :Type AND `Date` > DATE_SUB(NOW(), INTERVAL 1 MONTH)", array(":CampaignId" => $this->sId, ":Type" => LogEntry::UNSUBSCRIPTION), 0)) {
$this->uPastMonthUnsubscriptions = $result->data[0]["COUNT(*)"];
}
/* Update past month donation count */
$this->uPastMonthDonations = count($sDonationsMade);
/* Update past month non-donation count */
$this->uPastMonthNonDonations = count($sDonationsAsked) - count($sDonationsMade);
$this->uLastStatisticsUpdate = time();
$this->InsertIntoDatabase();
}
}
示例3: http_status_code
$_APP = true;
require "includes/base.php";
if (php_sapi_name() !== "cli") {
http_status_code(403);
die;
}
/* This cronjob will send out donation reminder e-mails for every user
* that hasn't received an e-mail in the past month. It will also
* re-generate statistics for every campaign, and store them in the
* historical statistics logs.
*/
/* First, we will update the exchange rates. */
Currency::UpdateRates();
/* Then, we'll start out sending reminder e-mails. */
try {
$sSubscriptions = Subscription::CreateFromQuery("SELECT * FROM subscriptions WHERE `Confirmed` = 1 AND `Active` = 1 AND (`LastEmail` IS NULL OR `LastEmail` < DATE_SUB(NOW(), INTERVAL 1 MONTH))");
} catch (NotFoundException $e) {
$sSubscriptions = array();
}
foreach ($sSubscriptions as $sSubscription) {
$sSubscription->SendPaymentRequest();
}
/* Now, we'll log a historical statistics snapshot for every campaign. */
try {
$sCampaigns = Campaign::CreateFromQuery("SELECT * FROM campaigns");
$found = true;
} catch (NotFoundException $e) {
/* No campaigns are in the database yet. */
$found = false;
}
if ($found) {