コード例 #1
0
 public function testUpdateRecordByIdCanBeDone()
 {
     $object = DbQuerries::updateById("cars", 1, ['color' => 'turqoise', 'price' => '$1 million']);
     $this->assertEquals(1, $object);
 }
コード例 #2
0
 /** 
  * A method to save data to database
  *
  * Used when inserting or updating a record.
  * It checks if the id exists, if it does then it updates a record otherwise
  * it inserts.
  */
 public function save()
 {
     try {
         if ($this->id) {
             $result = DbQuerries::updateById(static::$table, $this->id, $this->properties);
         } else {
             $result = DbQuerries::insertInTable(static::$table, $this->properties);
         }
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }