灯角

文章 0 评论 0 浏览 23

灯角 2024-11-25 22:52:20

新闻快报:在 mysql 中,每次更新行中的任何其他列时,TIMESTAMP 列总是使用 now() 进行更新 - 这是一个这种数据类型的特意特征。

另一方面,DATETIME 没有这种奇怪的行为 - 这是完全正常的。

答案:创建必须是DATETIME,但由于这个bug,你还需要一个触发器,像这样:

CREATE TABLE IF NOT EXISTS mytable (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `updated` TIMESTAMP, -- This will be updated to now(), if you don't set it or set it to null
  `created` DATETIME NOT NULL, -- This will never be magically updated once written
  `deleted` TINYINT DEFAULT 0,
  `notes` TEXT DEFAULT '',
  `description` VARCHAR(100)
) TYPE=innodb;

DELIMITER ~
CREATE TRIGGER mytable_insert_trigger
BEFORE INSERT ON mytable
FOR EACH ROW BEGIN
    SET NEW.created = CURRENT_TIMESTAMP;
END;~
DELIMITER ;

insert into mytable (notes) values ('test');
select * from mytable;
+----+---------------------+---------------------+---------+-------+-------------+
| id | updated             | created             | deleted | notes | description |
+----+---------------------+---------------------+---------+-------+-------------+
|  1 | 2011-07-05 11:48:02 | 2011-07-05 11:48:02 |       0 | test  | NULL        |
+----+---------------------+---------------------+---------+-------+-------------+

News flash: In mysql, TIMESTAMP columns are always updated with now() every time any other column in the row is updated - this is a deliberate feature of this datatype.

DATETIME on the other hand does not have this weird behaviour - it's completely normal.

The answer: created must be DATETIME, but due to this bug, you also need a trigger, like this:

CREATE TABLE IF NOT EXISTS mytable (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `updated` TIMESTAMP, -- This will be updated to now(), if you don't set it or set it to null
  `created` DATETIME NOT NULL, -- This will never be magically updated once written
  `deleted` TINYINT DEFAULT 0,
  `notes` TEXT DEFAULT '',
  `description` VARCHAR(100)
) TYPE=innodb;

DELIMITER ~
CREATE TRIGGER mytable_insert_trigger
BEFORE INSERT ON mytable
FOR EACH ROW BEGIN
    SET NEW.created = CURRENT_TIMESTAMP;
END;~
DELIMITER ;

insert into mytable (notes) values ('test');
select * from mytable;
+----+---------------------+---------------------+---------+-------+-------------+
| id | updated             | created             | deleted | notes | description |
+----+---------------------+---------------------+---------+-------+-------------+
|  1 | 2011-07-05 11:48:02 | 2011-07-05 11:48:02 |       0 | test  | NULL        |
+----+---------------------+---------------------+---------+-------+-------------+

一张表中的两个 MySQL 时间戳列

灯角 2024-11-25 21:10:08

http://www.pygtk.org/ 中找到了一个执行此操作的示例pygtk2tutorial/sec-ManualMenuExample.html

它向您展示了如何创建一个菜单,将其附加到菜单栏,并侦听鼠标按钮单击事件并弹出与创建的菜单完全相同的菜单。

我想这就是你所追求的。

编辑:(添加了进一步的解释以显示如何仅响应鼠标右键事件)

总结一下。

创建一个小部件来监听鼠标事件。在本例中它是一个按钮。

button = gtk.Button("A Button")

创建一个菜单

menu = gtk.Menu()

用菜单项填充它

menu_item = gtk.MenuItem("A menu item")
menu.append(menu_item)
menu_item.show()

让小部件侦听鼠标按下事件,并将菜单附加到它。

button.connect_object("event", self.button_press, menu)

然后定义处理这些事件的方法。正如链接中的示例所述,传递给此方法的小部件是您想要弹出的菜单,而不是正在侦听这些事件的小部件。

def button_press(self, widget, event):
    if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
        #make widget popup
        widget.popup(None, None, None, event.button, event.time)
        pass

您将看到 if 语句检查是否按下了按钮,如果是的话,它将检查按下了哪个按钮。 event.button 是一个整数值,表示按下了哪个鼠标按钮。所以1是左键,2是中键,3是鼠标右键。通过检查 event.button 是否为 3,您仅响应鼠标右键的鼠标按下事件。

