예제 #1
0
 /**
  * @param string $table
  * @param string|array $idColumn
  * @param string $class
  * @param \PDO|null $dbh
  */
 public function __construct($table, $idColumn, $class = 'stdClass', PDO $dbh = null)
 {
     parent::__construct($class, $dbh);
     $this->table = $table;
     $this->idColumn = is_array($idColumn) ? $idColumn : array($idColumn);
     $this->quoteIdentifier = Rorm::getIdentifierQuoter($this->dbh);
 }
예제 #2
0
파일: SQLiteTest.php 프로젝트: rrelmy/rorm
 /**
  * @depends testModels
  */
 public function testQuoteIdentifier()
 {
     $quoter = Rorm::getIdentifierQuoter(Rorm::getDatabase('sqlite'));
     $this->assertEquals('"sqlite"', $quoter('sqlite'));
 }
예제 #3
0
파일: Model.php 프로젝트: rrelmy/rorm
 /**
  * @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;
 }
예제 #4
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));
 }