Exemplo n.º 1
0
 public function testMakePlaceholders()
 {
     $this->assertEquals(['keys' => 'username, email', 'values' => '?, ?', 'data' => ['example', '*****@*****.**'], 'array' => []], DfSql::makePlaceholders(['username' => 'example', 'email' => '*****@*****.**']));
     $this->assertEquals(['keys' => 'username, email', 'values' => ':username, :email', 'data' => [':username' => 'example', ':email' => '*****@*****.**'], 'array' => ['username = :username', 'email = :email']], DfSql::makePlaceholders(['username' => 'example', 'email' => '*****@*****.**'], false));
 }
Exemplo n.º 2
0
 /**
  * Return current date for log record
  * @return string
  */
 private function getLogDate()
 {
     return DfSql::datetime();
 }
Exemplo n.º 3
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);
 }