本文整理汇总了PHP中TimeSource::getFormattedForDataBase方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeSource::getFormattedForDataBase方法的具体用法?PHP TimeSource::getFormattedForDataBase怎么用?PHP TimeSource::getFormattedForDataBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSource
的用法示例。
在下文中一共展示了TimeSource::getFormattedForDataBase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFeature
public function setFeature(SiteModel $site, \BaseSiteFeature $siteFeature, $value, UserAccountModel $userAccountModel = null)
{
try {
$this->app['db']->beginTransaction();
$changeMade = false;
$stat = $this->app['db']->prepare("SELECT is_on FROM site_feature_information WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id");
$stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId()));
if ($stat->rowCount() == 1) {
$data = $stat->fetch();
if ($data['is_on'] != $value) {
$stat = $this->app['db']->prepare("UPDATE site_feature_information SET is_on=:is_on " . " WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id ");
$stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0));
$changeMade = true;
}
} else {
$stat = $this->app['db']->prepare("INSERT INTO site_feature_information (site_id, extension_id, feature_id, is_on) " . " VALUES(:site_id, :extension_id, :feature_id, :is_on) ");
$stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0));
$changeMade = true;
}
if ($changeMade) {
$stat = $this->app['db']->prepare("INSERT INTO site_feature_history (site_id, extension_id, feature_id, is_on, user_account_id, created_at) " . " VALUES (:site_id, :extension_id, :feature_id, :is_on, :user_account_id, :created_at)");
$stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0, 'user_account_id' => $userAccountModel ? $userAccountModel->getId() : null, 'created_at' => \TimeSource::getFormattedForDataBase()));
}
$this->app['db']->commit();
} catch (Exception $e) {
$this->app['db']->rollBack();
}
}
示例2: create
public function create(ImportedEventModel $importedEvent)
{
global $DB;
$stat = $DB->prepare("INSERT INTO imported_event ( import_url_id, import_id, title, " . "description, start_at, end_at, timezone, is_deleted, url, ticket_url, created_at, reoccur ) " . " VALUES ( :import_url_id, :import_id, :title, " . ":description, :start_at, :end_at, :timezone, '0', :url, :ticket_url, :created_at, :reoccur ) RETURNING id");
$stat->execute(array('import_url_id' => $importedEvent->getImportUrlId(), 'import_id' => $importedEvent->getImportId(), 'title' => substr($importedEvent->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED), 'description' => $importedEvent->getDescription(), 'start_at' => $importedEvent->getStartAtInUTC()->format("Y-m-d H:i:s"), 'end_at' => $importedEvent->getEndAtInUTC()->format("Y-m-d H:i:s"), 'timezone' => $importedEvent->getTimezone(), 'url' => $importedEvent->getUrl(), 'ticket_url' => $importedEvent->getTicketUrl(), 'reoccur' => $importedEvent->getReoccur() ? json_encode($importedEvent->getReoccur()) : null, 'created_at' => \TimeSource::getFormattedForDataBase()));
$data = $stat->fetch();
$importedEvent->setId($data['id']);
}
示例3: create
public function create(ContactSupportModel $contact)
{
global $DB;
$stat = $DB->prepare("INSERT INTO contact_support (subject, message, email, user_account_id, ip, browser, created_at, is_spam_honeypot_field_detected) " . "VALUES (:subject, :message, :email, :user_account_id, :ip, :browser, :created_at, :is_spam_honeypot_field_detected) RETURNING id");
$stat->execute(array('subject' => substr($contact->getSubject(), 0, VARCHAR_COLUMN_LENGTH_USED), 'message' => $contact->getMessage(), 'email' => substr($contact->getEmail(), 0, VARCHAR_COLUMN_LENGTH_USED), 'user_account_id' => $contact->getUserAccountId(), 'ip' => substr($contact->getIp(), 0, VARCHAR_COLUMN_LENGTH_USED), 'browser' => $contact->getBrowser(), 'created_at' => \TimeSource::getFormattedForDataBase(), 'is_spam_honeypot_field_detected' => $contact->getIsSpamHoneypotFieldDetected() ? 1 : 0));
$data = $stat->fetch();
$contact->setId($data['id']);
}
示例4: create
/**
*
* @return \models\API2ApplicationRequestTokenModel
*/
public function create(API2ApplicationModel $app, API2ApplicationRequestTokenModel $requestToken)
{
global $DB;
$requestToken->setRequestToken(createKey(1, 255));
// TODO make sure token is unique!!!!!
$stat = $DB->prepare("INSERT INTO api2_application_request_token (api2_application_id, request_token, created_at, user_id, " . "callback_url, is_callback_display, is_callback_javascript, is_editor, state_from_user) " . "VALUES (:api2_application_id, :request_token, :created_at, :user_id, :callback_url, " . ":is_callback_display, :is_callback_javascript, :is_editor, :state_from_user)");
$stat->execute(array('api2_application_id' => $app->getId(), 'request_token' => $requestToken->getRequestToken(), 'created_at' => \TimeSource::getFormattedForDataBase(), 'user_id' => null, 'callback_url' => $app->getIsCallbackUrl() ? $requestToken->getCallbackUrl() : null, 'is_callback_display' => $app->getIsCallbackDisplay() && $requestToken->getIsCallbackDisplay() ? 1 : 0, 'is_callback_javascript' => $app->getIsCallbackJavascript() && $requestToken->getIsCallbackJavascript() ? 1 : 0, 'is_editor' => $requestToken->getIsEditor() && $app->getIsEditor() ? 1 : 0, 'state_from_user' => $requestToken->getStateFromUser()));
return $requestToken;
}
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:13,代码来源:API2ApplicationRequestTokenRepository.php
示例5: createForAppAndUserId
public function createForAppAndUserId(API2ApplicationModel $app, $userID)
{
global $DB;
$stat = $DB->prepare("SELECT api2_application_user_token_information.* FROM api2_application_user_token_information WHERE " . "api2_application_id =:api2_application_id AND user_id =:user_id");
$stat->execute(array('api2_application_id' => $app->getId(), 'user_id' => $userID));
if ($stat->rowCount() == 0) {
$stat = $DB->prepare("INSERT INTO api2_application_user_token_information " . "(api2_application_id, user_id, user_token, user_secret, created_at) " . "VALUES (:api2_application_id, :user_id, :user_token, :user_secret, :created_at)");
$stat->execute(array('api2_application_id' => $app->getId(), 'user_id' => $userID, 'user_token' => createKey(1, 255), 'user_secret' => createKey(1, 255), 'created_at' => \TimeSource::getFormattedForDataBase()));
// TODO check for unique user_token
}
}
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:11,代码来源:API2ApplicationUserTokenRepository.php
示例6: create
public function create(UserAccountModel $user)
{
global $DB;
$uar = new UserAccountResetModel();
$uar->setUserAccountId($user->getId());
$uar->setAccessKey(createKey(2, 250));
// TODO check not already used
$stat = $DB->prepare("INSERT INTO user_account_reset (user_account_id, access_key, created_at) " . "VALUES (:user_account_id, :access_key, :created_at)");
$stat->execute(array('user_account_id' => $uar->getUserAccountId(), 'access_key' => $uar->getAccessKey(), 'created_at' => \TimeSource::getFormattedForDataBase()));
$data = $stat->fetch();
return $uar;
}
示例7: addCountryToSite
public function addCountryToSite(CountryModel $country, SiteModel $site, UserAccountModel $user)
{
global $DB;
$stat = $DB->prepare("SELECT * FROM country_in_site_information WHERE site_id =:site_id AND country_id =:country_id");
$stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId()));
if ($stat->rowCount() == 1) {
$stat = $DB->prepare("UPDATE country_in_site_information SET is_in='1' WHERE site_id =:site_id AND country_id =:country_id");
$stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId()));
} else {
$stat = $DB->prepare("INSERT INTO country_in_site_information (site_id,country_id,is_in,is_previously_in,created_at) VALUES (:site_id,:country_id,'1','1',:created_at)");
$stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId(), 'created_at' => \TimeSource::getFormattedForDataBase()));
}
}
示例8: create
/**
*
* @return \models\API2ApplicationModel
*/
public function create(UserAccountModel $user, $title)
{
global $DB;
$app = new API2ApplicationModel();
$app->setTitle($title);
$app->setAppSecret(createKey(1, 255));
$app->setAppToken(createKey(1, 255));
$stat = $DB->prepare("INSERT INTO api2_application_information (user_id,title,app_token,app_secret,created_at) " . "VALUES (:user_id,:title,:app_token,:app_secret,:created_at) RETURNING id");
$stat->execute(array('user_id' => $user->getId(), 'title' => $title, 'app_token' => $app->getAppToken(), 'app_secret' => $app->getAppSecret(), 'created_at' => \TimeSource::getFormattedForDataBase()));
$data = $stat->fetch();
$app->setId($data['id']);
return $app;
}
示例9: resetAccount
public function resetAccount(UserAccountModel $user, UserAccountResetModel $reset)
{
global $DB;
try {
$DB->beginTransaction();
$stat = $DB->prepare("UPDATE user_account_information SET password_hash=:password_hash WHERE id =:id");
$stat->execute(array('id' => $user->getId(), 'password_hash' => $user->getPasswordHash()));
$stat = $DB->prepare("UPDATE user_account_reset SET reset_at=:reset_at WHERE user_account_id =:user_account_id AND access_key=:access_key");
$stat->execute(array('user_account_id' => $user->getId(), 'access_key' => $reset->getAccessKey(), 'reset_at' => \TimeSource::getFormattedForDataBase()));
$DB->commit();
} catch (Exception $e) {
$DB->rollBack();
}
}
示例10: create
public function create(\BaseIncomingLink $incomingLink, SiteModel $site = null)
{
global $DB;
try {
$DB->beginTransaction();
$stat = $DB->prepare("INSERT INTO incoming_link (site_id, extension_id, type, source_url, target_url, reporter_useragent, reporter_ip, created_at) " . "VALUES (:site_id, :extension_id, :type, :source_url, :target_url, :reporter_useragent, :reporter_ip, :created_at) RETURNING id");
$stat->execute(array('site_id' => $site ? $site->getId() : null, 'extension_id' => $incomingLink->getTypeExtensionID(), 'type' => $incomingLink->getType(), 'source_url' => $incomingLink->getSourceURL(), 'target_url' => $incomingLink->getTargetURL(), 'reporter_useragent' => $incomingLink->getReporterUseragent(), 'reporter_ip' => $incomingLink->getReporterIp(), 'created_at' => \TimeSource::getFormattedForDataBase()));
$data = $stat->fetch();
$incomingLink->setId($data['id']);
$DB->commit();
} catch (Exception $e) {
$DB->rollBack();
}
}
示例11: markVerifiedByUserAccountIDAndAccessKey
public function markVerifiedByUserAccountIDAndAccessKey($id, $access, $fromIP = null)
{
global $DB;
try {
$DB->beginTransaction();
$stat = $DB->prepare("UPDATE user_account_verify_email SET verified_at=:verified_at, verified_from_ip=:verified_from_ip WHERE user_account_id =:user_account_id AND access_key=:access_key");
$stat->execute(array('user_account_id' => $id, 'access_key' => $access, 'verified_at' => \TimeSource::getFormattedForDataBase(), 'verified_from_ip' => $fromIP));
$stat = $DB->prepare("UPDATE user_account_information SET is_email_verified='1' WHERE id =:id");
$stat->execute(array('id' => $id));
$DB->commit();
} catch (Exception $e) {
$DB->rollBack();
}
}
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:14,代码来源:UserAccountVerifyEmailRepository.php
示例12: deactivate
public function deactivate(EventCustomFieldDefinitionModel $model, UserAccountModel $userAccountModel = null)
{
global $DB;
try {
$DB->beginTransaction();
$stat = $DB->prepare("UPDATE event_custom_field_definition_information SET is_active='0' WHERE id=:id");
$stat->execute(array('id' => $model->getId()));
$stat = $DB->prepare("INSERT INTO event_custom_field_definition_history (event_custom_field_definition_id, key_changed, extension_id_changed,type_changed,label_changed,is_active,created_at,user_account_id) " . "VALUES (:event_custom_field_definition_id, -2, -2,-2,-2,'0',:created_at,:user_account_id)");
$stat->execute(array('event_custom_field_definition_id' => $model->getId(), 'created_at' => \TimeSource::getFormattedForDataBase(), 'user_account_id' => $userAccountModel ? $userAccountModel->getId() : null));
$DB->commit();
} catch (Exception $e) {
$DB->rollBack();
}
$this->updateSiteCache($model->getSiteId());
}
开发者ID:radical-assembly,项目名称:OpenACalendar-Web-Core,代码行数:15,代码来源:EventCustomFieldDefinitionRepository.php
示例13: startUserWatchingSite
public function startUserWatchingSite(UserAccountModel $user, SiteModel $site)
{
global $DB;
$uws = $this->loadByUserAndSite($user, $site);
if ($uws && $uws->getIsWatching()) {
// all done!
} else {
if ($uws && !$uws->getIsWatching()) {
$stat = $DB->prepare("UPDATE user_watches_site_information SET is_watching='1', last_watch_started=:last_watch_started WHERE user_account_id =:user_account_id AND site_id=:site_id");
$stat->execute(array('user_account_id' => $user->getId(), 'site_id' => $site->getId(), 'last_watch_started' => \TimeSource::getFormattedForDataBase()));
} else {
$stat = $DB->prepare("INSERT INTO user_watches_site_information (user_account_id,site_id,is_watching,is_was_once_watching,last_watch_started,created_at) " . "VALUES (:user_account_id,:site_id,:is_watching,:is_was_once_watching,:last_watch_started,:created_at)");
$stat->execute(array('user_account_id' => $user->getId(), 'site_id' => $site->getId(), 'is_watching' => '1', 'is_was_once_watching' => '1', 'created_at' => \TimeSource::getFormattedForDataBase(), 'last_watch_started' => \TimeSource::getFormattedForDataBase()));
}
}
}
示例14: markUserInterestedInSite
public function markUserInterestedInSite(UserAccountModel $user, SiteModel $site)
{
global $DB;
$uiis = $this->loadByUserAndSite($user, $site);
if ($uiis && $uiis->isInterested()) {
// all done!
} else {
if ($uiis && !$uiis->isInterested()) {
$stat = $DB->prepare("UPDATE user_interested_in_site_information SET is_interested='1' WHERE user_account_id =:user_account_id AND site_id=:site_id");
$stat->execute(array('user_account_id' => $user->getId(), 'site_id' => $site->getId()));
} else {
$stat = $DB->prepare("INSERT INTO user_interested_in_site_information (user_account_id,site_id,is_interested,created_at) " . "VALUES (:user_account_id,:site_id,:is_interested,:created_at)");
$stat->execute(array('user_account_id' => $user->getId(), 'site_id' => $site->getId(), 'is_interested' => '1', 'created_at' => \TimeSource::getFormattedForDataBase()));
}
}
}
示例15: create
public function create(SiteModel $site, UserAccountModel $owner, $countries, SiteQuotaModel $siteQuota, $canAnyUserVerifiedEdit = false)
{
global $DB, $CONFIG, $EXTENSIONHOOKRUNNER;
$createdat = \TimeSource::getFormattedForDataBase();
if (!$site->isSlugValid($site->getSlug(), $CONFIG)) {
throw new Exception("Slug not valid");
}
try {
$DB->beginTransaction();
// TODO should check slug not already exist and nice error
$timezones = array();
foreach ($countries as $country) {
foreach (explode(",", $country->getTimezones()) as $timeZone) {
$timezones[] = $timeZone;
}
}
$site->setCachedTimezonesAsList($timezones);
$site->setCachedIsMultipleCountries(count($countries) > 1);
// Site
$stat = $DB->prepare("INSERT INTO site_information (title, slug, slug_canonical, " . "created_at,cached_is_multiple_timezones,cached_is_multiple_countries," . "cached_timezones,is_feature_map,is_feature_importer,is_feature_curated_list," . "is_listed_in_index,is_web_robots_allowed, " . " prompt_emails_days_in_advance,site_quota_id, " . "is_feature_tag,is_feature_physical_events,is_feature_virtual_events) " . "VALUES (:title, :slug, :slug_canonical, " . " :created_at,:cached_is_multiple_timezones,:cached_is_multiple_countries," . ":cached_timezones,:is_feature_map,:is_feature_importer,:is_feature_curated_list," . ":is_listed_in_index,:is_web_robots_allowed, " . " :prompt_emails_days_in_advance, :site_quota_id, " . ":is_feature_tag,:is_feature_physical_events,:is_feature_virtual_events) RETURNING id");
$stat->execute(array('title' => substr($site->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED), 'slug' => $site->getSlug(), 'slug_canonical' => SiteModel::makeCanonicalSlug($site->getSlug()), 'cached_is_multiple_timezones' => $site->getCachedIsMultipleTimezones() ? 1 : 0, 'cached_is_multiple_countries' => $site->getCachedIsMultipleCountries() ? 1 : 0, 'cached_timezones' => $site->getCachedTimezones(), 'created_at' => $createdat, 'is_feature_curated_list' => $site->getIsFeatureCuratedList() ? 1 : 0, 'is_feature_importer' => $site->getIsFeatureImporter() ? 1 : 0, 'is_feature_map' => $site->getIsFeatureMap() ? 1 : 0, 'is_feature_tag' => $site->getIsFeatureTag() ? 1 : 0, 'is_feature_virtual_events' => $site->getIsFeatureVirtualEvents() ? 1 : 0, 'is_feature_physical_events' => $site->getIsFeaturePhysicalEvents() ? 1 : 0, 'is_listed_in_index' => $site->getIsListedInIndex() ? 1 : 0, 'is_web_robots_allowed' => $site->getIsWebRobotsAllowed() ? 1 : 0, 'prompt_emails_days_in_advance' => $site->getPromptEmailsDaysInAdvance(), 'site_quota_id' => $siteQuota->getId()));
$data = $stat->fetch();
$site->setId($data['id']);
$stat = $DB->prepare("INSERT INTO site_history (site_id, user_account_id, " . "title, slug, slug_canonical, created_at,is_feature_map,is_feature_importer," . "is_feature_curated_list,is_listed_in_index,is_web_robots_allowed, " . " prompt_emails_days_in_advance, is_new," . "is_feature_tag,is_feature_physical_events,is_feature_virtual_events) " . "VALUES (:site_id, :user_account_id, :title, " . ":slug, :slug_canonical, :created_at,:is_feature_map,:is_feature_importer," . ":is_feature_curated_list,:is_listed_in_index,:is_web_robots_allowed, " . " :prompt_emails_days_in_advance, '1', " . ":is_feature_tag,:is_feature_physical_events,:is_feature_virtual_events)");
$stat->execute(array('site_id' => $site->getId(), 'user_account_id' => $owner->getId(), 'title' => substr($site->getTitle(), 0, VARCHAR_COLUMN_LENGTH_USED), 'slug' => $site->getSlug(), 'slug_canonical' => SiteModel::makeCanonicalSlug($site->getSlug()), 'created_at' => $createdat, 'is_feature_curated_list' => $site->getIsFeatureCuratedList() ? 1 : 0, 'is_feature_importer' => $site->getIsFeatureImporter() ? 1 : 0, 'is_feature_map' => $site->getIsFeatureMap() ? 1 : 0, 'is_feature_tag' => $site->getIsFeatureTag() ? 1 : 0, 'is_feature_virtual_events' => $site->getIsFeatureVirtualEvents() ? 1 : 0, 'is_feature_physical_events' => $site->getIsFeaturePhysicalEvents() ? 1 : 0, 'is_listed_in_index' => $site->getIsListedInIndex() ? 1 : 0, 'is_web_robots_allowed' => $site->getIsWebRobotsAllowed() ? 1 : 0, 'prompt_emails_days_in_advance' => $site->getPromptEmailsDaysInAdvance()));
// Permissions
$ugr = new UserGroupRepository();
$userGroupEditors = new UserGroupModel();
$userGroupEditors->setTitle("Editors");
$userGroupEditors->setIsIncludesVerifiedUsers($canAnyUserVerifiedEdit);
$ugr->createForSite($site, $userGroupEditors, $owner, array(array('org.openacalendar', 'CALENDAR_CHANGE')), array($owner));
$userGroupEditors = new UserGroupModel();
$userGroupEditors->setTitle("Administrators");
$ugr->createForSite($site, $userGroupEditors, $owner, array(array('org.openacalendar', 'CALENDAR_ADMINISTRATE')), array($owner));
// Countries!
$stat = $DB->prepare("INSERT INTO country_in_site_information (site_id,country_id,is_in,is_previously_in,created_at) VALUES (:site_id,:country_id,'1','1',:created_at)");
foreach ($countries as $country) {
$stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId(), 'created_at' => $createdat));
}
$stat = $DB->prepare("INSERT INTO user_watches_site_information (user_account_id,site_id,is_watching,is_was_once_watching,last_watch_started,created_at) " . "VALUES (:user_account_id,:site_id,:is_watching,:is_was_once_watching,:last_watch_started,:created_at)");
$stat->execute(array('user_account_id' => $owner->getId(), 'site_id' => $site->getId(), 'is_watching' => '1', 'is_was_once_watching' => '1', 'created_at' => \TimeSource::getFormattedForDataBase(), 'last_watch_started' => \TimeSource::getFormattedForDataBase()));
$DB->commit();
$EXTENSIONHOOKRUNNER->afterSiteCreate($site, $owner);
} catch (Exception $e) {
$DB->rollBack();
}
}