You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public function http_testMysqlRaw()
{
$selectMiner = $this->mysql_pool->dbQueryBuilder->select('*')->from('account');
$selectMiner = $selectMiner->where('', '(status = 1 and dec in ("ss", "cc")) or name = "kk"', Miner::LOGICAL_RAW);
$this->http_output->end($selectMiner->getStatement(false));
}
版本2.1.5
1.在设置where条件时只支持某个字段或者数组的形式。不支持在已有sql直接拼接一段字符串形成新的sql
例如:
不固定 (status = 1 and dec in ("ss", "cc")) or name = "kk"
2.解决方案
/Server/Asyn/Mysql/Miner.php
/**
* AND logical operator. 参考laravel起名
*/
(1) const LOGICAL_RAW = "RAW";
(2) 方法里的getCriteriaString
从原先的
case self::IS:
case self::IS_NOT:
改成
case self::LOGICAL_RAW:
case self::IS:
case self::IS_NOT:
(3)
在方法里
从原先
$statement .= $criterion['column'] . " " . $criterion['operator'] . " " . $value;
改成
if ($criterion['operator'] == self::LOGICAL_RAW) {
$statement .= " " . $value . " ";
} else {
$statement .= $criterion['column'] . " " . $criterion['operator'] . " " . $value;
}
3.调用效果支持
$selectMiner = $selectMiner->openWhere();
//wheres 代表 不固定 (status = 1 and dec in ("ss", "cc")) or name = "kk"
$selectMiner = $selectMiner->where('', $wheres, 'RAW');
$selectMiner = $selectMiner->closeWhere();
The text was updated successfully, but these errors were encountered: