开发者

My database doesn't insert immediately

I am a trying to apply Test Driven Development to producing a web page and am having trouble using my database. I am developing using Cake 1.1, PHP5 and SimpleTest to unit test.

My problem is that I have a test that:

  1. Inserts a row using a direct SQL statement
  2. Tests if that row was inserted (by using a function in my main program.)
  3. Deletes the row that was inserted.

Both steps 1 and 3 work fine but step 2 fails.

It's important to realize that if I run the test without deleting the row (I commented that out) and then ran the test again but first eliminating step 1 (once again simply commenting that line) and the test passed without a problem.

I 开发者_开发问答also tried running the SQL statements directly (one after another in the editor) in PHPMyAdmin and they work perfectly.


Are all steps executed in the same transaction?

When not, step 2 isn't able to see the result of step 1 until step 1 commits.


It does sound like your insert is happening inside a transaction that has not yet been committed when you attempt the test.

Can you give some sample code?


Are you sure you are committing the transaction in step 1?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