/** * Fetch all active data from table * @return mixed */ public function fetchAll() { $results = $this->_db->query("SELECT * FROM " . self::TABLE_NAME . " WHERE active = 1 AND store_id = " . $this->getStoreID()); if (!$results) { $response = new Response('Fetch all returned error: ' . $this->_db->error, 200, true); $response->toJSON(); } return $this->result_array($results); }
/** * Deactivate all ID's in provided array * @param array $data * @return bool */ public function deleteMany(array $data) { # get hardcoded store id $this->store_id = $this->getStoreID(); $in = '('; foreach ($data as $range) { $in .= intval($range['id']) . ', '; } $in = substr($in, 0, -2); $in .= ')'; $result = $this->_db->query("UPDATE " . self::TABLE_NAME . " SET active = 0 WHERE store_id = " . $this->store_id . " AND id IN " . $in); if (!$result) { $response = new Response('Fetch all returned error: ' . $this->_db->error, 200, true); $response->toJSON(); } return true; }