PosgreSQL: use ENCODE, not HEX

This commit is contained in:
Thomas Gelf 2015-06-23 13:28:14 +02:00
parent 6c8213f4db
commit 3087776f6b
2 changed files with 12 additions and 2 deletions

View File

@ -8,13 +8,19 @@ class GeneratedConfigTable extends QuickTable
{
public function getColumns()
{
return array(
$columns = array(
'checksum' => 'LOWER(HEX(c.checksum))',
'duration' => "c.duration || 'ms'",
'files' => 'COUNT(cf.file_checksum)',
'last_related_change' => 'l.change_time',
'activity_log_id' => 'l.id'
);
if ($this->db->getDbType() === 'psql') {
$columns['checksum'] = "LOWER(ENCODE(c.checksum, 'hex'))";
}
return $columns;
}
protected function getActionUrl($row)

View File

@ -33,7 +33,11 @@ class Db extends DbConnection
public function getLastActivityChecksum()
{
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(HEX(checksum)) AS checksum FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
if ($this->getDbType() === 'psql') {
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(HEX(checksum)) AS checksum FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
} else {
$select = "SELECT checksum FROM (SELECT * FROM (SELECT 1 AS pos, LOWER(ENCODE(checksum, 'hex')) AS checksum FROM director_activity_log ORDER BY change_time DESC LIMIT 1) a UNION SELECT 2 AS pos, '' AS checksum) u ORDER BY pos LIMIT 1";
}
return $this->db()->fetchOne($select);
}