There is a example for doing this very thing found at http://www.pygtk.org/pygtk2tutorial/sec-ManualMenuExample.html

It shows you how to create a menu attach it to a menu bar and also listen for a mouse button click event and popup the very same menu that was created.

I think this is what you are after.

EDIT: (added further explanation to show how to respond to only right mouse button events)

To summarise.

Create a widget to listen for mouse events on. In this case it's a button.

button = gtk.Button("A Button")

Create a menu

menu = gtk.Menu()

Fill it with menu items

menu_item = gtk.MenuItem("A menu item")
menu.append(menu_item)
menu_item.show()

Make the widget listen for mouse press events, attaching the menu to it.

button.connect_object("event", self.button_press, menu)

Then define the method which handles these events. As is stated in the example in the link, the widget passed to this method is the menu that you want popping up not the widget that is listening for these events.

def button_press(self, widget, event):
    if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
        #make widget popup
        widget.popup(None, None, None, event.button, event.time)
        pass

You will see that the if statement checks to see if the button was pressed, if that is true it will then check to see which of the buttons was pressed. The event.button is a integer value, representing which mouse button was pressed. So 1 is the left button, 2 is the middle and 3 is the right mouse button. By checking to see if the event.button is 3, you are only responding to mouse press events for the right mouse button.

使用 PyGTK 的右键菜单(上下文菜单)

灯角 2024-11-25 20:09:45

尝试将标题更改为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Try changing your header to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

CSS - IE 中的圆角 - IE9

灯角 2024-11-25 14:18:59

尝试更改

devise_for :users, controllers: { invitations: 'users/invitations' }

devise_for :users, controllers: { invitations: 'devise/invitations' }

Try changing

devise_for :users, controllers: { invitations: 'users/invitations' }

to

devise_for :users, controllers: { invitations: 'devise/invitations' }

Devise Invitable:未初始化常量

灯角 2024-11-25 05:32:50

而不是这个

<link rel="stylesheet" href="style.css">

尝试这个:

<link rel="stylesheet" href="<?php echo base_url();?>"> 

或者如果你的 css 位于一个名为 css 的目录中:

<link rel="stylesheet" href="<?php echo base_url();?>css/style.css"> 

你的 Javascript 将以同样的方式工作

Instead of this

<link rel="stylesheet" href="style.css">

Try this:

<link rel="stylesheet" href="<?php echo base_url();?>"> 

Or if you have your css in a directory called css:

<link rel="stylesheet" href="<?php echo base_url();?>css/style.css"> 

Your Javascript will work the same way

PHP 代码点火器 CSS

灯角 2024-11-25 04:29:09

好吧,您根本没有给我们任何数据格式的线索。
因此,根据我在你的问题中看到的内容,只有 6 行数据,我建议:

{rows:{row1:'@Scsi_test',row2:'(iotest)',row3:'scsi',row4:'dkdkdkdkdkdkddk',row5:'dkdkdkdkdkdkddk',row6:'dkdkdkdkdkdkddk'}}

Well, you haven't given us any clues at all what the data format is.
So based on what I see in your question, just 6 rows of data, I would suggest:

{rows:{row1:'@Scsi_test',row2:'(iotest)',row3:'scsi',row4:'dkdkdkdkdkdkddk',row5:'dkdkdkdkdkdkddk',row6:'dkdkdkdkdkdkddk'}}

有关如何将此数据格式转换为 JSON 的示例?

灯角 2024-11-24 20:38:16

也许资源管理器启动可执行文件的方式与直接从控制台运行它的方式有所不同。我认为资源管理器使用 ShellExecuteShellExecuteEx 我怀疑从控制台或批处理文件执行应用程序会产生相同的效果。

我将创建一个测试应用程序,尝试一些 ShellExecute 变体并使用不同的参数来查看是否可以重现资源管理器行为,以便尝试诊断传递给 ShellExecute 的哪些参数可能会导致问题。

ShellExecuteEx 页面上有一个有趣的社区注释,可能适用,也可能不适用:
ShellExecuteEx 忽略当前输入桌面。它始终使用winsta0\default。相反,请使用 ShellExecute 或 CreateProcess。

