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)); }
/** * Return current date for log record * @return string */ private function getLogDate() { return DfSql::datetime(); }
/** * 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); }