diff --git a/api/qq/SYS_API_TREE.php b/api/qq/SYS_API_TREE.php index dfa58ea..21ce53a 100644 --- a/api/qq/SYS_API_TREE.php +++ b/api/qq/SYS_API_TREE.php @@ -2,7 +2,7 @@ namespace SYSTEM\SQL; class SYS_API_TREE extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} - public static function pqsql(){return + public static function pgsql(){return 'SELECT * FROM '.\SYSTEM\SQL\system_api::NAME_PG .' WHERE "'.\SYSTEM\SQL\system_api::FIELD_GROUP.'" = $1' .' ORDER BY "'.\SYSTEM\SQL\system_api::FIELD_ID.'"'; diff --git a/db/connection/ConnectionPG.php b/db/connection/ConnectionPG.php index 58190f3..f772c80 100644 --- a/db/connection/ConnectionPG.php +++ b/db/connection/ConnectionPG.php @@ -57,5 +57,11 @@ class ConnectionPG extends ConnectionAbstr { return new ResultPostgres($result,$this); } + + public function trans(){ + return $this->connection->trans();} + + public function commit(){ + return $this->connection->commit();} } \ No newline at end of file diff --git a/db/result/Result.php b/db/result/Result.php index f68e306..3eac332 100644 --- a/db/result/Result.php +++ b/db/result/Result.php @@ -8,7 +8,7 @@ abstract class Result { public abstract function affectedRows(); - public abstract function next($object = false, $result_type = MYSQL_BOTH); + public abstract function next($object = false); public abstract function seek($row_number); diff --git a/db/result/ResultPostgres.php b/db/result/ResultPostgres.php index 012f3f1..4fecba1 100644 --- a/db/result/ResultPostgres.php +++ b/db/result/ResultPostgres.php @@ -25,7 +25,7 @@ class ResultPostgres extends \SYSTEM\DB\Result{ public function affectedRows(){ return pg_affected_rows($this->res);} - public function next($object = false, $result_type = MYSQL_BOTH){ + public function next($object = false){ if($object){ $this->current = pg_fetch_object($this->res); } else { diff --git a/log/error_handler/error_handler_dbwriter.php b/log/error_handler/error_handler_dbwriter.php index c17872a..100fa0a 100644 --- a/log/error_handler/error_handler_dbwriter.php +++ b/log/error_handler/error_handler_dbwriter.php @@ -9,7 +9,6 @@ class error_handler_dbwriter extends \SYSTEM\LOG\error_handler { try{ if(\property_exists(get_class($E), 'logged') && $E->logged){ return false;} //alrdy logged(this prevents proper thrown value for every system exception) - \SYSTEM\SQL\SYS_LOG_INSERT::Q1( /*array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5), $_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST), @@ -17,11 +16,11 @@ class error_handler_dbwriter extends \SYSTEM\LOG\error_handler { array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null, ($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0),*/ array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), - getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5),date('Y-m-d H:i:s', microtime(true)), + getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5), $_SERVER["SERVER_NAME"],$_SERVER["SERVER_PORT"],$_SERVER['REQUEST_URI'], serialize($_POST), array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null, array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null, - ($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown)); + ($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null,$thrown ? 1 : 0)); if(\property_exists(get_class($E), 'logged')){ $E->logged = true;} //we just did log } catch (\Exception $E){return false;} //Error -> Ignore diff --git a/log/qq/SYS_LOG_INSERT.php b/log/qq/SYS_LOG_INSERT.php index 75262b4..db57e2a 100644 --- a/log/qq/SYS_LOG_INSERT.php +++ b/log/qq/SYS_LOG_INSERT.php @@ -2,7 +2,7 @@ namespace SYSTEM\SQL; class SYS_LOG_INSERT extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} - public static function pqsql(){return + public static function pgsql(){return 'INSERT INTO '.\SYSTEM\SQL\system_log::NAME_PG. '("'.\SYSTEM\SQL\system_log::FIELD_CLASS.'","'.\SYSTEM\SQL\system_log::FIELD_MESSAGE.'","'. \SYSTEM\SQL\system_log::FIELD_CODE.'","'.\SYSTEM\SQL\system_log::FIELD_FILE.'","'. @@ -25,6 +25,6 @@ class SYS_LOG_INSERT extends \SYSTEM\DB\QP { \SYSTEM\SQL\system_log::FIELD_POST.','.\SYSTEM\SQL\system_log::FIELD_HTTP_REFERER.','. \SYSTEM\SQL\system_log::FIELD_HTTP_USER_AGENT.','.\SYSTEM\SQL\system_log::FIELD_USER.','. \SYSTEM\SQL\system_log::FIELD_THROWN.')'. -'VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'; +'VALUES(?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?);'; } } \ No newline at end of file diff --git a/page/qq/SYS_TEXT_GET_TAG.php b/page/qq/SYS_TEXT_GET_TAG.php index 799d4b2..d5df07d 100644 --- a/page/qq/SYS_TEXT_GET_TAG.php +++ b/page/qq/SYS_TEXT_GET_TAG.php @@ -2,6 +2,11 @@ namespace SYSTEM\SQL; class SYS_TEXT_GET_TAG extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} + public static function pgsql(){return +'SELECT system.text.id,text FROM system.text + LEFT JOIN system.text_tag ON system.text.id = system.text_tag.id + WHERE tag = $1 and lang = $2;'; + } public static function mysql(){return 'SELECT system_text.id,text FROM system_text LEFT JOIN system_text_tag ON system_text.id = system_text_tag.id diff --git a/sai/modules/saimod_sys_todo/qq/SYS_SAIMOD_TODO_EXCEPTION_INSERT.php b/sai/modules/saimod_sys_todo/qq/SYS_SAIMOD_TODO_EXCEPTION_INSERT.php index c16efd1..738cf49 100644 --- a/sai/modules/saimod_sys_todo/qq/SYS_SAIMOD_TODO_EXCEPTION_INSERT.php +++ b/sai/modules/saimod_sys_todo/qq/SYS_SAIMOD_TODO_EXCEPTION_INSERT.php @@ -2,6 +2,20 @@ namespace SYSTEM\SQL; class SYS_SAIMOD_TODO_EXCEPTION_INSERT extends \SYSTEM\DB\QP { public static function get_class(){return \get_class();} + public static function pgsql(){return +'INSERT INTO '.\SYSTEM\SQL\system_todo::NAME_PG. +'('.\SYSTEM\SQL\system_todo::FIELD_CLASS.','.\SYSTEM\SQL\system_todo::FIELD_MESSAGE.','. + \SYSTEM\SQL\system_todo::FIELD_CODE.','.\SYSTEM\SQL\system_todo::FIELD_FILE.','. + \SYSTEM\SQL\system_todo::FIELD_LINE.','.\SYSTEM\SQL\system_todo::FIELD_TRACE.','. + \SYSTEM\SQL\system_todo::FIELD_IP.','.\SYSTEM\SQL\system_todo::FIELD_QUERYTIME.','. + \SYSTEM\SQL\system_todo::FIELD_TIME.','.\SYSTEM\SQL\system_todo::FIELD_SERVER_NAME.','. + \SYSTEM\SQL\system_todo::FIELD_SERVER_PORT.','.\SYSTEM\SQL\system_todo::FIELD_REQUEST_URI.','. + \SYSTEM\SQL\system_todo::FIELD_POST.','.\SYSTEM\SQL\system_todo::FIELD_HTTP_REFERER.','. + \SYSTEM\SQL\system_todo::FIELD_HTTP_USER_AGENT.',"'.\SYSTEM\SQL\system_todo::FIELD_USER.'",'. + \SYSTEM\SQL\system_todo::FIELD_THROWN.','.\SYSTEM\SQL\system_todo::FIELD_MESSAGE_HASH.','. + \SYSTEM\SQL\system_todo::FIELD_TYPE.')'. +'VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, digest($18, \'sha1\'),$19)'; + } public static function mysql(){return 'INSERT INTO '.\SYSTEM\SQL\system_todo::NAME_MYS. '('.\SYSTEM\SQL\system_todo::FIELD_CLASS.','.\SYSTEM\SQL\system_todo::FIELD_MESSAGE.','. diff --git a/sql/qt/pg/schema/extension_pgcrypto.sql b/sql/qt/pg/schema/extension_pgcrypto.sql new file mode 100644 index 0000000..45384eb --- /dev/null +++ b/sql/qt/pg/schema/extension_pgcrypto.sql @@ -0,0 +1 @@ +create extension pgcrypto; \ No newline at end of file diff --git a/sql/qt/pg/schema/system_text.sql b/sql/qt/pg/schema/system_text.sql new file mode 100644 index 0000000..b74d0ae --- /dev/null +++ b/sql/qt/pg/schema/system_text.sql @@ -0,0 +1,10 @@ +CREATE TABLE system.text ( + id character varying(35) NOT NULL, + lang character varying(4) NOT NULL, + text text NOT NULL, + author serial NOT NULL, + author_edit serial NOT NULL, + time_create timestamp with time zone NOT NULL DEFAULT now(), + time_edit timestamp with time zone DEFAULT NULL, + CONSTRAINT system_text_pk_id_lang PRIMARY KEY (id,lang) +); \ No newline at end of file diff --git a/sql/qt/pg/schema/system_text_tag.sql b/sql/qt/pg/schema/system_text_tag.sql new file mode 100644 index 0000000..260fb92 --- /dev/null +++ b/sql/qt/pg/schema/system_text_tag.sql @@ -0,0 +1,5 @@ +CREATE TABLE system.text_tag ( + id character varying(35) NOT NULL, + tag character varying(35) NOT NULL, + CONSTRAINT system_text_tag_pk_id_tag PRIMARY KEY (id,tag) +) \ No newline at end of file