我还会调查 AppCompatFlags 是否影响控制台执行应用程序(或查看是否已为您的应用程序设置了任何 AppCompatFlags)。

Perhaps there is a difference caused by the way Explorer launches an executable vs directly running it from the console. I think that Explorer uses ShellExecute or ShellExecuteEx and I doubt that executing an application from a console or batch file does the same.

I would create a test app that tries some of the ShellExecute variants and use different parameters to see if the Explorer behavior can be reproduced in order to try to diagnose what parameters passed to ShellExecute might be causing the problem.

There is an interesting community note on the ShellExecuteEx page that may or may not be applicable:
ShellExecuteEx ignores the current input desktop. It always uses winsta0\default. Instead use ShellExecute or CreateProcess.

I would also investigate whether or not AppCompatFlags affect console executed applications (or see if any AppCompatFlags have been set for your application).

从 Windows 命令提示符运行可执行文件与从 Windows 资源管理器运行可执行文件有何区别?

灯角 2024-11-24 18:09:09

这里你不需要使用linq,你可以用逻辑来完成

现在只需获取Num_Subjects就像unit1 = 6

DataTable dt = [whole_table];

int counter = Num_Subjects + 1; //7

string colName = "P" + counter.ToString(); //P7

while(dt.Columns.Contains(colName))
{
   dt.Columns.Remove(colName);
   colName = "P" + (++counter).ToString()
}

最后你我们得到一个表最多P6列其余的列将被删除。

Here you don't need to use linq, you can do it with logic

Now just get Num_Subjects like for unit1 = 6

DataTable dt = [whole_table];

int counter = Num_Subjects + 1; //7

string colName = "P" + counter.ToString(); //P7

while(dt.Columns.Contains(colName))
{
   dt.Columns.Remove(colName);
   colName = "P" + (++counter).ToString()
}

At last you we get a table upto P6 columns rest of columns will be deleted.

使用 linq to sql 动态选择列(数量)

灯角 2024-11-24 15:30:02

我认为您可能正在开发一个控制台项目并尝试制作一个 Windows 应用程序!
如果是这样,请从file->new中选择一个新的win32项目,然后重新编写该代码。
您将得到以下输出:

在此处输入图像描述

I think you might be working on a console project and trying to make a windows application !
If it is so,select a new win32 project from file->new and then re-write that code.
You will have this as output:

enter image description here

致命错误 LNK1120:1 个未解析的外部

灯角 2024-11-24 13:37:47

Rails 对待连接表的方式与您想象的有些不同。从 DBA 的角度来看,您的联接表完全没问题,但对于 Rails 来说,真正的联接表只有引用列。一旦添加新列,Rails 就会将连接表视为新实体。

(就我个人而言,一开始我对此感到沮丧,但我很快就意识到这没什么大不了的)

因此,要解决您的问题,您需要重命名您的表,比方说 FinanceBalances。另外,让我们将FinishedBalance 更改为amount。

然后,在您的 Sale.rb 文件中进行如下所示的关联:

has_many :financeBalances
has_many :financeCompanies, :through => :financeBalances

对 FinanceCompany 执行相同的操作。

您的代码将如下所示:

<% for financeBalance in sale.financeBalances %>
  <%= "£" + financeBalance.amount + " from " %>
  <%= financeBalance.financeCompany.name %>
<% end %>

如果您确实希望 financeCompany.financedBalance 正常工作,您可以在 FinanceCompany 模型中定义一个方法并编写返回您想要的查询。

Rails treats join tables a bit differently than you might think. From a DBA perspective, your join table is perfectly fine but for Rails true join tables have only referential columns. As soon as you add a new column, Rails likes to treat the join table as a new entity.

