本文整理汇总了PHP中sqlDate函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlDate函数的具体用法?PHP sqlDate怎么用?PHP sqlDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlDate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exchange
function exchange($val)
{
$date = sqlDate('now');
$kes = $this->getDi()->currencyExchangeTable->getRate('KES', $date);
$usd = $this->getDi()->currencyExchangeTable->getRate('USD', $date);
return moneyRound($val * $kes / $usd);
}
示例2: addTo
function addTo($date)
{
if ($this->isEmpty()) {
throw new Am_Exception_InternalError("Could not do this operation on empty object " . __METHOD__);
}
if ($this->unit == self::FIXED) {
return $this->count;
}
list($y, $m, $d) = explode('-', sqlDate($date));
$tm = amstrtotime($date);
switch ($this->unit) {
case self::DAY:
$tm2 = mktime(0, 0, 0, $m, $d + $this->count, $y);
break;
case self::MONTH:
$tm2 = mktime(0, 0, 0, $m + $this->count, $d, $y);
break;
case self::YEAR:
$tm2 = mktime(0, 0, 0, $m, $d, $y + $this->count);
break;
default:
throw new Am_Exception_InternalError("Unknown period unit configured in " . $this->__toString());
}
if ($tm2 < $tm) {
// overflow, assign fixed "lifetime" date
return self::MAX_SQL_DATE;
}
return date('Y-m-d', $tm2);
}
示例3: onSubscriptionDeleted
public function onSubscriptionDeleted(Am_Event_SubscriptionDeleted $event)
{
if (!$this->getConfig('expired_list')) {
return;
}
$user = $event->getUser();
$lmDb = $this->getConfig('db') . '.' . $this->getConfig('prefix');
Am_Di::getInstance()->db->query("\n INSERT INTO {$lmDb}users\n (uid,list,fname,lname,email,cseq,cdel,cnf,dateadd,htmail)\n VALUES\n (?,?,?,?,?, 1, 0, 1, ?, 1)\n ", $this->_getUniqUid(), $this->getConfig('expired_list'), $user->name_f, $user->name_l, $user->email, sqlDate(time()));
}
示例4: insert
public function insert($reload = true)
{
if ($this->currency == Am_Currency::getDefault()) {
$this->base_currency_multi = 1.0;
} else {
$this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
}
parent::insert($reload);
$this->getDi()->hook->call(new Am_Event_PaymentAfterInsert(null, array('payment' => $this, 'invoice' => $this->getInvoice(), 'user' => $this->getInvoice()->getUser())));
return $this;
}
示例5: insert
public function insert($reload = true)
{
if ($this->currency == Am_Currency::getDefault()) {
$this->base_currency_multi = 1.0;
} else {
$this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
}
$ret = parent::insert($reload);
$this->getDi()->hook->call('refundAfterInsert', array('invoice' => $this->getInvoice(), 'refund' => $this, 'user' => $this->getInvoice()->getUser()));
return $ret;
}
示例6: getStatus
/**
* @return int status constant
*/
function getStatus()
{
$now = sqlDate('now');
if ($this->expire_date < $now) {
return self::EXPIRED;
}
if ($this->begin_date > $now) {
return self::FUTURE;
}
return self::ACTIVE;
}
示例7: init
function init()
{
$this->addText('users_count')->setLabel(___('Generate Users Count'))->setValue(100);
$this->addText('email_domain')->setLabel(___("Email Domain\nused to generate email address for users"))->setValue('cgi-central.int');
if ($this->isProductsExists()) {
$this->addCheckbox('do_not_generate_products', array('checked' => 'checked'))->setLabel(___("Do not generate products\n" . "use existing products for demo records"))->setId('form-do-not-generate-products');
$this->addMagicSelect('product_ids')->setLabel(___("Use the following product for demo users\n" . 'keep it empty to use any products'))->setId('form-product_ids')->loadOptions(Am_Di::getInstance()->productTable->getOptions());
$script = <<<CUT
\$(function() {
function toggle_do_not_generate_products() {
if (\$('input[name=do_not_generate_products]').prop('checked')) {
\$('#form-products-count').parents('.row').hide();
\$('#form-product_ids').parents('.row').show();
} else {
\$('#form-products-count').parents('.row').show();
\$('#form-product_ids').parents('.row').hide();
}
}
toggle_do_not_generate_products()
\$('input[name=do_not_generate_products]').bind('change', function(){
toggle_do_not_generate_products();
})
});
CUT;
$this->addScript('script')->setScript($script);
}
$this->addText('products_count', array('size' => 3))->setLabel(___('Generate Products Count'))->setValue(3)->setId('form-products-count');
$gr = $this->addGroup()->setLabel(___('Invoices Per User'));
$gr->addText('invoices_per_user', array('size' => 3))->setValue(2);
$gr->addStatic()->setContent(' +/- ');
$gr->addText('invoices_per_user_variation', array('size' => 3))->setValue(1);
$gr = $this->addGroup()->setLabel(___('Products Per Invoice'));
$gr->addText('products_per_invoice', array('size' => 3))->setValue(2);
$gr->addStatic()->setContent(' +/- ');
$gr->addText('products_per_invoice_variation', array('size' => 3))->setValue(1);
$gr = $this->addGroup()->setLabel(___('Period'));
$gr->setSeparator(' ');
$gr->addDate('date_begin', array('size' => 8))->setValue(sqlDate('-60 days'));
$gr->addDate('date_end', array('size' => 8))->setValue(sqlDate('now'));
parent::init();
$this->addSaveButton(___('Generate'));
}
示例8: run
public function run()
{
$this->grid->getDi()->plugins_payment->loadEnabled()->getAllEnabled();
$ds = $this->grid->getDataSource();
$fn = tempnam(DATA_DIR, 'zip_');
$zip = new ZipArchive();
$zip->open($fn, ZipArchive::OVERWRITE);
$st = $ds->query();
while ($iprec = $this->grid->getDi()->db->fetchRow($st)) {
$ip = $ds->getDataSourceQuery()->getTable()->createRecord($iprec);
$pdf = Am_Pdf_Invoice::create($ip);
$zip->addFromString($pdf->getFileName(), $pdf->render());
}
$zip->close();
register_shutdown_function(array($this, 'cleanup'), $fn);
$helper = new Am_Controller_Action_Helper_SendFile();
$helper->sendFile($fn, 'application/octet-stream', array('filename' => sprintf('invoices-%s.zip', sqlDate('now'))));
}
示例9: run
function run()
{
$form = new Am_Form_Admin('form-grid-payout');
$form->setAttribute('name', 'payout');
$date = $form->addDate('payout_date')->setLabel(___('Payout Date'))->setValue(sqlDate($this->getDi()->dateTime));
foreach ($this->grid->getVariablesList() as $k) {
$form->addHidden($this->grid->getId() . '_' . $k)->setValue($this->grid->getRequest()->get($k, ""));
}
$form->addSaveButton(___("Run Payout"));
$form->setDataSources(array($this->grid->getCompleteRequest()));
if ($form->isSubmitted() && $form->validate()) {
$values = $form->getValue();
$this->getDi()->affCommissionTable->runPayout($values['payout_date']);
$this->grid->redirectBack();
} else {
echo $this->renderTitle();
echo $form;
}
}
示例10: indexAction
public function indexAction()
{
/* @var $invoice Invoice */
$invoice = $this->getDi()->invoiceTable->findBySecureId($this->getParam('secure_id'), 'payment-link');
if (!$invoice || $invoice->status != Invoice::PENDING) {
throw new Am_Exception_InternalError(sprintf('Unknow invoice [%s] or invoice is already processed', filterId($this->getParam('secure_id'))));
}
if (!$invoice->due_date && sqlDate($invoice->tm_added) < sqlDate("-" . Invoice::DEFAULT_DUE_PERIOD . " days")) {
throw new Am_Exception_InputError(___('Invoice is expired'));
} elseif ($invoice->due_date && $invoice->due_date < sqlDate('now')) {
throw new Am_Exception_InputError(___('Invoice is expired'));
}
$form = new Am_Form();
if (!$invoice->paysys_id) {
$psOptions = array();
foreach (Am_Di::getInstance()->paysystemList->getAllPublic() as $ps) {
$psOptions[$ps->getId()] = $this->renderPaysys($ps);
}
$paysys = $form->addAdvRadio('paysys_id')->setLabel(___('Payment System'))->loadOptions($psOptions);
$paysys->addRule('required', ___('Please choose a payment system'));
if (count($psOptions) == 1) {
$paysys->toggleFrozen(true);
}
}
$form->addSaveButton(___('Pay'));
$this->view->invoice = $invoice;
$this->view->form = $form;
$form->setDataSources(array($this->getRequest()));
if ($form->isSubmitted() && $form->validate()) {
$vars = $form->getValue();
if (!$invoice->paysys_id) {
$invoice->setPaysystem($vars['paysys_id']);
$invoice->save();
}
$payProcess = new Am_Paysystem_PayProcessMediator($this, $invoice);
$result = $payProcess->process();
throw new Am_Exception_InternalError(sprintf('Error occurred while trying proccess invoice [%s]', filterId($invoice->public_id)));
}
$this->view->layoutNoMenu = true;
$this->view->display('pay.phtml');
}
示例11: seed
private function seed()
{
$parser = new Csv();
$parser->setFilePath(DOC_ROOT . '/data/restaurants.csv');
$data = $parser->parse();
if ($data === false) {
echo "Error parsing CSV";
return 1;
}
foreach ($data as $row) {
$restaurant = ORM::for_table("restaurants")->create();
$name = $row["restaurant_name"];
$restaurant->restaurant_name = $name;
$restaurant->cuisine_type = $row["cuisine_type"];
$restaurant->created = sqlDate();
$restaurant->updated = sqlDate();
$restaurant->save();
echo "Created restaurant `{$name}` \n";
}
return 0;
}
示例12: getAddForm
public function getAddForm()
{
$form = new Am_Form_Admin();
$form->setAction($url = $this->getUrl(null, 'c', null, 'payments', 'addpayment', 'user_id', $this->user_id));
$form->addText("receipt_id", array('tabindex' => 2))->setLabel("Receipt#")->addRule('required');
$amt = $form->addSelect("amount", array('tabindex' => 3), array('intrinsic_validation' => false))->setLabel("Amount");
$amt->addRule('required', 'This field is required');
if ($this->_request->getInt('invoice_id')) {
$invoice = $this->getDi()->invoiceTable->load($this->_request->getInt('invoice_id'));
if (!$invoice->first_total || $invoice->getPaymentsCount()) {
$amt->addOption($invoice->second_total, $invoice->second_total);
} else {
$amt->addOption($invoice->first_total, $invoice->first_total);
}
}
$form->addSelect("paysys_id", array('tabindex' => 1))->setLabel("Payment System")->loadOptions($this->getDi()->paysystemList->getOptions());
$date = $form->addDate("dattm", array('tabindex' => 4))->setLabel("Date Of Transaction");
$date->addRule('required', 'This field is required');
$date->setValue(sqlDate('now'));
$form->addHidden("invoice_id");
$form->addSaveButton();
return $form;
}
示例13: getStartStop
public function getStartStop($key)
{
$start = $this->getStart($key);
return array(sqlDate($start), sqlDate(strtotime('+3 month', $start) - 1));
}
示例14: onDaily
public function onDaily(Am_Event $event)
{
$this->di->userTable->checkAllSubscriptions();
$this->di->emailTemplateTable->sendCronExpires();
$this->di->emailTemplateTable->sendCronAutoresponders();
$this->di->emailTemplateTable->sendCronPendingNotifications();
$this->di->store->cronDeleteExpired();
$this->di->storeRebuild->cronDeleteExpired();
Am_Auth_BruteforceProtector::cleanUp();
if ($this->di->config->get('clear_access_log') && $this->di->config->get('clear_access_log_days') > 0) {
$dat = sqlDate($this->di->time - $this->di->config->get('clear_access_log_days') * 3600 * 24);
$this->di->accessLogTable->clearOld($dat);
}
if ($this->di->config->get('clear_inc_payments') && $this->di->config->get('clear_inc_payments_days') > 0) {
$dat = sqlDate($this->di->time - $this->di->config->get('clear_inc_payments_days') * 3600 * 24);
$this->di->invoiceTable->clearPending($dat);
}
if ($this->di->config->get('clear_inc_users') && $this->di->config->get('clear_inc_users_days') > 0) {
$dat = sqlDate($this->di->time - $this->di->config->get('clear_inc_users_days') * 3600 * 24);
$this->di->userTable->clearPending($dat);
}
$this->di->uploadTable->cleanUp();
Am_Mail_Queue::getInstance()->cleanUp();
}
示例15: requireParam
* {user: "", pass: ""}
*
* Response Wrapper Body:
* {token: ..., expires: ...}
*/
include_once "utils.php";
include_once "model.php";
/** Validate **/
$username = requireParam("user");
$password = requireParam("pass");
$passwordHash = md5(md5($password) . $salt);
/** Check the DB for this user / pass combination **/
$account = Account::fromCredentials($username, $passwordHash);
if ($account == false) {
error('User not found', 600);
}
if ($account->status != 1) {
error('Account suspended', 601);
}
/** Kill old sessions **/
Session::clearForAccount($account->accountId);
/** Create a session **/
$session = new Session();
$session->sessionId = gen_uuid();
$session->accountId = $account->accountId;
$session->expires = sqlDate(time() + 1200);
if ($session->create()) {
success(array('valid' => true, 'uid' => $account->uuid, 'sessionID' => $session->sessionId, 'sessionStart' => $session->created, 'sessionEnd' => $session->expires));
} else {
error('Failed to create session', 602);
}