本文整理汇总了PHP中DB::alteration_message方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::alteration_message方法的具体用法?PHP DB::alteration_message怎么用?PHP DB::alteration_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::alteration_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($request)
{
$customerGroup = EcommerceRole::get_customer_group();
if ($customerGroup) {
$allCombos = DB::query("\n\t\t\t\tSELECT \"Group_Members\".\"ID\", \"Group_Members\".\"MemberID\", \"Group_Members\".\"GroupID\"\n\t\t\t\tFROM \"Group_Members\"\n\t\t\t\tWHERE \"Group_Members\".\"GroupID\" = " . $customerGroup->ID . ";");
//make an array of all combos
$alreadyAdded = array();
$alreadyAdded[-1] = -1;
if ($allCombos) {
foreach ($allCombos as $combo) {
$alreadyAdded[$combo["MemberID"]] = $combo["MemberID"];
}
}
$unlistedMembers = DataObject::get("Member", $where = "\"Member\".\"ID\" NOT IN (" . implode(",", $alreadyAdded) . ")", $sort = "", $join = "INNER JOIN \"Order\" ON \"Order\".\"MemberID\" = \"Member\".\"ID\"");
//add combos
if ($unlistedMembers) {
$existingMembers = $customerGroup->Members();
foreach ($unlistedMembers as $member) {
$existingMembers->add($member);
DB::alteration_message("Added member to customers: " . $member->Email, "created");
}
}
} else {
DB::alteration_message("NO customer group found", "deleted");
}
}
示例2: run
function run($request)
{
$productVariationArrayID = array();
if (empty($_GET["live"])) {
$live = false;
} else {
$live = intval($_GET["live"]) == 1 ? true : false;
}
if ($live) {
DB::alteration_message("this is a live task", "deleted");
} else {
DB::alteration_message("this is a test only. If you add a live=1 get variable then you can make it for real ;-)", "created");
}
foreach ($this->tableArray as $table) {
$sql = "DELETE FROM \"{$table}\"";
DB::alteration_message("<pre>DELETING FROM {$table}: <br /><br />" . $sql . "</pre>");
if ($live) {
DB::query($sql);
}
$sql = "SELECT COUNT(ID) FROM \"{$table}\"";
$count = DB::query($sql)->value();
if ($count == 0) {
$style = "created";
} else {
$style = "deleted";
}
DB::alteration_message(" **** COMPLETED, NUMBER OF REMAINING RECORD: " . $count . " **** ", $style);
}
}
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce_product_variation,代码行数:29,代码来源:EcommerceProductVariationTaskDeleteAll.php
示例3: run
public function run($request)
{
if (!Director::is_cli() && !isset($_GET['run'])) {
DB::alteration_message('Must add ?run=1', 'error');
return false;
}
if (!Director::is_cli()) {
// - Add UTF-8 so characters will render as they should when debugging (so you can visualize inproperly formatted characters easier)
// - Add base_tag so that printing blocks of HTML works properly with relative links (helps with visualizing errors)
?>
<head>
<?php
echo SSViewer::get_base_tag('');
?>
<meta charset="UTF-8">
</head>
<?php
}
increase_time_limit_to(300);
WordpressDatabase::$default_config = $this->config()->default_db;
$this->db = $this->wordpressImportService->getDatabase();
// Login as default admin so 'canPublish()' definitely returns true in 'SiteTree::doPublish()'
if (!Member::currentUser()) {
$defaultAdmin = Member::default_admin();
if ($defaultAdmin && $defaultAdmin->exists()) {
Session::set('loggedInAs', $defaultAdmin->ID);
}
}
// Unsure if the importing functionality can ever hit this, but just incase.
if (Versioned::current_stage() !== 'Stage') {
throw new Exception('Versioned::current_stage() must be "Stage".');
}
$this->runCustom($request);
}
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:34,代码来源:WordpressImportBasicTask.php
示例4: default_group
/**
* Check for default group, and if it doesn't exist, create it
* Should be run under "requireDefaultRecords"
* @param string $code
* @param string $title
* @param string $parent
* @param array $permissions
*/
public static function default_group($code, $title, $parentCode = null, $permissions = array())
{
$group = null;
$action = null;
if (!DataObject::get_one('Group', "Code = '" . $code . "'")) {
$action = 'create';
$group = new Group();
} else {
$action = 'update';
$group = DataObject::get_one('Group', "Code = '" . $code . "'");
}
$group->Title = $title;
$group->Code = $code;
if ($parentCode) {
$parentObj = DataObject::get_one("Group", "Code = '" . $parentCode . "'");
$group->ParentID = $parentObj->ID;
}
$group->write();
if (!empty($permissions)) {
foreach ($permissions as $p) {
Permission::grant($group->ID, $p);
}
}
if ($action == 'create') {
DB::alteration_message('Group ' . $title . ' (' . $code . ') has been created.', "created");
}
if ($action == 'update') {
DB::alteration_message('Group ' . $title . ' (' . $code . ') has been updated.', "updated");
}
return $group;
}
示例5: run
function run($request)
{
$orderItemSingleton = singleton('OrderItem');
$query = $orderItemSingleton->buildSQL("\"Quantity\" > 0");
$select = $query->select;
$select['NewNumberSold'] = self::$number_sold_calculation_type . "(\"OrderItem\".\"Quantity\") AS \"NewNumberSold\"";
$query->select($select);
$query->groupby("\"BuyableClassName\", \"BuyableID\" ");
$query->orderby("\"BuyableClassName\", \"BuyableID\" ");
//$q->leftJoin('OrderItem','"Product"."ID" = "OrderItem"."BuyableID"');
//$q->where("\"OrderItem\".\"BuyableClassName\" = 'Product'");
$records = $query->execute();
$orderItems = $orderItemSingleton->buildDataObjectSet($records, "DataObjectSet", $query, 'OrderItem');
if ($orderItems) {
foreach ($orderItems as $orderItem) {
if (!$orderItem->NewNumberSold) {
$orderItem->NewNumberSold = 0;
}
$buyable = DataObject::get_by_id($orderItem->BuyableClassName, $orderItem->BuyableID);
if ($buyable) {
if ($orderItem->NewNumberSold != $buyable->NumberSold) {
$buyable->NumberSold = $orderItem->NewNumberSold;
if ($buyable instanceof SiteTree) {
}
}
} else {
DB::alteration_message("could not find " . $orderItem->BuyableClassName . "." . $orderItem->BuyableID . " ... ", "deleted");
}
}
}
}
示例6: requireDefaultRecords
/**
* The process to automatically consolidate existing and configuration defined tag types, executed on project build.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Retrieve existing and configuration defined tag types that have not been consolidated.
foreach ($this->service->getFusionTagTypes() as $type => $field) {
if (($tags = $type::get()->filter('FusionTagID', 0)) && $tags->exists()) {
foreach ($tags as $tag) {
// Determine whether there's an existing fusion tag.
if (!($existing = FusionTag::get()->filter('Title', $tag->{$field})->first())) {
// There is no fusion tag, therefore instantiate one using the current tag.
$fusion = FusionTag::create();
$fusion->Title = $tag->{$field};
$fusion->TagTypes = serialize(array($tag->ClassName => $tag->ClassName));
$fusion->write();
$fusionID = $fusion->ID;
} else {
// There is a fusion tag, therefore append the current tag type.
$types = unserialize($existing->TagTypes);
$types[$tag->ClassName] = $tag->ClassName;
$existing->TagTypes = serialize($types);
$existing->write();
$fusionID = $existing->ID;
}
// Update the current tag to point to this.
$tag->FusionTagID = $fusionID;
$tag->write();
DB::alteration_message("\"{$tag->{$field}}\" Fusion Tag", 'created');
}
}
}
}
示例7: run
function run($request)
{
//IMPORTANT!
Config::inst()->update("Email", "send_all_emails_to", "no-one@localhost");
Email::set_mailer(new EcommerceTaskTryToFinaliseOrders_Mailer());
$orderStatusLogClassName = "OrderStatusLog";
$submittedOrderStatusLogClassName = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
if ($submittedOrderStatusLogClassName) {
$sampleSubmittedStatusLog = $submittedOrderStatusLogClassName::get()->First();
if ($sampleSubmittedStatusLog) {
$lastOrderStep = OrderStep::get()->sort("Sort", "DESC")->First();
if ($lastOrderStep) {
$joinSQL = "INNER JOIN \"{$orderStatusLogClassName}\" ON \"{$orderStatusLogClassName}\".\"OrderID\" = \"Order\".\"ID\"";
$whereSQL = "WHERE \"StatusID\" <> " . $lastOrderStep->ID . " AND \"{$orderStatusLogClassName}\".ClassName = '{$submittedOrderStatusLogClassName}'";
$count = DB::query("\r\n\t\t\t\t\t\tSELECT COUNT (\"Order\".\"ID\")\r\n\t\t\t\t\t\tFROM \"Order\"\r\n\t\t\t\t\t\t{$joinSQL}\r\n\t\t\t\t\t\t{$whereSQL}\r\n\t\t\t\t\t")->value();
$do = DB::query("\r\n\t\t\t\t\t\tUPDATE \"Order\"\r\n\t\t\t\t\t\t{$joinSQL}\r\n\t\t\t\t\t\tSET \"Order\".\"StatusID\" = " . $lastOrderStep->ID . "\r\n\t\t\t\t\t\t{$whereSQL}\r\n\t\t\t\t\t");
if ($count) {
DB::alteration_message("NOTE: {$count} records were updated.", "created");
} else {
DB::alteration_message("No records were updated.");
}
} else {
DB::alteration_message("Could not find the last order step.", "deleted");
}
} else {
DB::alteration_message("Could not find any submitted order logs.", "deleted");
}
} else {
DB::alteration_message("Could not find a class name for submitted orders.", "deleted");
}
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:31,代码来源:EcommerceTaskArchiveAllSubmittedOrders.php
示例8: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!$this->owner->config()->upgrade_on_build) {
return;
}
// Perform migrations (the legacy field will be left in the DB by the ORM)
$class = $this->owner->class;
$baseclass = $this->ownerBaseClass;
if ($baseclass == $class) {
// if(in_array('FeaturedImageExtension', Config::inst()->get($class, 'extensions'))){
$rows = DB::query('SELECT * FROM "' . $baseclass . '"');
$altered = false;
foreach ($rows as $page) {
if (array_key_exists('FeaturedImageID', $page) && ($imageID = $page['FeaturedImageID'])) {
DB::query('INSERT INTO "' . $baseclass . '_FeaturedImages" (' . $class . 'ID, ImageID) VALUES (' . $page['ID'] . ', ' . $page['FeaturedImageID'] . ')');
$altered = true;
//$page->FeaturedImages()->add($imageID);
//$page->FeaturedImageID = null; // leave as is...
// $page->write();
}
}
// Now drop the legacy field
if ($altered) {
DB::query('ALTER TABLE "' . $baseclass . '" DROP "FeaturedImageID"');
DB::alteration_message('Migrated FeaturedImages to many_many on ' . $baseclass, 'changed');
}
}
}
示例9: run
function run($request)
{
$days = intval($request->getVar("days") - 0);
if (!$days) {
$days = $this->defaultDays;
}
$countMin = intval($request->getVar("min") - 0);
if (!$countMin) {
$countMin = $this->defaultMinimum;
}
$endingDaysBack = intval($request->getVar("ago") - 0);
if (!$endingDaysBack) {
$endingDaysBack = $this->endingDaysBack;
}
$field = EcommerceSearchHistoryFormField::create("stats", $this->title)->setNumberOfDays($days)->setMinimumCount($countMin)->setEndingDaysBack($endingDaysBack);
echo $field->forTemplate();
$arrayNumberOfDays = array(30, 365);
$link = "/dev/tasks/EcommerceTaskReviewSearches/";
for ($months = 0; $months++; $months < 36) {
foreach ($arrayNumberOfDays as $numberOfDays) {
$myLink = $link . "?ago=" . floor($months * 30.5) . "&days=" . $numberOfDays;
DB::alteration_message("<a href=\"" . $myLink . "\">{$months} months ago, last {$numberOfDays} days</a>");
}
}
}
示例10: requireDefaultRecords
/**
* Ensures that there is always a 404 page
* by checking if there's an instance of
* ErrorPage with a 404 and 500 error code. If there
* is not, one is created when the DB is built.
*/
function requireDefaultRecords()
{
parent::requireDefaultRecords();
$pageNotFoundErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '404'");
if (!($pageNotFoundErrorPage && $pageNotFoundErrorPage->exists())) {
$pageNotFoundErrorPage = new ErrorPage();
$pageNotFoundErrorPage->ErrorCode = 404;
$pageNotFoundErrorPage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
$pageNotFoundErrorPage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
$pageNotFoundErrorPage->Status = 'New page';
$pageNotFoundErrorPage->write();
$pageNotFoundErrorPage->publish('Stage', 'Live');
DB::alteration_message('404 page created', 'created');
}
$serverErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '500'");
if (!($serverErrorPage && $serverErrorPage->exists())) {
$serverErrorPage = new ErrorPage();
$serverErrorPage->ErrorCode = 500;
$serverErrorPage->Title = _t('ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error');
$serverErrorPage->Content = _t('ErrorPage.DEFAULTSERVERERRORPAGECONTENT', '<p>Sorry, there was a problem with handling your request.</p>');
$serverErrorPage->Status = 'New page';
$serverErrorPage->write();
$serverErrorPage->publish('Stage', 'Live');
DB::alteration_message('500 page created', 'created');
}
}
示例11: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!CommerceCurrency::get()->exists()) {
$gbp = new CommerceCurrency();
$gbp->Title = "UK Pounds";
$gbp->HTMLNotation = "£";
$gbp->GatewayCode = "GBP";
$gbp->write();
$gbp->flushCache();
DB::alteration_message('UK Pounds created', 'created');
$eur = new CommerceCurrency();
$eur->Title = "Euro";
$eur->HTMLNotation = "€";
$eur->GatewayCode = "EUR";
$eur->write();
$eur->flushCache();
DB::alteration_message('Euro created', 'created');
$usd = new CommerceCurrency();
$usd->Title = "US Dollars";
$usd->HTMLNotation = "$";
$usd->GatewayCode = "USD";
$usd->write();
$usd->flushCache();
DB::alteration_message('US Dollars created', 'created');
}
}
示例12: run
function run($request)
{
$db = DB::getConn();
if ($db instanceof PostgreSQLDatabase) {
$exist = DB::query("SELECT column_name FROM information_schema.columns WHERE table_name ='PickUpOrDeliveryModifier' AND column_name = 'PickupOrDeliveryType'")->numRecords();
} else {
// default is MySQL - broken for others, each database conn type supported must be checked for!
$exist = DB::query("SHOW COLUMNS FROM \"PickUpOrDeliveryModifier\" LIKE 'PickupOrDeliveryType'")->numRecords();
}
if ($exist > 0) {
$defaultOption = PickUpOrDeliveryModifierOptions::get()->filter(array("IsDefault" => 1))->First();
$modifiers = PickUpOrDeliveryModifier::get()->filter(array("OptionID" => 0));
if ($modifiers->count()) {
foreach ($modifiers as $modifier) {
if (!isset($modifier->OptionID) || !$modifier->OptionID) {
if (!isset(self::$options_old_to_new[$modifier->Code])) {
$option = PickUpOrDeliveryModifierOptions::get()->filter(array("Code" => $modifier->Code))->First();
if (!$option) {
$option = $defaultOption;
}
self::$options_old_to_new[$modifier->Code] = $option->ID;
}
$myOption = self::$options_old_to_new[$modifier->Code];
// USING QUERY TO UPDATE
DB::query("UPDATE \"PickUpOrDeliveryModifier\" SET \"OptionID\" = " . $myOption . " WHERE \"PickUpOrDeliveryModifier\".\"ID\" = " . $modifier->ID);
DB::alteration_message('Updated modifier #' . $modifier->ID . ' from code to option ID ' . $myOption, 'edited');
}
}
}
}
DB::alteration_message("<hr />COMPLETED<hr />", "created");
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-delivery,代码行数:32,代码来源:EcommerceTaskUpgradePickUpOrDeliveryModifier.php
示例13: XrequireDefaultRecords
public function XrequireDefaultRecords()
{
foreach ($this->config()->get('records') as $code => $record) {
if ($record['IsDev'] && Director::isDev() || $record['IsTest'] && Director::isTest() || $record['IsLive'] && Director::isLive()) {
if (!($discountType = StreakDiscountType::get_by_code($code))) {
$discountType = StreakDiscountType::create();
DB::alteration_message("Added discount type '{$code}'", "changed");
}
// if the record is using default code then update from config.
if ($code == self::DefaultCode) {
$record['Code'] = $this->config()->get('default_code');
} else {
$record['Code'] = $code;
}
$title = $record['Title'];
// if the record is using default title then update from config as hasn't changed, if different
// then leave alone
if ($title == self::DefaultTitle) {
$record['Title'] = $this->config()->get('default_title');
}
$data = array_diff_key($record, array_flip(array('IsDev', 'IsTest', 'IsLive')));
$discountType->update($data);
$discountType->write();
}
}
}
示例14: createSubmissionLogForArchivedOrders
protected function createSubmissionLogForArchivedOrders()
{
$lastOrderStep = OrderStep::get()->sort("Sort", "DESC")->First();
$submissionLogClassName = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
$obj = $submissionLogClassName::create();
if (!is_a($obj, Object::getCustomClass("OrderStatusLog"))) {
user_error('EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order") refers to a class that is NOT an instance of OrderStatusLog');
}
$orderStatusLogClassName = "OrderStatusLog";
$offset = 0;
$orders = $this->getOrdersForCreateSubmissionLogForArchivedOrders($lastOrderStep, $orderStatusLogClassName, $offset);
while ($orders->count()) {
foreach ($orders as $order) {
$isSubmitted = $submissionLogClassName::get()->Filter(array("OrderID" => $order->ID))->count();
if (!$isSubmitted) {
$obj = $submissionLogClassName::create();
$obj->OrderID = $order->ID;
//it is important we add this here so that we can save the 'submitted' version.
//this is particular important for the Order Item Links.
$obj->write();
$obj->OrderAsHTML = $order->ConvertToHTML();
$obj->write();
DB::alteration_message("creating submission log for Order #" . $obj->OrderID, "created");
}
}
$offset += 100;
$orders = $this->getOrdersForCreateSubmissionLogForArchivedOrders($lastOrderStep, $orderStatusLogClassName, $offset);
}
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:29,代码来源:EcommerceTaskArchiveAllOrdersWithItems.php
示例15: run
function run($request)
{
$problem = DB::query("SELECT COUNT(OrderStatusLog.ID) FROM OrderStatusLog_Submitted INNER JOIN OrderStatusLog ON OrderStatusLog_Submitted.ID = OrderStatusLog.ID WHERE OrderID = 0");
if ($problem->value()) {
DB::alteration_message("the size of the problem is: " . $problem->value(), "deleted");
} else {
DB::alteration_message("No broken links found.", "created");
}
$rows = DB::query("Select \"ID\" from \"Order\" WHERE \"StatusID\" > 1");
if ($rows) {
foreach ($rows as $row) {
$orderID = $row["ID"];
$inners = DB::query("SELECT COUNT(OrderStatusLog.ID) FROM OrderStatusLog_Submitted INNER JOIN OrderStatusLog ON OrderStatusLog_Submitted.ID = OrderStatusLog.ID WHERE OrderID = {$orderID}");
if ($inners->value() < 1) {
$sql = "\r\n\t\t\t\t\tSELECT *\r\n\t\t\t\t\tFROM OrderStatusLog_Submitted\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\"OrderAsString\" LIKE '%s:7:\"OrderID\";i:" . $orderID . "%'\r\n\t\t\t\t\t\tOR \"OrderAsHTML\" LIKE '%Order #" . $orderID . "%'\r\n\r\n\t\t\t\t\tLIMIT 1";
if ($innerInners = DB::query($sql)) {
foreach ($innerInners as $innerInnerRow) {
DB::alteration_message("FOUND " . $innerInnerRow["ID"], "created");
DB::query("UPDATE \"OrderStatusLog\" SET \"OrderID\" = {$orderID} WHERE \"OrderStatusLog\".\"ID\" = " . $innerInnerRow["ID"] . " AND \"OrderID\" < 1");
}
}
}
}
}
}