(On a personal note, I was frustrated by this at first but I quickly learned it's not a big deal)

So, to fix your problem, you'll need to rename your table, let's say FinanceBalances. Also, let's change financedBalance to amount.

Then, in your Sale.rb file put you associations like so:

has_many :financeBalances
has_many :financeCompanies, :through => :financeBalances

Do the same for FinanceCompany.

And your code will look like:

<% for financeBalance in sale.financeBalances %>
  <%= "£" + financeBalance.amount + " from " %>
  <%= financeBalance.financeCompany.name %>
<% end %>

If you really really want financeCompany.financedBalance to work, you can define a method in your financeCompany model and write the query that returns what you want.

具有第三列的 Rails 分配表

灯角 2024-11-24 12:43:18

如果您的表具有唯一的主键(...将取决于设计...),那么这是需要计算条目出现次数的可行替代方案:

DELETE FROM people as A
WHERE deleted = 1
AND EXISTS (SELECT '1'
            FROM people as B
            WHERE B.id <> A.id
            AND A.firstName = B.firstName
            AND A.lastName = B.lastName)

这可能比计算行具有稍好的性能。请注意,此查询可能会遇到与上一个答案中存在的相同问题;具体来说,如果有两个或多个“已删除”行,并且没有“未删除”行,则它们都可能会被删除(留下任何行!)。如果查询的目的只是在存在“未删除”等效行时删除“已删除”行,请添加 AND B.deleted = 0 作为内部 WHERE< 的一部分/代码> 子句。

If your table has a unique primary key (... will depend on design...), then this is a viable alternative to needing to count the occurrances of entries:

DELETE FROM people as A
WHERE deleted = 1
AND EXISTS (SELECT '1'
            FROM people as B
            WHERE B.id <> A.id
            AND A.firstName = B.firstName
            AND A.lastName = B.lastName)

This may have slightly better performance than counting rows. Please note that this query will likely suffer the same possible issue present in the previous answer; specifically, if there are two or more 'deleted' rows, and no 'non-deleted', both of them will probably be removed (leaving you with no rows!). If the intent of the query is only to remove 'deleted' rows when there is a 'non-deleted' equivalent row, add AND B.deleted = 0 as part of the inner WHERE clause.

MySQL 带条件的 DELETE 查询

灯角 2024-11-24 09:02:32

如果它是 Air 应用程序,则有应用程序配置文件 yourapp-app.xml

标题部分的某个位置定义了 Flex 框架版本。只需将其更新到至少 10.2.0.0

If it is an Air App there is the APP Configuration file yourapp-app.xml

Somewhere in the headsection is the flex framework ersion defined. Simply Update it to at least 10.2.0.0

Flash Builder 4.5 目标播放器

灯角 2024-11-24 08:58:34

尝试将父容器和同级容器位置设置为相对位置。
它以前对我有用。

Try setting the parent and siblings containers position to relative.
Its worked for me before.

Z-index:如何使嵌套元素出现在其父元素下方

灯角 2024-11-24 07:30:52

不,但你可以这样做:

    enum E {
        e1,e2
    }
    interface I{
        Enum getEnum();
    }
 interface I2 {
    EnumSet getEnums();
}
class I2Impl implements I2 {
    @Override public EnumSet getEnums() {
        return EnumSet.allOf(E.class);
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println(new IImpl().getEnum());
        System.out.println(new I2Impl().getEnums());
    }
}

no, but you can do something like:

    enum E {
        e1,e2
    }
    interface I{
        Enum getEnum();
    }
 interface I2 {
    EnumSet getEnums();
}
class I2Impl implements I2 {
    @Override public EnumSet getEnums() {
        return EnumSet.allOf(E.class);
    }
}
public class Main {
    public static void main(String[] args) {
        System.out.println(new IImpl().getEnum());
        System.out.println(new I2Impl().getEnums());
    }
}

接口可以要求类定义内部枚举吗?

灯角 2024-11-24 04:03:44

确保当视图(重新)出现时,您将其设置为第一响应者。

-(void)viewDidAppear:(BOOL)animated
{
 [self becomeFirstResponder];
}

它需要位于 viewDidAppear 而不是 viewWillAppear 中

Make sure when the view (re)appears that you set it as the first responder.

-(void)viewDidAppear:(BOOL)animated
{
 [self becomeFirstResponder];
}

It needs to be in viewDidAppear and not viewWillAppear

MotionEnded 未被连续调用

更多

推荐作者

束缚m

文章 0 评论 0

alipaysp_VP2a8Q4rgx

文章 0 评论 0

α

文章 0 评论 0

一口甜

文章 0 评论 0

厌味

文章 0 评论 0

转身泪倾城

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文