public function testInsert()
 {
     $dialect = PostgresDialect::me();
     $query = OSQL::insert()->into('test_table')->set('field2', 2)->set('field16', 3);
     $this->addReturning($query);
     $this->assertEquals($query->toDialectString($dialect), 'INSERT INTO "test_table" ("field2", "field16") ' . 'VALUES (\'2\', \'3\') ' . 'RETURNING ' . '"test_table"."field1" AS "alias1", ' . '"test_table"."field2", ' . 'count("test_table"."field5") AS "alias5", ' . '(SELECT "test_table1"."id" FROM "test_table1") AS "foo1"');
 }
 public function testInsertFromSelect()
 {
     $dialect = $this->getDbByType('PgSQL')->getDialect();
     $select = OSQL::select()->from('test_table2')->get('field3')->get('field_7')->andWhere(Expression::gt('field2', DBValue::create('33')));
     $insert = OSQL::insert()->setSelect($select)->into('test_table')->set('field2', 2)->set('field16', 3);
     $this->assertEquals($insert->toDialectString($dialect), 'INSERT INTO "test_table" ("field2", "field16") (' . 'SELECT "test_table2"."field3", "test_table2"."field_7" ' . 'FROM "test_table2" WHERE ("field2" > \'33\')' . ')');
 }
 /**
  * @return InsertQuery
  **/
 protected function makeInsertQuery($childId)
 {
     $uc = $this->container;
     return OSQL::insert()->into($uc->getHelperTable())->set($uc->getParentIdField(), $uc->getParentObject()->getId())->set($uc->getChildIdField(), $childId);
 }
 public function testFullInsertQueryByCity()
 {
     $city = $this->spawnCity();
     $insertCity = $city->proto()->fillQuery(OSQL::insert(), $city);
     $this->assertEquals('INSERT INTO  (id, name, capital, large) VALUES (20, Saint-Peterburg, TRUE, TRUE)', $insertCity->toDialectString(ImaginaryDialect::me()));
 }
Ejemplo n.º 5
0
 public function import(Identifiable $object)
 {
     return $this->inject(OSQL::insert(), $object);
 }