Skip to content

Commit

Permalink
converting DataObject::get_one and get_by_ID to new ORM
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerkrauss committed Feb 11, 2015
1 parent 70a1054 commit c7d08a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/controllers/UniadsAdmin.php
Expand Up @@ -37,7 +37,7 @@ public function __construct() {
public function preview(SS_HTTPRequest $request) {
$request->shift();
$adID = (int) $request->param('ID');
$ad = DataObject::get_by_id('UniadsObject', $adID);
$ad = UniadsObject::get()->byID($adID);

if (!$ad) {
Controller::curr()->httpError(404);
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/UniadsController.php
Expand Up @@ -29,7 +29,7 @@ public function go() {
private function GetAdAndLogClick($id) {
$id = (int) $id;
if ($id) {
$ad = DataObject::get_by_id('UniadsObject', $id);
$ad = UniadsObject::get()->byID($id);
if ($ad && $ad->exists()) {
$conf = UniadsObject::config();
if ($conf->record_clicks) {
Expand Down
9 changes: 7 additions & 2 deletions code/extensions/UniadsExtension.php
Expand Up @@ -52,7 +52,12 @@ public function DisplayAd($zone) {

if ($zone) {
if (!is_object($zone)) {
$zone = DataObject::get_one('UniadsZone', "Title = '".Convert::raw2sql($zone)."' and Active = 1");
$zone = UniadsZone::get()
->filter(array(
'Title' => $zone,
'Active' => 1
))
->first();
}
if ($zone) {
$toUse = $this->owner;
Expand Down Expand Up @@ -123,7 +128,7 @@ public function DisplayAd($zone) {
if($result && count($result) > 0) {
$row = $result->First();
if (isset($row['ID']) && $row['ID'] !== '') {
$ad = DataObject::get_one('UniadsObject', "ID = " . $row['ID']);
$ad = UniadsObject::get()->byID($row['ID']);
// now we can log impression
$conf = UniadsObject::config();
if ($conf->record_impressions) {
Expand Down

0 comments on commit c7d08a4

Please sign in to comment.