mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
Issue 1819: CUBRID prepare statement error
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10525 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f0eecb4809
commit
c2df2f3a45
10 changed files with 201 additions and 71 deletions
|
|
@ -179,6 +179,8 @@
|
|||
{
|
||||
$value = $param->getUnescapedValue();
|
||||
$type = $param->getType();
|
||||
|
||||
if($param->isColumnName()) continue;
|
||||
|
||||
switch($type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -135,18 +135,19 @@
|
|||
|
||||
if(count($this->param)){
|
||||
foreach($this->param as $k => $o){
|
||||
if($o->getType() == 'number'){
|
||||
$value = $o->getUnescapedValue();
|
||||
if(is_array($value)) $_param = array_merge($_param, $value);
|
||||
else $_param[] = $o->getUnescapedValue();
|
||||
}else{
|
||||
$value = $o->getUnescapedValue();
|
||||
if(is_array($value)) {
|
||||
foreach($value as $v)
|
||||
$_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
}
|
||||
else $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
}
|
||||
if($o->isColumnName()) continue;
|
||||
if($o->getType() == 'number'){
|
||||
$value = $o->getUnescapedValue();
|
||||
if(is_array($value)) $_param = array_merge($_param, $value);
|
||||
else $_param[] = $o->getUnescapedValue();
|
||||
}else{
|
||||
$value = $o->getUnescapedValue();
|
||||
if(is_array($value)) {
|
||||
foreach($value as $v)
|
||||
$_param[] = array($v, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
}
|
||||
else $_param[] = array($value, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING('utf-8'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,14 +112,16 @@
|
|||
}
|
||||
|
||||
// 2. Bind parameters
|
||||
call_user_func_array('mysqli_stmt_bind_param',$args);
|
||||
$status = call_user_func_array('mysqli_stmt_bind_param',$args);
|
||||
if(!$status)
|
||||
$this->setError(-1, "Invalid arguments: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
|
||||
}
|
||||
|
||||
// 3. Execute query
|
||||
$status = mysqli_stmt_execute($stmt);
|
||||
|
||||
if(!$status)
|
||||
$this->setError(-1, "Prepared statement failed: $query");
|
||||
$this->setError(-1, "Prepared statement failed: $query" . mysqli_error($connection) . PHP_EOL . print_r($args, true));
|
||||
|
||||
// Return stmt for other processing - like retrieving resultset (_fetch)
|
||||
return $stmt;
|
||||
|
|
@ -146,6 +148,10 @@
|
|||
foreach($this->param as $k => $o){
|
||||
$value = $o->getUnescapedValue();
|
||||
$type = $o->getType();
|
||||
|
||||
// Skip column names -> this should be concatenated to query string
|
||||
if($o->isColumnName()) continue;
|
||||
|
||||
switch($type)
|
||||
{
|
||||
case 'number' :
|
||||
|
|
|
|||
|
|
@ -223,34 +223,36 @@
|
|||
|
||||
function getWhereString($with_values = true, $with_optimization = true){
|
||||
$where = '';
|
||||
$condition_count = 0;
|
||||
|
||||
foreach($this->conditions as $conditionGroup){
|
||||
if($condition_count === 0){
|
||||
$conditionGroup->setPipe("");
|
||||
}
|
||||
$condition_string = $conditionGroup->toString($with_values);
|
||||
$where .= $condition_string;
|
||||
$condition_count++;
|
||||
}
|
||||
|
||||
if($with_optimization &&
|
||||
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))){
|
||||
|
||||
if($condition_count !== 0) $where = '(' . $where .') ';
|
||||
|
||||
foreach($this->orderby as $order){
|
||||
$colName = $order->getColumnName();
|
||||
if(strstr($colName, 'list_order') || strstr($colName, 'update_order')){
|
||||
$opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
|
||||
if ($condition_count === 0) $opt_condition->setPipe("");
|
||||
$where .= $opt_condition->toString($with_values).' ';
|
||||
$condition_count++;
|
||||
$condition_count = 0;
|
||||
|
||||
foreach ($this->conditions as $conditionGroup) {
|
||||
if ($condition_count === 0) {
|
||||
$conditionGroup->setPipe("");
|
||||
}
|
||||
}
|
||||
$condition_string = $conditionGroup->toString($with_values);
|
||||
$where .= $condition_string;
|
||||
$condition_count++;
|
||||
}
|
||||
|
||||
return trim($where);
|
||||
|
||||
if ($with_optimization &&
|
||||
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))) {
|
||||
|
||||
if ($condition_count !== 0)
|
||||
$where = '(' . $where . ') ';
|
||||
|
||||
foreach ($this->orderby as $order) {
|
||||
$colName = $order->getColumnName();
|
||||
if (strstr($colName, 'list_order') || strstr($colName, 'update_order')) {
|
||||
$opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and');
|
||||
if ($condition_count === 0)
|
||||
$opt_condition->setPipe("");
|
||||
$where .= $opt_condition->toString($with_values) . ' ';
|
||||
$condition_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trim($where);
|
||||
}
|
||||
|
||||
function getGroupByString(){
|
||||
|
|
|
|||
|
|
@ -24,13 +24,21 @@
|
|||
}
|
||||
|
||||
function toString($withValue = true){
|
||||
if(!isset($this->_value_to_string)){
|
||||
if(!$this->show()) { $this->_value_to_string = ''; }
|
||||
else if($withValue)
|
||||
$this->_value_to_string = $this->toStringWithValue();
|
||||
else $this->_value_to_string = $this->toStringWithoutValue();
|
||||
}
|
||||
return $this->_value_to_string;
|
||||
if (!isset($this->_value_to_string)) {
|
||||
if (!$this->show())
|
||||
{
|
||||
$this->_value_to_string = '';
|
||||
}
|
||||
else if ($withValue)
|
||||
{
|
||||
$this->_value_to_string = $this->toStringWithValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_value_to_string = $this->toStringWithoutValue();
|
||||
}
|
||||
}
|
||||
return $this->_value_to_string;
|
||||
}
|
||||
|
||||
function toStringWithoutValue(){
|
||||
|
|
|
|||
|
|
@ -14,16 +14,27 @@
|
|||
}
|
||||
|
||||
function toStringWithoutValue(){
|
||||
$value = $this->argument->getUnescapedValue();
|
||||
$value = $this->argument->getUnescapedValue();
|
||||
|
||||
if(is_array($value)){
|
||||
$q = '';
|
||||
foreach ($value as $v) $q .= '?,';
|
||||
if($q !== '') $q = substr($q, 0, -1);
|
||||
$q = '(' . $q . ')';
|
||||
}
|
||||
else $q = '?';
|
||||
return $this->pipe . ' ' . $this->getConditionPart($q);
|
||||
if(is_array($value)){
|
||||
$q = '';
|
||||
foreach ($value as $v) $q .= '?,';
|
||||
if($q !== '') $q = substr($q, 0, -1);
|
||||
$q = '(' . $q . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
|
||||
if($this->argument->isColumnName())
|
||||
{
|
||||
$q = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$q = '?';
|
||||
}
|
||||
}
|
||||
return $this->pipe . ' ' . $this->getConditionPart($q);
|
||||
}
|
||||
|
||||
function show(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue