/** * Delete location object by id. */ public function delete() { if (isset($_GET['location_id'])) { $id = intval(wp_unslash($_GET['location_id'])); $connection = WPGMP_Database::connect(); $this->query = $connection->prepare("DELETE FROM {$this->table} WHERE {$this->unique}='%d'", $id); return WPGMP_Database::non_query($this->query, $connection); } }
/** * Query to be executed. * @param string $query SQL Query. * @return array Records. */ function query($query) { $this->query = $query; $connection = WPGMP_Database::connect(); $thisObjectName = get_class($this); $cursors = WPGMP_Database::reader($this->query, $connection); if (!empty($cursors)) { foreach ($cursors as $row) { $obj = new $thisObjectName(); $obj->fill($row); $objects[] = $obj; } return $objects; } }