/** * Get employer data from ventus_career_fair_employers table * @param array $map a map of key value pairs to identify the employer with * @return array an array of employer/s */ public function getEmployerByMap(array $map) { $sql = 'SELECT * FROM ventus_career_fair_employers WHERE 1'; foreach (array_keys($map) as $col) { $sql .= ' AND ' . \Ventus\Utilities\DBO::cleanFieldName($col) . ' = ?'; } return $this->db->query($sql, array_values($map))->fetchAll(); }
/** * Updates a bursary * @param int $id The bursary ID * @param array $data The new bursary data * @param string $table The table to update * @param array $fields The fields to update */ protected function updateBursary($id, array $data, $table, array $fields) { if (!ctype_digit($id) && !is_int($id)) { throw new \InvalidArgumentException('Invalid bursary ID'); } // Update the child table $sql1 = "UPDATE {$table}\n SET "; foreach ($fields as $field) { $sql1 .= \Ventus\Utilities\DBO::cleanFieldName($field) . " = :{$field},"; } $sql1 = mb_substr($sql1, 0, -1) . " WHERE bursary_id = :bursary_id;"; $data = $this->db->pick($fields, $data); $data['bursary_id'] = $id; $this->db->query($sql1, $data); // Update the parent table $sql2 = "UPDATE " . self::MAIN_BURSARIES_TABLE . "\n SET updated_on = NOW()\n WHERE bursary_id = :bursary_id;"; $this->db->query($sql2, array('bursary_id' => $id)); }