private function dumpPeopleTable()
 {
     $allRows = CW_MySQL::getInstance()->query('SELECT * FROM people');
     $isFirstRow = true;
     $row = $allRows->fetch_assoc();
     do {
         if ($isFirstRow) {
             foreach ($row as $columnName => $columnValue) {
                 printf(self::ROW_FORMAT, $columnName);
                 echo ' ';
             }
             echo "\n";
         }
         foreach ($row as $columnName => $columnValue) {
             printf(self::ROW_FORMAT, $columnValue);
         }
         echo "\n";
     } while ($row = $allRows->fetch_assoc());
 }
Пример #2
0
 public function testLastInsertId()
 {
     CW_MySQL::getInstance()->insert('people', array('firstname' => 'testLastInsertId', 'lastname' => 'User', 'age' => 50, 'createdDate' => time()));
     $lastInsertId = CW_MySQL::getInstance()->getLastInsertId();
     //$lastInsertOnly = CW_MySQL::getInstance()->select('people', array('firstname' => 'testLastInsertId'));
     $results = CW_MySQL::getInstance()->query('SELECT id, firstname FROM people WHERE id=' . $lastInsertId);
     $this->assertEquals(1, $results->num_rows, 'No row found by ID ' . $lastInsertId);
     $singleRow = $results->fetch_object();
     $this->assertEquals($singleRow->id, $lastInsertId, 'Insert ID from class does not match actual from database.');
     $this->assertEquals('testLastInsertId', $singleRow->firstname, 'Inserted name does not match row retrieved via inserted ID');
 }