Lines Matching +full:update +full:- +full:user +full:- +full:pass -(+path:inc +path:lang) -(+path:lib +path:plugins +path:lang) -(+path:lib +path:tpl +path:dokuwiki +path:lang)

7  * A PHP-Based RSS and Atom Feed Framework.
10 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
38 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
43 * @license http://www.opensource.org/licenses/bsd-license.php BSD License
54 * connect to the `mydb` database on `localhost` on port 3306, with the user
93 $this->options = [
94 'user' => null,
95 'pass' => null,
105 $this->options = array_replace_recursive($this->options, \SimplePie\Cache::parse_URL($location));
108 $this->options['dbname'] = substr($this->options['path'], 1);
111 $this->mysql = new \PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
113 $this->mysql = null;
117 $this->id = $name . $type;
119 if (!$query = $this->mysql->query('SHOW TABLES')) {
120 $this->mysql = null;
125 while ($row = $query->fetchColumn()) {
129 if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db)) {
130 $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))');
132 trigger_error("Can't create " . $this->options['extras']['prefix'] . "cache_data table, check permissions", \E_USER_WARNING);
133 $this->mysql = null;
138 if (!in_array($this->options['extras']['prefix'] . 'items', $db)) {
139 $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
141 trigger_error("Can't create " . $this->options['extras']['prefix'] . "items table, check permissions", \E_USER_WARNING);
142 $this->mysql = null;
156 if ($this->mysql === null) {
160 $query = $this->mysql->prepare('DELETE i, cd FROM `' . $this->options['extras']['prefix'] . 'cache_data` cd, ' .
161 '`' . $this->options['extras']['prefix'] . 'items` i ' .
163 'AND cd.mtime < (unix_timestamp() - :purge_time)');
164 $query->bindValue(':purge_time', $this->options['extras']['cache_purge_time']);
166 if (!$query->execute()) {
175 $query = $this->mysql->prepare('SELECT COUNT(*) FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed');
176 $query->bindValue(':feed', $this->id);
177 if ($query->execute()) {
178 if ($query->fetchColumn() > 0) {
181 $sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = :items, `data` = :data, `mtime` = :time WHERE `id` = :feed';
182 $query = $this->mysql->prepare($sql);
183 $query->bindValue(':items', $items);
185 $sql = 'UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `data` = :data, `mtime` = :time WHERE `id` = :feed';
186 $query = $this->mysql->prepare($sql);
189 $query->bindValue(':data', $prepared[0]);
190 $query->bindValue(':time', time());
191 $query->bindValue(':feed', $this->id);
192 if (!$query->execute()) {
196 $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:feed, :count, :data, :time)');
197 $query->bindValue(':feed', $this->id);
198 $query->bindValue(':count', count($prepared[1]));
199 $query->bindValue(':data', $prepared[0]);
200 $query->bindValue(':time', time());
201 if (!$query->execute()) {
209 $database_ids[] = $this->mysql->quote($id);
212 $query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `id` = ' . implode(' OR `id` = ', $database_ids) . ' AND `feed_id` = :feed');
213 $query->bindValue(':feed', $this->id);
215 if ($query->execute()) {
217 while ($row = $query->fetchColumn()) {
224 if (!($date = $prepared[1][$new_id]->get_date('U'))) {
228 $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(:feed, :id, :data, :date)');
229 $query->bindValue(':feed', $this->id);
230 $query->bindValue(':id', $new_id);
231 $query->bindValue(':data', serialize($prepared[1][$new_id]->data));
232 $query->bindValue(':date', $date);
233 if (!$query->execute()) {
244 $query = $this->mysql->prepare('SELECT `id` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :feed');
245 $query->bindValue(':feed', $this->id);
246 if ($query->execute()) {
247 if ($query->rowCount() > 0) {
248 $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `items` = 0, `data` = :data, `mtime` = :time WHERE `id` = :feed');
249 $query->bindValue(':data', serialize($data));
250 $query->bindValue(':time', time());
251 $query->bindValue(':feed', $this->id);
252 if ($query->execute()) {
256 $query = $this->mysql->prepare('INSERT INTO `' . $this->options['extras']['prefix'] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(:id, 0, :data, :time)');
257 $query->bindValue(':id', $this->id);
258 $query->bindValue(':data', serialize($data));
259 $query->bindValue(':time', time());
260 if ($query->execute()) {
276 if ($this->mysql === null) {
280 $query = $this->mysql->prepare('SELECT `items`, `data` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id');
281 $query->bindValue(':id', $this->id);
282 if ($query->execute() && ($row = $query->fetch())) {
285 if (isset($this->options['items'][0])) {
286 $items = (int) $this->options['items'][0];
305 $sql = 'SELECT `data` FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :feed ORDER BY `posted` DESC';
310 $query = $this->mysql->prepare($sql);
311 $query->bindValue(':feed', $this->id);
312 if ($query->execute()) {
313 while ($row = $query->fetchColumn()) {
333 if ($this->mysql === null) {
337 $query = $this->mysql->prepare('SELECT `mtime` FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id');
338 $query->bindValue(':id', $this->id);
339 if ($query->execute() && ($time = $query->fetchColumn())) {
353 if ($this->mysql === null) {
357 $query = $this->mysql->prepare('UPDATE `' . $this->options['extras']['prefix'] . 'cache_data` SET `mtime` = :time WHERE `id` = :id');
358 $query->bindValue(':time', time());
359 $query->bindValue(':id', $this->id);
361 return $query->execute() && $query->rowCount() > 0;
371 if ($this->mysql === null) {
375 $query = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'cache_data` WHERE `id` = :id');
376 $query->bindValue(':id', $this->id);
377 $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id');
378 $query2->bindValue(':id', $this->id);
380 return $query->execute() && $query2->execute();