File modules/cms/model/Url.class.php

Last commit: Sun Mar 7 00:10:20 2021 +0100	Jan Dankert	Refactoring: Hopefully more performance while accessing the database resultsets.
1 <?php 2 namespace cms\model; 3 4 use cms\base\DB as Db; 5 6 /** 7 * Darstellen einer URL. An URL points to an string-based URL. 8 * 9 * @author Jan Dankert 10 * @package openrat.objects 11 */ 12 class Url extends BaseObject 13 { 14 public $urlid; 15 public $url = ''; 16 17 function __construct( $objectid='' ) 18 { 19 parent::__construct( $objectid ); 20 $this->isUrl = true; 21 $this->typeid = BaseObject::TYPEID_URL; 22 } 23 24 25 // Lesen der Verkn�pfung aus der Datenbank 26 function load() 27 { 28 $db = Db::get(); 29 30 $sql = $db->sql( 'SELECT *'. 31 ' FROM {{url}}'. 32 ' WHERE objectid={objectid}' ); 33 $sql->setInt( 'objectid',$this->objectid ); 34 $row = $sql->getRow(); 35 36 if ( count($row ) != 0 ) 37 { 38 $this->url = $row['url']; 39 } 40 41 $this->objectLoad(); 42 } 43 44 45 /** 46 * Löschen. 47 */ 48 function delete() 49 { 50 $db = Db::get(); 51 52 $sql = $db->sql( 'DELETE FROM {{url}} '. 53 ' WHERE objectid={objectid}' ); 54 $sql->setInt( 'objectid',$this->objectid ); 55 56 $sql->execute(); 57 58 parent::delete(); 59 } 60 61 62 63 public function save() 64 { 65 $db = Db::get(); 66 67 $sql = $db->sql('UPDATE {{url}} SET '. 68 ' url = {url}'. 69 ' WHERE objectid={objectid}' ); 70 $sql->setInt ('objectid' ,$this->objectid ); 71 $sql->setString('url',$this->url ); 72 73 $sql->execute(); 74 75 parent::save(); 76 } 77 78 79 function getProperties() 80 { 81 return array_merge( parent::getProperties(), 82 Array( 'objectid' =>$this->objectid, 83 'url' =>$this->url 84 ) ); 85 } 86 87 88 function getType() 89 { 90 return 'url'; 91 } 92 93 94 function add() 95 { 96 parent::add(); 97 98 $sql = Db::sql('SELECT MAX(id) FROM {{url}}'); 99 $this->urlid = intval($sql->getOne())+1; 100 101 $sql = Db::sql('INSERT INTO {{url}}'. 102 ' (id,objectid,url)'. 103 ' VALUES( {urlid},{objectid},{url} )' ); 104 $sql->setInt ('urlid' ,$this->urlid ); 105 $sql->setInt ('objectid' ,$this->objectid ); 106 107 $sql->setString('url',$this->url ); 108 109 $sql->execute(); 110 } 111 }
Download modules/cms/model/Url.class.php
History Sun, 7 Mar 2021 00:10:20 +0100 Jan Dankert Refactoring: Hopefully more performance while accessing the database resultsets. Sat, 6 Mar 2021 01:27:59 +0100 Jan Dankert Fix: Adding links was broken. Wed, 18 Nov 2020 01:46:36 +0100 Jan Dankert Refactoring of model classes: New method persist() and some other cleanups. Sat, 26 Sep 2020 12:20:43 +0200 Jan Dankert Refactoring: No global variables like $SESS any more. All constants are capsulated by classes. Sat, 26 Sep 2020 02:26:39 +0200 Jan Dankert Refactoring: No global functions any more, the database object is read from the Db class. Sun, 23 Feb 2020 04:01:30 +0100 Jan Dankert Refactoring with Namespaces for the cms modules, part 1: moving.