Example #1
0
 /**
  * @depends testDbDriver
  */
 public function testQuote()
 {
     $dbh = Rorm::getDatabase();
     $this->assertEquals('TRUE', Rorm::quote($dbh, true));
     $this->assertEquals('FALSE', Rorm::quote($dbh, false));
     $this->assertEquals('NULL', Rorm::quote($dbh, null));
     $this->assertEquals(17, Rorm::quote($dbh, 17));
     $this->assertEquals(28.75, Rorm::quote($dbh, 28.75));
     $this->assertInternalType('integer', Rorm::quote($dbh, 10));
     $this->assertInternalType('float', Rorm::quote($dbh, 10.6));
     $this->assertEquals("'lorem'", Rorm::quote($dbh, 'lorem'));
     // todo test object with __toString
 }
Example #2
0
 public function testQuote()
 {
     $dbh = Rorm::getDatabase('sqlite');
     $this->assertEquals(1, Rorm::quote($dbh, true));
     $this->assertEquals(0, Rorm::quote($dbh, false));
 }
Example #3
0
 /**
  * @return bool
  */
 public function delete()
 {
     $dbh = static::getDatabase();
     $quoteIdentifier = Rorm::getIdentifierQuoter($dbh);
     $idColumns = static::$_idColumn;
     if (!is_array($idColumns)) {
         $idColumns = array($idColumns);
     }
     $where = array();
     foreach ($idColumns as $columnName) {
         $where[] = $quoteIdentifier($columnName) . ' = ' . Rorm::quote($dbh, $this->{$columnName});
     }
     $sql = 'DELETE FROM ' . $quoteIdentifier(static::getTable()) . ' WHERE ' . implode(' AND ', $where);
     return $dbh->exec($sql) > 0;
 }