mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 21:12:15 +09:00
merge from branch 1.5.3.2 (~r12279)
git-svn-id: http://xe-core.googlecode.com/svn/branches/luminous@12282 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
commit
7e118f8533
14 changed files with 206 additions and 87 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
require(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
||||||
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
|
||||||
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
|
||||||
|
require(_XE_PATH_.'classes/db/queryparts/expression/ClickCountExpression.class.php');
|
||||||
require(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
|
||||||
require(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
||||||
require(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
require(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
||||||
|
|
@ -110,9 +111,9 @@
|
||||||
* transaction flag
|
* transaction flag
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $transaction_started = false;
|
var $transaction_started = FALSE;
|
||||||
|
|
||||||
var $is_connected = false;
|
var $is_connected = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns enable list in supported dbms list
|
* returns enable list in supported dbms list
|
||||||
|
|
@ -249,7 +250,7 @@
|
||||||
$get_supported_list = array();
|
$get_supported_list = array();
|
||||||
$db_classes_path = _XE_PATH_."classes/db/";
|
$db_classes_path = _XE_PATH_."classes/db/";
|
||||||
$filter = "/^DB([^\.]+)\.class\.php/i";
|
$filter = "/^DB([^\.]+)\.class\.php/i";
|
||||||
$supported_list = FileHandler::readDir($db_classes_path, $filter, true);
|
$supported_list = FileHandler::readDir($db_classes_path, $filter, TRUE);
|
||||||
sort($supported_list);
|
sort($supported_list);
|
||||||
|
|
||||||
// after creating instance of class, check is supported
|
// after creating instance of class, check is supported
|
||||||
|
|
@ -269,9 +270,9 @@
|
||||||
|
|
||||||
if(!$oDB) continue;
|
if(!$oDB) continue;
|
||||||
|
|
||||||
$obj = null;
|
$obj = NULL;
|
||||||
$obj->db_type = $db_type;
|
$obj->db_type = $db_type;
|
||||||
$obj->enable = $oDB->isSupported() ? true : false;
|
$obj->enable = $oDB->isSupported() ? TRUE : FALSE;
|
||||||
|
|
||||||
$get_supported_list[] = $obj;
|
$get_supported_list[] = $obj;
|
||||||
}
|
}
|
||||||
|
|
@ -295,8 +296,8 @@
|
||||||
* @return boolean true: connected, false: not connected
|
* @return boolean true: connected, false: not connected
|
||||||
*/
|
*/
|
||||||
function isConnected($type = 'master', $indx = 0) {
|
function isConnected($type = 'master', $indx = 0) {
|
||||||
if($type == 'master') return $this->master_db["is_connected"] ? true : false;
|
if($type == 'master') return $this->master_db["is_connected"] ? TRUE : FALSE;
|
||||||
else return $this->slave_db[$indx]["is_connected"] ? true : false;
|
else return $this->slave_db[$indx]["is_connected"] ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -341,7 +342,7 @@
|
||||||
$debug_file = _XE_PATH_."files/_debug_db_query.php";
|
$debug_file = _XE_PATH_."files/_debug_db_query.php";
|
||||||
$buff = array();
|
$buff = array();
|
||||||
if(!file_exists($debug_file)) $buff[] = '<?php exit(); ?>';
|
if(!file_exists($debug_file)) $buff[] = '<?php exit(); ?>';
|
||||||
$buff[] = print_r($log, true);
|
$buff[] = print_r($log, TRUE);
|
||||||
|
|
||||||
if(@!$fp = fopen($debug_file, "a")) return;
|
if(@!$fp = fopen($debug_file, "a")) return;
|
||||||
fwrite($fp, implode("\n", $buff)."\n\n");
|
fwrite($fp, implode("\n", $buff)."\n\n");
|
||||||
|
|
@ -385,7 +386,7 @@
|
||||||
* @return boolean true: error, false: no error
|
* @return boolean true: error, false: no error
|
||||||
*/
|
*/
|
||||||
function isError() {
|
function isError() {
|
||||||
return $this->errno === 0 ? false : true;
|
return $this->errno === 0 ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -535,8 +536,8 @@
|
||||||
* @return int count of cache data
|
* @return int count of cache data
|
||||||
*/
|
*/
|
||||||
function getCountCache($tables, $condition) {
|
function getCountCache($tables, $condition) {
|
||||||
return false;
|
return FALSE;
|
||||||
if(!$tables) return false;
|
if(!$tables) return FALSE;
|
||||||
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
||||||
|
|
||||||
$condition = md5($condition);
|
$condition = md5($condition);
|
||||||
|
|
@ -548,14 +549,14 @@
|
||||||
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
|
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
|
||||||
|
|
||||||
$cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
|
$cache_filename = sprintf('%s/%s.%s', $cache_path, $tables_str, $condition);
|
||||||
if(!file_exists($cache_filename)) return false;
|
if(!file_exists($cache_filename)) return FALSE;
|
||||||
|
|
||||||
$cache_mtime = filemtime($cache_filename);
|
$cache_mtime = filemtime($cache_filename);
|
||||||
|
|
||||||
if(!is_array($tables)) $tables = array($tables);
|
if(!is_array($tables)) $tables = array($tables);
|
||||||
foreach($tables as $alias => $table) {
|
foreach($tables as $alias => $table) {
|
||||||
$table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table) ;
|
$table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table) ;
|
||||||
if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime) return false;
|
if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = (int)FileHandler::readFile($cache_filename);
|
$count = (int)FileHandler::readFile($cache_filename);
|
||||||
|
|
@ -570,8 +571,8 @@
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function putCountCache($tables, $condition, $count = 0) {
|
function putCountCache($tables, $condition, $count = 0) {
|
||||||
return false;
|
return FALSE;
|
||||||
if(!$tables) return false;
|
if(!$tables) return FALSE;
|
||||||
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
||||||
|
|
||||||
$condition = md5($condition);
|
$condition = md5($condition);
|
||||||
|
|
@ -593,8 +594,8 @@
|
||||||
* @return boolean true: success, false: failed
|
* @return boolean true: success, false: failed
|
||||||
*/
|
*/
|
||||||
function resetCountCache($tables) {
|
function resetCountCache($tables) {
|
||||||
return false;
|
return FALSE;
|
||||||
if(!$tables) return false;
|
if(!$tables) return FALSE;
|
||||||
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
|
||||||
|
|
||||||
if(!is_array($tables)) $tables = array($tables);
|
if(!is_array($tables)) $tables = array($tables);
|
||||||
|
|
@ -604,7 +605,7 @@
|
||||||
FileHandler::writeFile($filename, '');
|
FileHandler::writeFile($filename, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -642,7 +643,7 @@
|
||||||
* @param boolean $with_values
|
* @param boolean $with_values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getSelectSql($query, $with_values = true){
|
function getSelectSql($query, $with_values = TRUE){
|
||||||
$select = $query->getSelectString($with_values);
|
$select = $query->getSelectString($with_values);
|
||||||
if($select == '') return new Object(-1, "Invalid query");
|
if($select == '') return new Object(-1, "Invalid query");
|
||||||
$select = 'SELECT ' .$select;
|
$select = 'SELECT ' .$select;
|
||||||
|
|
@ -676,6 +677,36 @@
|
||||||
return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a SELECT statement that uses click count
|
||||||
|
* returns the corresponding update sql string
|
||||||
|
* for databases that don't have click count support built in
|
||||||
|
* (aka all besides CUBRID)
|
||||||
|
*
|
||||||
|
* Function does not check if click count columns exist!
|
||||||
|
* You must call $query->usesClickCount() before using this function
|
||||||
|
*
|
||||||
|
* @param $queryObject
|
||||||
|
*/
|
||||||
|
function getClickCountQuery($queryObject)
|
||||||
|
{
|
||||||
|
$new_update_columns = array();
|
||||||
|
$click_count_columns = $queryObject->getClickCountColumns();
|
||||||
|
foreach($click_count_columns as $click_count_column)
|
||||||
|
{
|
||||||
|
$click_count_column_name = $click_count_column->column_name;
|
||||||
|
|
||||||
|
$increase_by_1 = new Argument($click_count_column_name, null);
|
||||||
|
$increase_by_1->setColumnOperation('+');
|
||||||
|
$increase_by_1->ensureDefaultValue(1);
|
||||||
|
|
||||||
|
$update_expression = new UpdateExpression($click_count_column_name, $increase_by_1);
|
||||||
|
$new_update_columns[] = $update_expression;
|
||||||
|
}
|
||||||
|
$queryObject->columns = $new_update_columns;
|
||||||
|
return $queryObject;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return delete query string
|
* Return delete query string
|
||||||
* @param object $query
|
* @param object $query
|
||||||
|
|
@ -683,7 +714,7 @@
|
||||||
* @param boolean $with_priority
|
* @param boolean $with_priority
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getDeleteSql($query, $with_values = true, $with_priority = false){
|
function getDeleteSql($query, $with_values = TRUE, $with_priority = FALSE){
|
||||||
$sql = 'DELETE ';
|
$sql = 'DELETE ';
|
||||||
|
|
||||||
$sql .= $with_priority?$query->getPriority():'';
|
$sql .= $with_priority?$query->getPriority():'';
|
||||||
|
|
@ -708,7 +739,7 @@
|
||||||
* @param boolean $with_priority
|
* @param boolean $with_priority
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getUpdateSql($query, $with_values = true, $with_priority = false){
|
function getUpdateSql($query, $with_values = TRUE, $with_priority = FALSE){
|
||||||
$columnsList = $query->getUpdateString($with_values);
|
$columnsList = $query->getUpdateString($with_values);
|
||||||
if($columnsList == '') return new Object(-1, "Invalid query");
|
if($columnsList == '') return new Object(-1, "Invalid query");
|
||||||
|
|
||||||
|
|
@ -730,7 +761,7 @@
|
||||||
* @param boolean $with_priority
|
* @param boolean $with_priority
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getInsertSql($query, $with_values = true, $with_priority = false){
|
function getInsertSql($query, $with_values = TRUE, $with_priority = FALSE){
|
||||||
$tableName = $query->getFirstTableName();
|
$tableName = $query->getFirstTableName();
|
||||||
$values = $query->getInsertString($with_values);
|
$values = $query->getInsertString($with_values);
|
||||||
$priority = $with_priority?$query->getPriority():'';
|
$priority = $with_priority?$query->getPriority():'';
|
||||||
|
|
@ -778,10 +809,10 @@
|
||||||
*/
|
*/
|
||||||
function _dbInfoExists() {
|
function _dbInfoExists() {
|
||||||
if (!$this->master_db)
|
if (!$this->master_db)
|
||||||
return false;
|
return FALSE;
|
||||||
if (count($this->slave_db) === 0)
|
if (count($this->slave_db) === 0)
|
||||||
return false;
|
return FALSE;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -811,7 +842,7 @@
|
||||||
|
|
||||||
$this->_close($connection["resource"]);
|
$this->_close($connection["resource"]);
|
||||||
|
|
||||||
$connection["is_connected"] = false;
|
$connection["is_connected"] = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -820,7 +851,7 @@
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function _begin(){
|
function _begin(){
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -832,7 +863,7 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if($this->_begin())
|
if($this->_begin())
|
||||||
$this->transaction_started = true;
|
$this->transaction_started = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -841,7 +872,7 @@
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function _rollback(){
|
function _rollback(){
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -852,7 +883,7 @@
|
||||||
if (!$this->isConnected() || !$this->transaction_started)
|
if (!$this->isConnected() || !$this->transaction_started)
|
||||||
return;
|
return;
|
||||||
if($this->_rollback())
|
if($this->_rollback())
|
||||||
$this->transaction_started = false;
|
$this->transaction_started = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -861,7 +892,7 @@
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function _commit(){
|
function _commit(){
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -869,11 +900,11 @@
|
||||||
* @param boolean $force regardless transaction start status or connect status, forced to commit
|
* @param boolean $force regardless transaction start status or connect status, forced to commit
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function commit($force = false) {
|
function commit($force = FALSE) {
|
||||||
if (!$force && (!$this->isConnected() || !$this->transaction_started))
|
if (!$force && (!$this->isConnected() || !$this->transaction_started))
|
||||||
return;
|
return;
|
||||||
if($this->_commit())
|
if($this->_commit())
|
||||||
$this->transaction_started = false;
|
$this->transaction_started = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -894,8 +925,8 @@
|
||||||
* @param resource $connection
|
* @param resource $connection
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function _query($query, $connection = null) {
|
function _query($query, $connection = NULL) {
|
||||||
if($connection == null)
|
if($connection == NULL)
|
||||||
$connection = $this->_getConnection('master');
|
$connection = $this->_getConnection('master');
|
||||||
// Notify to start a query execution
|
// Notify to start a query execution
|
||||||
$this->actStart($query);
|
$this->actStart($query);
|
||||||
|
|
@ -971,14 +1002,14 @@
|
||||||
$connection = &$this->slave_db[$indx];
|
$connection = &$this->slave_db[$indx];
|
||||||
|
|
||||||
$result = $this->__connect($connection);
|
$result = $this->__connect($connection);
|
||||||
if($result === NULL || $result === false) {
|
if($result === NULL || $result === FALSE) {
|
||||||
$connection["is_connected"] = false;
|
$connection["is_connected"] = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check connections
|
// Check connections
|
||||||
$connection["resource"] = $result;
|
$connection["resource"] = $result;
|
||||||
$connection["is_connected"] = true;
|
$connection["is_connected"] = TRUE;
|
||||||
|
|
||||||
// Save connection info for db logs
|
// Save connection info for db logs
|
||||||
$this->connection = ucfirst($type) . ' ' . $connection["db_hostname"];
|
$this->connection = ucfirst($type) . ' ' . $connection["db_hostname"];
|
||||||
|
|
@ -1018,8 +1049,8 @@
|
||||||
* @param boolean $force force load DBParser instance
|
* @param boolean $force force load DBParser instance
|
||||||
* @return DBParser
|
* @return DBParser
|
||||||
*/
|
*/
|
||||||
function &getParser($force = false){
|
function &getParser($force = FALSE){
|
||||||
static $dbParser = null;
|
static $dbParser = NULL;
|
||||||
if(!$dbParser || $force) {
|
if(!$dbParser || $force) {
|
||||||
$oDB = &DB::getInstance();
|
$oDB = &DB::getInstance();
|
||||||
$dbParser = $oDB->getParser();
|
$dbParser = $oDB->getParser();
|
||||||
|
|
|
||||||
|
|
@ -729,6 +729,12 @@
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
$buff = new Object ();
|
$buff = new Object ();
|
||||||
$buff->data = $data;
|
$buff->data = $data;
|
||||||
|
|
||||||
|
if($queryObject->usesClickCount())
|
||||||
|
{
|
||||||
|
$update_query = $this->getClickCountQuery($queryObject);
|
||||||
|
$this->_executeUpdateAct($update_query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -501,6 +501,13 @@ class DBMysql extends DB {
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
$buff = new Object ();
|
$buff = new Object ();
|
||||||
$buff->data = $data;
|
$buff->data = $data;
|
||||||
|
|
||||||
|
if($queryObject->usesClickCount())
|
||||||
|
{
|
||||||
|
$update_query = $this->getClickCountQuery($queryObject);
|
||||||
|
$this->_executeUpdateAct($update_query, $with_values);
|
||||||
|
}
|
||||||
|
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,13 @@
|
||||||
* argument list
|
* argument list
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $arguments = null;
|
var $arguments = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* column list
|
* column list
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $columnList = null;
|
var $columnList = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* order by text
|
* order by text
|
||||||
|
|
@ -83,15 +83,15 @@
|
||||||
* @param string $priority
|
* @param string $priority
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Query($queryID = null
|
function Query($queryID = NULL
|
||||||
, $action = null
|
, $action = NULL
|
||||||
, $columns = null
|
, $columns = NULL
|
||||||
, $tables = null
|
, $tables = NULL
|
||||||
, $conditions = null
|
, $conditions = NULL
|
||||||
, $groups = null
|
, $groups = NULL
|
||||||
, $orderby = null
|
, $orderby = NULL
|
||||||
, $limit = null
|
, $limit = NULL
|
||||||
, $priority = null){
|
, $priority = NULL){
|
||||||
$this->queryID = $queryID;
|
$this->queryID = $queryID;
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
$this->priority = $priority;
|
$this->priority = $priority;
|
||||||
|
|
@ -106,7 +106,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(){
|
function show(){
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setQueryId($queryID){
|
function setQueryId($queryID){
|
||||||
|
|
@ -149,7 +149,7 @@
|
||||||
|
|
||||||
function setTables($tables){
|
function setTables($tables){
|
||||||
if(!isset($tables) || count($tables) === 0){
|
if(!isset($tables) || count($tables) === 0){
|
||||||
$this->setError(true);
|
$this->setError(TRUE);
|
||||||
$this->setMessage("You must provide at least one table for the query.");
|
$this->setMessage("You must provide at least one table for the query.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +198,7 @@
|
||||||
* @param string|array $columns
|
* @param string|array $columns
|
||||||
* @return Query return Query instance
|
* @return Query return Query instance
|
||||||
*/
|
*/
|
||||||
function select($columns= null){
|
function select($columns= NULL){
|
||||||
$this->action = 'select';
|
$this->action = 'select';
|
||||||
$this->setColumns($columns);
|
$this->setColumns($columns);
|
||||||
return $this;
|
return $this;
|
||||||
|
|
@ -263,12 +263,34 @@
|
||||||
return $this->priority?'LOW_PRIORITY':'';
|
return $this->priority?'LOW_PRIORITY':'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if current query uses the click count attribute
|
||||||
|
* For CUBRID, this statement uses the click count feature.
|
||||||
|
* For the other databases, using this attribute causes a query
|
||||||
|
* to produce both a select and an update
|
||||||
|
*/
|
||||||
|
function usesClickCount()
|
||||||
|
{
|
||||||
|
return count($this->getClickCountColumns()) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getClickCountColumns()
|
||||||
|
{
|
||||||
|
$click_count_columns = array();
|
||||||
|
foreach($this->columns as $column){
|
||||||
|
if($column->show() && $column instanceof ClickCountExpression)
|
||||||
|
$click_count_columns[] = $column;
|
||||||
|
}
|
||||||
|
return $click_count_columns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return select sql
|
* Return select sql
|
||||||
* @param boolean $with_values
|
* @param boolean $with_values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getSelectString($with_values = true){
|
function getSelectString($with_values = TRUE){
|
||||||
|
$select = array();
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column){
|
||||||
if($column->show())
|
if($column->show())
|
||||||
if($column->isSubquery()){
|
if($column->isSubquery()){
|
||||||
|
|
@ -285,7 +307,7 @@
|
||||||
* @param boolean $with_values
|
* @param boolean $with_values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getUpdateString($with_values = true){
|
function getUpdateString($with_values = TRUE){
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column){
|
||||||
if($column->show())
|
if($column->show())
|
||||||
$update[] = $column->getExpression($with_values);
|
$update[] = $column->getExpression($with_values);
|
||||||
|
|
@ -298,7 +320,7 @@
|
||||||
* @param boolean $with_values
|
* @param boolean $with_values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getInsertString($with_values = true){
|
function getInsertString($with_values = TRUE){
|
||||||
$columnsList = '';
|
$columnsList = '';
|
||||||
if($this->subquery){ // means we have insert-select
|
if($this->subquery){ // means we have insert-select
|
||||||
|
|
||||||
|
|
@ -339,7 +361,7 @@
|
||||||
* @param boolean $with_values
|
* @param boolean $with_values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getFromString($with_values = true){
|
function getFromString($with_values = TRUE){
|
||||||
$from = '';
|
$from = '';
|
||||||
$simple_table_count = 0;
|
$simple_table_count = 0;
|
||||||
foreach($this->tables as $table){
|
foreach($this->tables as $table){
|
||||||
|
|
@ -360,7 +382,7 @@
|
||||||
* @param boolean $with_optimization
|
* @param boolean $with_optimization
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getWhereString($with_values = true, $with_optimization = true){
|
function getWhereString($with_values = TRUE, $with_optimization = TRUE){
|
||||||
$where = '';
|
$where = '';
|
||||||
$condition_count = 0;
|
$condition_count = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,8 @@
|
||||||
parent::SelectExpression($column_name, $alias);
|
parent::SelectExpression($column_name, $alias);
|
||||||
|
|
||||||
if(!is_bool($click_count)){
|
if(!is_bool($click_count)){
|
||||||
error_log("Click_count value for $column_name was not boolean", 0);
|
// error_log("Click_count value for $column_name was not boolean", 0);
|
||||||
$this->click_count = false;
|
$this->click_count = false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$this->click_count = $click_count;
|
$this->click_count = $click_count;
|
||||||
}
|
}
|
||||||
|
|
@ -39,7 +38,15 @@
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getExpression(){
|
function getExpression(){
|
||||||
return "$this->column_name = $this->column_name + 1";
|
$db_type = Context::getDBType();
|
||||||
|
if($db_type == 'cubrid')
|
||||||
|
{
|
||||||
|
return "INCR($this->column_name)";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "$this->column_name";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
function getExpressionString(){
|
function getExpressionString(){
|
||||||
if($this->name == '*') return "new StarExpression()";
|
if($this->name == '*') return "new StarExpression()";
|
||||||
if($this->click_count)
|
if($this->click_count)
|
||||||
return sprintf('new ClickCountExpression(%s, %s, $args->%s)', $this->name, $this->alias,$this->click_count);
|
return sprintf('new ClickCountExpression(\'%s\', %s, $args->%s)', $this->name, $this->alias ? '\'' . $this->alias . '\'' : "''",$this->click_count);
|
||||||
if(strpos($this->name, '$') === 0)
|
if(strpos($this->name, '$') === 0)
|
||||||
return sprintf('new SelectExpression($args->%s)', substr($this->name, 1));
|
return sprintf('new SelectExpression($args->%s)', substr($this->name, 1));
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,9 @@
|
||||||
Context::set('status_name_list', $statusNameList);
|
Context::set('status_name_list', $statusNameList);
|
||||||
Context::set('page_navigation', $output->page_navigation);
|
Context::set('page_navigation', $output->page_navigation);
|
||||||
|
|
||||||
|
$oSecurity = new Security();
|
||||||
|
$oSecurity->encodeHTML('document_list..variables.');
|
||||||
|
|
||||||
// set a search option used in the template
|
// set a search option used in the template
|
||||||
$count_search_option = count($this->search_option);
|
$count_search_option = count($this->search_option);
|
||||||
for($i=0;$i<$count_search_option;$i++) {
|
for($i=0;$i<$count_search_option;$i++) {
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@
|
||||||
$buff = '<?php if(!defined("__ZBXE__")) exit();'."\n";
|
$buff = '<?php if(!defined("__ZBXE__")) exit();'."\n";
|
||||||
foreach($ftp_info as $key => $val) {
|
foreach($ftp_info as $key => $val) {
|
||||||
if(!$val) continue;
|
if(!$val) continue;
|
||||||
if(preg_match('/(<\?|<\?php|\?>)/xsm', preg_replace('/\s/', '', $val)))
|
if(preg_match('/(<\?|<\?php|\?>|fputs|fopen|fwrite|fgets|fread|\/\*|\*\/|chr\()/xsm', preg_replace('/\s/', '', $val)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
|
||||||
|
require_once(_XE_PATH_.'classes/db/queryparts/expression/ClickCountExpression.class.php');
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
|
||||||
require_once(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
require_once(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ class DBTest extends PHPUnit_Framework_TestCase {
|
||||||
$querySql = $db->{$methodName}($output);
|
$querySql = $db->{$methodName}($output);
|
||||||
|
|
||||||
// Remove whitespaces, tabs and all
|
// Remove whitespaces, tabs and all
|
||||||
|
if(is_a($querySql, 'Object'))
|
||||||
|
{
|
||||||
|
$querySql = $querySql->getMessage();
|
||||||
|
}
|
||||||
$querySql = Helper::cleanString($querySql);
|
$querySql = Helper::cleanString($querySql);
|
||||||
$expected = Helper::cleanString($expected);
|
$expected = Helper::cleanString($expected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -441,4 +441,15 @@
|
||||||
$this->_testPreparedQuery($xml_file, $argsString, $expected, 'getSelectSql', $expectedArgs);
|
$this->_testPreparedQuery($xml_file, $argsString, $expected, 'getSelectSql', $expectedArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue 1431 - xml click count error
|
||||||
|
*/
|
||||||
|
function testClickCount()
|
||||||
|
{
|
||||||
|
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/click_count.xml";
|
||||||
|
$argsString = '$args->incr_expose_count = true;';
|
||||||
|
$expected = 'select INCR("expose_count") from "xe_modules" as "modules"';
|
||||||
|
$this->_test($xml_file, $argsString, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<query id="getNewestDocuments" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="modules" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="expose_count" click_count="incr_expose_count"/>
|
||||||
|
</columns>
|
||||||
|
</query>
|
||||||
|
|
@ -402,4 +402,15 @@ class MysqlSelectTest extends MysqlTest {
|
||||||
$expected = "select convert(`document_srl`, unsigned integer) from `xe_documents` as `documents`";
|
$expected = "select convert(`document_srl`, unsigned integer) from `xe_documents` as `documents`";
|
||||||
$this->_test($xml_file, $argsString, $expected);
|
$this->_test($xml_file, $argsString, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue 1431 - xml click count error
|
||||||
|
*/
|
||||||
|
function testClickCount()
|
||||||
|
{
|
||||||
|
$xml_file = _TEST_PATH_ . "db/xml_query/mysql/data/click_count.xml";
|
||||||
|
$argsString = '$args->incr_expose_count = true;';
|
||||||
|
$expected = "select `expose_count` from `xe_modules` as `modules`";
|
||||||
|
$this->_test($xml_file, $argsString, $expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
8
tests/classes/db/db/xml_query/mysql/data/click_count.xml
Normal file
8
tests/classes/db/db/xml_query/mysql/data/click_count.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<query id="getNewestDocuments" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="modules" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="expose_count" click_count="incr_expose_count"/>
|
||||||
|
</columns>
|
||||||
|
</query>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue