Example #1
0
 /**
  * Update Request
  * @param array $set
  * @param array $where
  * @return bool
  */
 public function update($set, $where = [])
 {
     $setData = implode(', ', DfSql::makePlaceholders($set, false)['array']);
     $sql = "UPDATE {$this->table} SET {$setData}";
     $sqlData = DfSql::makePlaceholders($set, false)['data'];
     if (!empty($where)) {
         $whereData = implode(', ', DfSql::makePlaceholders($where, false)['array']);
         $sqlData = array_merge($sqlData, DfSql::makePlaceholders($where, false)['data']);
         $sql .= " WHERE {$whereData}";
     }
     return $this->db->queryWithRowOneCheck($sql, $sqlData);
 }
Example #2
0
 /**
  * @param DfDbConnection $db
  */
 public function check($db)
 {
     $this->assertEquals(['id' => 1, 'username' => 'test', 'email' => '*****@*****.**'], $db->getRecordByQuery("SELECT * FROM users WHERE id = :id", [':id' => 1]));
     $this->assertEquals([['id' => 1, 'username' => 'test', 'email' => '*****@*****.**']], $db->getRecordsByQuery("SELECT * FROM users WHERE id = :id", [':id' => 1]));
 }