'title' => 'Semantico UI',
'pdo' => 'sqlite:/opt/semantico/product/releases/sem_ui/db/semantico.db',
'default_table' => 'node',
+
+ 'sql_replace' => function($sql) {
+ $r = [];
+
+ $r["CAST(started as char(30)),duration||' seconds'"] = "from_unixtime(UNIX_TIMESTAMP(started)+duration)";
+
+ $sql = str_replace(array_keys($r),$r,$sql);
+ return $sql;
+ },
+
'tables' => array(
'aws_az' => array(
DELIMITER $$
+
+DROP FUNCTION IF EXISTS strftime$$
+CREATE FUNCTION strftime (f text,str text)
+RETURNS text DETERMINISTIC
+BEGIN
+ IF ( f = '%s' )
+ THEN
+ RETURN UNIX_TIMESTAMP(str);
+ ELSE
+ RETURN DATE_FORMAT(str,f);
+ END IF;
+END$$
+
DROP FUNCTION IF EXISTS to_char$$
CREATE FUNCTION to_char (f text,s text)
RETURNS text DETERMINISTIC
if (!empty($name) and !preg_match('/'.$name.'/',$t->name)) continue;
if ($insert) {
- echo "\n-- Table: ".$t->name."\n";
+ echo "\n-- ".strtoupper($t->type).": ".$t->name."\n";
}
#echo 'DROP TABLE IF EXISTS '.$t->sql_name().';'.NB_EOL;
echo 'DROP '.strtoupper($t->type).' IF EXISTS '.$t->sql_name().';'.NB_EOL;
// String replace function
$sql_replace_fct = $this->db()->type('sql.replace',false);
- $sql_replace = function($sql) use ($sql_replace_fct) {
+ $db_sql_replace_fct = empty($this->db()->sql_replace) ? '' : $this->db()->sql_replace;
+ $sql_replace = function($sql) use ($sql_replace_fct,$db_sql_replace_fct) {
+ if ($db_sql_replace_fct) $sql = $db_sql_replace_fct($sql);
return $sql_replace_fct ? $sql_replace_fct($sql) : $sql;
};
'exec' => [
'SET NAMES '.str_replace('utf-8','utf8',strtolower(Db::$encoding)),
- (Db::p('db.type') ? 'SET sql_mode=PIPES_AS_CONCAT' : null),
+ (Db::p('db.type') ? 'SET SESSION sql_mode=PIPES_AS_CONCAT' : null),
],
'extra_where' => 'having',