/**
  * http://pear.php.net/bugs/bug.php?id=946
  */
 function testBug946()
 {
     $data = array();
     $total_rows = 5;
     $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $this->types);
     for ($row = 0; $row < $total_rows; $row++) {
         $data[$row]['user_name'] = "user_{$row}";
         $data[$row]['user_password'] = '******';
         $data[$row]['subscribed'] = (bool) ($row % 2);
         $data[$row]['user_id'] = $row;
         $data[$row]['quota'] = sprintf("%.2f", strval(1 + ($row + 1) / 100));
         $data[$row]['weight'] = sqrt($row);
         $data[$row]['access_date'] = MDB_Date::mdbToday();
         $data[$row]['access_time'] = MDB_Date::mdbTime();
         $data[$row]['approved'] = MDB_Date::mdbNow();
         $this->insertTestValues($prepared_query, $data[$row]);
         $result = $this->db->executeQuery($prepared_query);
         if (MDB::isError($result)) {
             $this->assertTrue(false, 'Error executing prepared query' . $result->getMessage());
         }
     }
     $this->db->freePreparedQuery($prepared_query);
     $result = $this->db->limitQuery('SELECT * FROM users', null, 1, 3);
     $numrows = $this->db->numRows($result);
     while ($row = $this->db->fetchInto($result)) {
         if (MDB::isError($row)) {
             $this->assertTrue(false, 'Error fetching a row' . $row->getMessage());
         }
     }
     $this->db->freeResult($result);
     $result = $this->db->query('SELECT * FROM users');
     $numrows = $this->db->numRows($result);
     while ($row = $this->db->fetchInto($result)) {
         if (MDB::isError($row)) {
             $this->assertTrue(false, 'Error fetching a row with limit' . $row->getMessage());
         }
     }
     $this->db->freeResult($result);
 }
 /**
  * Testing transaction support
  */
 function testTransactions()
 {
     if (!$this->supported('Transactions')) {
         return;
     }
     $this->db->autoCommit(0);
     $row = 0;
     $data = array();
     $data['user_name'] = "user_{$row}";
     $data['user_password'] = '******';
     $data['subscribed'] = (bool) ($row % 2);
     $data['user_id'] = $row;
     $data['quota'] = strval($row / 100);
     $data['weight'] = sqrt($row);
     $data['access_date'] = MDB_Date::mdbToday();
     $data['access_time'] = MDB_Date::mdbTime();
     $data['approved'] = MDB_Date::mdbNow();
     $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $this->types);
     $this->insertTestValues($prepared_query, $data);
     $result = $this->db->executeQuery($prepared_query);
     $this->db->rollback();
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue($this->db->endOfResult($result), 'Transaction rollback did not revert the row that was inserted');
     $this->db->freeResult($result);
     $this->insertTestValues($prepared_query, $data);
     $result = $this->db->executeQuery($prepared_query);
     $this->db->commit();
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue(!$this->db->endOfResult($result), 'Transaction commit did not make permanent the row that was inserted');
     $this->db->freeResult($result);
     $result = $this->db->query('DELETE FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error deleting from users' . $result->getMessage());
         $this->db->rollback();
     }
     $autocommit = $this->db->autocommit(1);
     $this->assertTrue(!MDB::isError($autocommit), 'Error autocommiting transactions');
     $this->db->freePreparedQuery($prepared_query);
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue($this->db->endOfResult($result), 'Transaction end with implicit commit when re-enabling auto-commit did not make permanent the rows that were deleted');
     $this->db->freeResult($result);
 }
function MetabaseToday()
{
    return MDB_Date::mdbToday();
}