示例#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
 }
示例#2
0
文件: Query.php 项目: rrelmy/rorm
 /**
  * @param string $class
  * @param PDO|null $dbh if null the default database connection is used
  */
 public function __construct($class = 'stdClass', PDO $dbh = null)
 {
     $this->class = $class;
     $this->classIsOrmModel = is_subclass_of($this->class, '\\Rorm\\Model');
     $this->dbh = $dbh ? $dbh : Rorm::getDatabase();
 }
示例#3
0
 /**
  * @depends testModels
  */
 public function testQuoteIdentifier()
 {
     $quoter = Rorm::getIdentifierQuoter(Rorm::getDatabase('sqlite'));
     $this->assertEquals('"sqlite"', $quoter('sqlite'));
 }
示例#4
0
文件: Model.php 项目: rrelmy/rorm
 /**
  * @return \PDO
  */
 public static function getDatabase()
 {
     return Rorm::getDatabase(static::$_connection);
 }
示例#5
0
文件: RormTest.php 项目: rrelmy/rorm
 /**
  * @param $value
  * @param $expected
  *
  * @dataProvider providerQuoteIdentifier
  * @fixme this test requires the sqlite connection
  */
 public function testQuoteIdentifier($value, $expected)
 {
     $quoter = Rorm::getIdentifierQuoter(Rorm::getDatabase('sqlite'));
     $this->assertEquals($expected, $quoter($value));
 }