![]() |
Izartu
0.0 Initial release
Web bookmark manager based on tags.
|
00001 <?php 00002 # Izartu 00003 # 00004 # Copyright © 2011-2012 Javier Beaumont <contact@javierbeaumont.org> 00005 # 00006 # This file is part of Izartu. 00007 # 00008 # Izartu is free software: you can redistribute it and/or modify 00009 # it under the terms of the GNU Affero General Public License as 00010 # published by the Free Software Foundation, either version 3 of the 00011 # License, or (at your option) any later version. 00012 # 00013 # Izartu is distributed in the hope that it will be useful, 00014 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 # GNU Affero General Public License for more details. 00017 # 00018 # You should have received a copy of the GNU Affero General Public License 00019 # along with Izartu. If not, see <http://www.gnu.org/licenses/>. 00020 00031 class Data extends Crud { 00032 private $id; 00033 private $lang; 00034 private $type; 00035 private $title; 00036 private $hlink; 00037 private $hlang; 00038 private $htype; 00039 private $text; 00040 private $user; 00041 private $add; 00042 private $mod; 00043 00049 final private function saveData() { 00050 if ($this->id) { 00051 $query = static::$db->prepare(' 00052 UPDATE `'.PREFIX.'data` 00053 SET 00054 `lang` = :lang, 00055 `title` = :title, 00056 `hlink` = :hlink, 00057 `hlang` = :hlang, 00058 `htype` = :htype, 00059 `text` = :text, 00060 WHERE `id` = :id'); 00061 $query->bindParam(':id', $this->id, PDO::PARAM_INT, 255); 00062 } else { 00063 $query = static::$db->prepare(' 00064 INSERT INTO `'.PREFIX.'data` ( 00065 `lang`, `title`, `hlink`, `hlang`, `htype`, `text`, `user`, `add` 00066 ) 00067 VALUES ( 00068 :lang, :title, :hlink, :hlang, :htype, :text, :user, :add 00069 )'); 00070 $query->bindParam(':user', $this->user, PDO::PARAM_STR, 255); 00071 $query->bindParam(':add', date('Y-m-d H:i:s'), PDO::PARAM_STR, 19); 00072 } 00073 00074 $query->bindParam(':lang', $this->lang, PDO::PARAM_INT, 255); 00075 $query->bindParam(':title', $this->title, PDO::PARAM_STR, 255); 00076 $query->bindParam(':hlink', $this->hlink, PDO::PARAM_STR, 255); 00077 $query->bindParam(':hlang', $this->hlang, PDO::PARAM_INT, 255); 00078 $query->bindParam(':htype', $this->htype, PDO::PARAM_INT, 255); 00079 $query->bindParam(':text', $this->text, PDO::PARAM_STR, 511); 00080 $query->execute(); 00081 } 00082 00088 final private function readData($cond, $param) { 00089 return $this->read(' 00090 SELECT 00091 `id`, `title`, `hlink`, `hlang`, `htype`, `text`, `user`, `add`, `mod` 00092 FROM `'.PREFIX.'data`' . $cond, 00093 $param); 00094 } 00095 00101 final private function deleteData() { 00102 $query = static::$db->prepare('DELETE FROM `'.PREFIX.'data` WHERE `id` = :id'); 00103 $query->bindParam(':id', $this->id, PDO::PARAM_INT, 255); 00104 $query->execute(); 00105 } 00106 00112 final protected function orderDataByDate($search = FALSE, $order = FALSE) { 00113 $cond = $param = FALSE; 00114 if (!empty($search) AND array_key_exists('lang', $search) AND $search['lang']){ 00115 $param[0] = array(':lang', $search['lang'], PDO::PARAM_INT, 255); 00116 $cond .= ' WHERE AND `lang` = :lang'; 00117 } 00118 $order ? $order = 'ASC' : $order = 'DESC'; 00119 $cond .= ' ORDER BY `mod` '.$order; 00120 00121 return $this->readData($cond, $param); 00122 } 00123 00124 }
1.7.6.1