1

我不断遇到 PDO 的这个问题,在我的测试中出现了这个错误。

<?php

require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');
require_once('../model.php');

class TestOfCallMapper extends UnitTestCase {
 function testOfReturnsAll() {
 }

 function setUp() {
  R::setup("mysql:host=localhost;dbname=poo", root, '');
  $this->destroySchema();
  $this->createSchema();
 }

 function tearDown() {
  $this->destroySchema();
 }

 private function createSchema() {
  R::exec(file_get_contents('../database/create_schema.sql'));
 }

 private function destroySchema() {
  R::exec(file_get_contents('../database/destroy_schema.sql'));
 }

}

$test = new TestOfCallMapper('Test of CallMapper Methods');
$test->run(new HTMLReporter());

我很确定发生的事情是我的 create_schema 文件中的内容继续执行并阻止其他查询运行,因为它告诉我查询没有缓冲。我不再使用 PDO,因为这对我来说没有意义,并开始使用称为 Redbean 的不同 ORM。不幸的是,我又遇到了这个恼人的错误,而且我似乎无法修复它,因为显然 Redbean 位于 PDO 之上。当我使用 PDO 时,我尝试设置打开缓冲查询的选项,但它不起作用。在我的测试之外,该方法似乎工作正常,但我不确定这是否可以接受。

4

1 回答 1

0

当我切换到新服务器时,这会自行解决。我从来没有发现问题。

于 2011-02-17T22:45:33.017 回答