print "<div class='infoBoxContents'>";
$result = db_query($link, "SELECT login,
- SUBSTRING(last_login,1,16) AS last_login,
+ ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login,
access_level,
(SELECT COUNT(int_id) FROM ttrss_user_entries
WHERE owner_uid = id) AS stored_articles,
- SUBSTRING(created,1,16) AS created
+ ".SUBSTRING_FOR_DATE."(created,1,16) AS created
FROM ttrss_users
WHERE id = '$uid'");
require_once 'config.php';
+ if (DB_TYPE == "pgsql") {
+ define('SUBSTRING_FOR_DATE', 'SUBSTRING_FOR_DATE');
+ } else {
+ define('SUBSTRING_FOR_DATE', 'SUBSTRING');
+ }
+
/**
* Return available translations names.
*
}
$result = db_query($link, "SELECT feed_url,id,
- SUBSTRING(last_updated,1,19) AS last_updated,
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated,
update_interval FROM ttrss_feeds WHERE owner_uid = '$user_id'
ORDER BY $q_order");
$old_counters = $_SESSION["fctr_last_value"];
/* $result = db_query($link, "SELECT id,last_error,parent_feed,
- SUBSTRING(last_updated,1,19) AS last_updated,
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated,
(SELECT count(id)
FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND
$query = "SELECT ttrss_feeds.id,
ttrss_feeds.title,
- SUBSTRING(ttrss_feeds.last_updated,1,19) AS last_updated,
+ ".SUBSTRING_FOR_DATE."(ttrss_feeds.last_updated,1,19) AS last_updated,
last_error,
COUNT(ttrss_entries.id) AS count
FROM ttrss_feeds
ttrss_entries.id,ttrss_entries.title,
updated,
unread,feed_id,marked,published,link,last_read,
- SUBSTRING(last_read,1,19) as last_read_noms,
+ ".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
$vfeed_query_part
$content_query_part
- SUBSTRING(updated,1,19) as updated_noms,
+ ".SUBSTRING_FOR_DATE."(updated,1,19) as updated_noms,
author
FROM
ttrss_entries,ttrss_user_entries,ttrss_feeds
updated,
unread,feed_id,
marked,link,last_read,
- SUBSTRING(last_read,1,19) as last_read_noms,
+ ".SUBSTRING_FOR_DATE."(last_read,1,19) as last_read_noms,
$vfeed_query_part
$content_query_part
- SUBSTRING(updated,1,19) as updated_noms
+ ".SUBSTRING_FOR_DATE."(updated,1,19) as updated_noms
FROM
ttrss_entries,ttrss_user_entries,ttrss_tags
WHERE
ttrss_user_entries.ref_id,
link,
SUBSTRING(content, 1, 120) AS excerpt,
- SUBSTRING(last_updated,1,19) AS last_updated
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM
ttrss_user_entries,ttrss_entries,ttrss_feeds
WHERE
$age_qpart = getMaxAgeSubquery();
$result = db_query($link, "SELECT ttrss_feeds.*,
- SUBSTRING(last_updated,1,19) AS last_updated_noms,
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,
(SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND unread = true
AND $age_qpart
}
$result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
- SUBSTRING(updated,1,16) as updated,
+ ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
(SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
num_comments,
author
// We search for feed needing update.
$result = db_query($link, "SELECT ttrss_feeds.feed_url,ttrss_feeds.id, ttrss_feeds.owner_uid,
- SUBSTRING(ttrss_feeds.last_updated,1,19) AS last_updated,
+ ".SUBSTRING_FOR_DATE."(ttrss_feeds.last_updated,1,19) AS last_updated,
ttrss_feeds.update_interval
FROM
ttrss_feeds, ttrss_users, ttrss_user_prefs
}
$result = db_query($link, "SELECT ttrss_feeds.*,
- SUBSTRING(last_updated,1,19) AS last_updated_noms,
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated_noms,
(SELECT COUNT(id) FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND
ttrss_user_entries.ref_id = ttrss_entries.id AND
$result = db_query($link, "SELECT title,link,content,feed_id,comments,int_id,
marked,published,
- SUBSTRING(updated,1,16) as updated,
+ ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
(SELECT icon_url FROM ttrss_feeds WHERE id = feed_id) as icon_url,
num_comments,
author
$result = db_query($link, "SELECT
feed_url,site_url,
- SUBSTRING(last_updated,1,19) AS last_updated
+ ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE id = '$id' AND
auth_login = '' AND auth_pass = '' AND private IS NOT true");
if ($_GET["slat"] == "true") {
$show_last_article_info = true;
$show_last_article_checked = "checked";
- $show_last_article_qpart = ", (SELECT SUBSTRING(MAX(updated),1,16) FROM ttrss_user_entries,
+ $show_last_article_qpart = ", (SELECT ".SUBSTRING_FOR_DATE."(MAX(updated),1,16) FROM ttrss_user_entries,
ttrss_entries WHERE ref_id = ttrss_entries.id
AND feed_id = F1.id) AS last_article";
} else if ($feeds_sort == "last_article") {
$result = db_query($link, "SELECT
id,login,access_level,email,
- SUBSTRING(last_login,1,16) as last_login
+ ".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login
FROM
ttrss_users
ORDER BY $sort");
require_once "functions.php";
define('EXPECTED_CONFIG_VERSION', 15);
- define('SCHEMA_VERSION', 34);
+ define('SCHEMA_VERSION', 35);
if (!file_exists("config.php")) {
print __("<b>Fatal Error</b>: You forgot to copy
create table ttrss_version (schema_version int not null) TYPE=InnoDB;
-insert into ttrss_version values (34);
+insert into ttrss_version values (35);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
drop table ttrss_users;
drop table ttrss_themes;
drop table ttrss_sessions;
+drop function SUBSTRING_FOR_DATE(timestamp, int, int);
begin;
create table ttrss_version (schema_version int not null);
-insert into ttrss_version values (34);
+insert into ttrss_version values (35);
create table ttrss_enclosures (id serial not null primary key,
content_url text not null,
create index ttrss_sessions_expire_index on ttrss_sessions(expire);
+create function SUBSTRING_FOR_DATE(timestamp, int, int) RETURNS text AS 'SELECT SUBSTRING(CAST($1 AS text), $2, $3)' LANGUAGE 'sql';
+
commit;
--- /dev/null
+update ttrss_version set schema_version = 35;
--- /dev/null
+create function SUBSTRING_FOR_DATE(timestamp, int, int) RETURNS text AS 'SELECT SUBSTRING(CAST($1 AS text), $2, $3)' LANGUAGE 'sql';
+
+update ttrss_version set schema_version = 35;
if (authenticate_user($link, $login, $pass)) {
$result = db_query($link, "SELECT
- id, feed_url, cat_id, title, SUBSTRING(last_updated,1,19) AS last_updated
+ id, feed_url, cat_id, title, ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE owner_uid = " .
$_SESSION["uid"]);
$query = "SELECT title,link,content,feed_id,comments,int_id,
marked,unread,
- SUBSTRING(updated,1,16) as updated,
+ ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author
FROM ttrss_entries,ttrss_user_entries
WHERE id = '$article_id' AND ref_id = id AND owner_uid = " . $_SESSION["uid"] ;