public function testPGetall() { $rs = $this->db->PGetAll('SELECT * FROM Country WHERE Continent = ?', 'North America'); $this->assertEquals(37, count($rs)); $this->assertEquals('Mexico', $rs['23'][1]); $this->assertEquals('414972.00', $rs['23']['GNP']); }
$timer = new MPLT(); require_once '../../src/dalmp.php'; # ------------------------------------------------------------------------------ $user = getenv('MYSQL_USER') ?: 'root'; $password = getenv('MYSQL_PASS') ?: ''; $host = getenv('MYSQL_HOST') ?: '127.0.0.1'; $port = getenv('MYSQL_PORT') ?: '3306'; $db = new DALMP\Database("utf8://{$user}:{$password}@{$host}:{$port}/dalmp"); /** * load zone files to mysql * mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql */ $db->PExecute('SET time_zone=?', '+00:00'); $db->FetchMode('ASSOC'); $sql = 'SELECT Name, Continent FROM Country WHERE Population > ? AND Code LIKE ? LIMIT ?'; $rs = $db->PGetAll($sql, 10000000, '%P%', 2); print_r($rs); $rs = $db->Execute('DROP TABLE IF EXISTS `tests`'); $rs = $db->Execute('CREATE TABLE `tests` (id INT(11) unsigned NOT NULL AUTO_INCREMENT, col1 varchar(255), col2 varchar(255), col3 varchar(255), status iNT(1), PRIMARY KEY (id))'); $rs = $db->AutoExecute('tests', array('col1' => 'ai eu', 'col2' => 2, 'status' => 0)); /** * status value is 0 or 1 on table * NOTICE the use of === */ $sql = 'SELECT status FROM tests WHERE id=?'; $rs = $db->PgetOne($sql, 3); if ($rs === false) { echo "no result" . $timer->isCli(1); } elseif ($rs == 0) { echo "{$rs} = 0" . $timer->isCli(1); } else {