public function test_P_StandardInsert() { $stmt = new InsertStatement("INSERT INTO `{$this->actualSchema}`.`cities`\n\t\t\t(`country`, `name`, `postal_code`)\n\t\t\tVALUES (?, ?, ?)", 'isi'); $countryID = 1; $name = 'Esbjerg'; $postalCode = 6700; $stmt->bindAndExecute($values = array($countryID, $name, $postalCode)); $insertID = $this->insertInto('cities', array('country' => $countryID, 'name' => $name, 'postal_code' => $postalCode)); $this->assertTablesEqual('cities'); $this->assertEquals($insertID, $stmt->insertID); }
public function bindAndExecute(array $values) { parent::bindAndExecute($values); if ($this->assertAffectedRows !== null) { if ($this->rows < $this->assertAffectedRows) { throw new TooFewAffectedRowsException("Failed asserting that exactly {$this->assertAffectedRows} rows were affected. The statement affected {$this->rows} rows."); } if ($this->rows > $this->assertAffectedRows) { throw new TooManyAffectedRowsException("Failed asserting that exactly {$this->assertAffectedRows} rows were affected. The statement affected {$this->rows} rows."); } } }