static function clearDatabase() { $con = DatabaseHelper::getConnection(); $con->query('DELETE From Ride'); $con->query('DELETE From Contacts'); $con->query('UPDATE ShowInterestNotifier SET LastRun = 0'); }
public function testGetRegionConfigration() { DatabaseHelper::getConnection()->query('DELETE FROM Regions'); $this->dbh->insert('Regions', array('Name' => 'Region1', 'Abbrev' => 'rg1', 'DefaultSrcCityId' => 1, 'DefaultSrcLocation' => 'DefaultSrc1')); $id = DatabaseHelper::getConnection()->lastInsertId(); $conf = $this->dbh->getRegionConfiguration($id); $this->assertNotNull($conf); $this->assertEquals(1, $conf['DefaultSrcCityId']); $this->assertEquals('DefaultSrc1', $conf['DefaultSrcLocation']); $this->assertNull($conf['DefaultDestLocation']); $this->dbh->insert('Regions', array('Name' => 'Region2', 'Abbrev' => 'rg2', 'DefaultSrcCityId' => 71, 'DefaultSrcLocation' => 'DefaultSrc2', 'DefaultDestCityId' => 70, 'DefaultDestLocation' => 'DefaultDest2')); $id = DatabaseHelper::getConnection()->lastInsertId(); $conf = $this->dbh->getRegionConfiguration($id); $this->assertNotNull($conf); $this->assertEquals(71, $conf['DefaultSrcCityId']); $this->assertEquals('DefaultSrc2', $conf['DefaultSrcLocation']); $this->assertEquals(70, $conf['DefaultDestCityId']); $this->assertEquals('DefaultDest2', $conf['DefaultDestLocation']); }
function contactsCount() { $dbCon = DatabaseHelper::getConnection(); return $dbCon->query('SELECT COUNT(*) AS Cnt FROM Contacts', PDO::FETCH_COLUMN, 0)->fetch(); }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Dump</title> </head> <body><?php // Just dump the contents of the ride and the contact tables include '../public/env.php'; include APP_PATH . '/Bootstrap.php'; $db = DatabaseHelper::getConnection(); $rs = $db->query('SELECT * FROM Ride'); $res = $rs->fetchAll(PDO::FETCH_ASSOC); echo '<h1>Rides</h1>'; foreach ($res as $ride) { var_dump($ride); } $rs = $db->query('SELECT * FROM Contacts'); $res = $rs->fetchAll(PDO::FETCH_ASSOC); echo '<h1>Contacts</h1>'; foreach ($res as $contact) { var_dump($contact); } echo '<h1>ShowInterestNotifier</h1>'; $rs = $db->query('SELECT * FROM ShowInterestNotifier'); $res = $rs->fetchAll(PDO::FETCH_ASSOC); var_dump($res); ?> </body></html>