diff --git a/library/Director/Web/Table/DbHelper.php b/library/Director/Web/Table/DbHelper.php new file mode 100644 index 00000000..1a76db20 --- /dev/null +++ b/library/Director/Web/Table/DbHelper.php @@ -0,0 +1,43 @@ +isPgsql()) { + return sprintf("LOWER(ENCODE(%s, 'hex'))", $column); + } else { + return sprintf("LOWER(HEX(%s))", $column); + } + } + + public function quoteBinary($binary) + { + if ($this->isPgsql()) { + return new Expr("'\\x" . bin2hex($binary) . "'"); + } + + return $binary; + } + + public function isPgsql() + { + return $this->db->getConfig() instanceof \Zend_Db_Adapter_Pdo_Pgsql; + } + + public function isMysql() + { + return $this->db->getConfig() instanceof \Zend_Db_Adapter_Pdo_Mysql; + } + + public function wantBinaryValue($value) + { + if (is_resource($value)) { + return stream_get_contents($value); + } + + return $value; + } +}