mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-20 19:02:14 +09:00
DBMssql class - working version of XE with SQL Server.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8535 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
33c0923009
commit
763fc6d56b
5 changed files with 97 additions and 30 deletions
|
|
@ -166,10 +166,11 @@
|
|||
|
||||
if(count($this->param)){
|
||||
foreach($this->param as $k => $o){
|
||||
if($o['type'] == 'number'){
|
||||
$_param[] = &$o['value'];
|
||||
if($o->getType() == 'number'){
|
||||
$_param[] = $o->getUnescapedValue();
|
||||
}else{
|
||||
$_param[] = array(&$o['value'], SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
$value = $o->getUnescapedValue();
|
||||
$_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -414,7 +415,8 @@
|
|||
**/
|
||||
// TODO Lookup _filterNumber against sql injection - see if it is still needed and how to integrate
|
||||
function _executeInsertAct($queryObject) {
|
||||
$query = '';
|
||||
$query = $this->getInsertSql($queryObject);
|
||||
$this->param = $queryObject->getArguments();
|
||||
return $this->_query($query);
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +424,8 @@
|
|||
* @brief Handle updateAct
|
||||
**/
|
||||
function _executeUpdateAct($queryObject) {
|
||||
$query = '';
|
||||
$query = $this->getUpdateSql($queryObject);
|
||||
$this->param = $queryObject->getArguments();
|
||||
return $this->_query($query);
|
||||
}
|
||||
|
||||
|
|
@ -430,7 +433,8 @@
|
|||
* @brief Handle deleteAct
|
||||
**/
|
||||
function _executeDeleteAct($queryObject) {
|
||||
$query = '';
|
||||
$query = $this->getDeleteSql($queryObject);
|
||||
$this->param = $queryObject->getArguments();
|
||||
return $this->_query($query);
|
||||
}
|
||||
|
||||
|
|
@ -477,14 +481,61 @@
|
|||
* it supports a method as navigation
|
||||
**/
|
||||
function _executeSelectAct($queryObject) {
|
||||
$query = $this->getSelectSql($queryObject);
|
||||
|
||||
// TODO Decide if we continue to pass parameters like this
|
||||
$this->param = $queryObject->getArguments();
|
||||
|
||||
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf(' '.$this->comment_syntax,$this->query_id):'';
|
||||
$result = $this->_query($query);
|
||||
if($this->isError()) return;
|
||||
$data = $this->_fetch($result);
|
||||
|
||||
$buff = new Object();
|
||||
$buff->data = $data;
|
||||
return $buff;
|
||||
if ($this->isError ()) {
|
||||
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()){
|
||||
$buff = new Object ();
|
||||
$buff->total_count = 0;
|
||||
$buff->total_page = 0;
|
||||
$buff->page = 1;
|
||||
$buff->data = array ();
|
||||
$buff->page_navigation = new PageHandler (/*$total_count*/0, /*$total_page*/1, /*$page*/1, /*$page_count*/10);//default page handler values
|
||||
return $buff;
|
||||
}else
|
||||
return;
|
||||
}
|
||||
|
||||
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()) {
|
||||
// Total count
|
||||
$count_query = sprintf('select count(*) as "count" %s %s', 'FROM ' . $queryObject->getFromString(), ($queryObject->getWhereString() === '' ? '' : ' WHERE '. $queryObject->getWhereString()));
|
||||
if ($queryObject->getGroupByString() != '') {
|
||||
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
|
||||
}
|
||||
|
||||
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
|
||||
$result_count = $this->_query($count_query);
|
||||
$count_output = $this->_fetch($result_count);
|
||||
$total_count = (int)$count_output->count;
|
||||
|
||||
// Total pages
|
||||
if ($total_count) {
|
||||
$total_page = (int) (($total_count - 1) / $queryObject->getLimit()->list_count) + 1;
|
||||
} else $total_page = 1;
|
||||
|
||||
|
||||
$virtual_no = $total_count - ($queryObject->getLimit()->page - 1) * $queryObject->getLimit()->list_count;
|
||||
$data = $this->_fetch($result, $virtual_no);
|
||||
|
||||
$buff = new Object ();
|
||||
$buff->total_count = $total_count;
|
||||
$buff->total_page = $total_page;
|
||||
$buff->page = $queryObject->getLimit()->page;
|
||||
$buff->data = $data;
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $queryObject->getLimit()->page, $queryObject->getLimit()->page_count);
|
||||
}else{
|
||||
$data = $this->_fetch($result);
|
||||
$buff = new Object ();
|
||||
$buff->data = $data;
|
||||
}
|
||||
|
||||
return $buff;
|
||||
}
|
||||
|
||||
function getParser(){
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@
|
|||
|
||||
$result = $this->_query ($query);
|
||||
if ($this->isError ()) {
|
||||
if ($limit && $output->limit->isPageHandler()){
|
||||
if ($queryObject->getLimit() && $queryObject->getLimit()->isPageHandler()){
|
||||
$buff = new Object ();
|
||||
$buff->total_count = 0;
|
||||
$buff->total_page = 0;
|
||||
|
|
|
|||
|
|
@ -204,12 +204,14 @@
|
|||
$this->arguments = array();
|
||||
|
||||
// Column arguments
|
||||
foreach($this->columns as $column){
|
||||
if($column->show()){
|
||||
$arg = $column->getArgument();
|
||||
if($arg) $this->arguments[] = $arg;
|
||||
}
|
||||
}
|
||||
if(count($this->columns) > 0){ // The if is for delete statements, all others must have columns
|
||||
foreach($this->columns as $column){
|
||||
if($column->show()){
|
||||
$arg = $column->getArgument();
|
||||
if($arg) $this->arguments[] = $arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Condition arguments
|
||||
if(count($this->conditions) > 0)
|
||||
|
|
|
|||
|
|
@ -26,8 +26,30 @@
|
|||
}
|
||||
|
||||
function getValue(){
|
||||
if(is_array($this->value)) return implode(',', $this->value);
|
||||
return $this->value;
|
||||
$value = $this->escapeValue($this->value);
|
||||
return $this->toString($value);
|
||||
}
|
||||
|
||||
function getUnescapedValue(){
|
||||
return $this->toString($this->value);
|
||||
}
|
||||
|
||||
function toString($value){
|
||||
if(is_array($value)) return implode(',', $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
function escapeValue($value){
|
||||
if(in_array($this->type, array('date', 'varchar', 'char','text', 'bigtext'))){
|
||||
if(!is_array($value))
|
||||
$value = '\''.$value.'\'';
|
||||
else {
|
||||
$total = count($value);
|
||||
for($i = 0; $i < $total; $i++)
|
||||
$value[$i] = '\''.$value[$i].'\'';
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
function getType(){
|
||||
|
|
@ -54,15 +76,7 @@
|
|||
$this->type = $column_type;
|
||||
|
||||
//if($column_type === '') $column_type = 'varchar';
|
||||
if(in_array($column_type, array('date', 'varchar', 'char','text', 'bigtext'))){
|
||||
if(!is_array($this->value))
|
||||
$this->value = '\''.$this->value.'\'';
|
||||
else {
|
||||
$total = count($this->value);
|
||||
for($i = 0; $i < $total; $i++)
|
||||
$this->value[$i] = '\''.$this->value[$i].'\'';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkFilter($filter_type){
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<param name="db_database" target="db_database" />
|
||||
<param name="db_table_prefix" target="db_table_prefix" />
|
||||
</parameter>
|
||||
<response callback_func="completeInstalled">
|
||||
<response callback_func="completeDBSetting">
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
</response>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue