Example #1
0
 public function testSelectValues()
 {
     $data = [['test1' => 'Linha1 test1', 'test2' => 'Linha1 test2'], ['test1' => 'Linha2 test1', 'test2' => 'Linha2 test2']];
     $phlatdb = new Phlatdb(new JsonLineEncoder());
     $inserted_ids = $phlatdb->table("testdb")->insert($data)->save();
     $res = $phlatdb->select('test1', 'test2')->find($inserted_ids[0]);
     $this->assertEquals(array('test1' => 'Linha1 test1', 'test2' => 'Linha1 test2'), $res);
 }
Example #2
0
 /**
  * Insert a new record and get the value of the primary key.
  *
  * @param  array   $values
  * @param  string  $sequence
  * @return int
  */
 public function insertGetId(array $values, $sequence = null)
 {
     if (empty($values)) {
         return true;
     }
     $phlatdb = new Phlatdb(new JsonLineEncoder());
     $keys = $phlatdb->table($this->from)->insert($values)->save();
     if (!empty($keys)) {
         return $keys[0];
     }
     return null;
 }