/** * Quotes left and right hand primitive values according to node type * @param mixed $left_v the lhs value (will be modified) * @param string $left_nt the lhs node type * @param mixed $right_v the rhs value (will be modified) * @param string $right_nt the rhs node type * @return string|true */ protected function qq(&$left_v, $left_nt, &$right_v, $right_nt) { // case one: left variable, right value if ($left_nt == EPQ_N_VARIABLE && $right_nt != EPQ_N_VARIABLE && false === strpos($right_nt, 'EPQ_N_EXPR_')) { if ($right_nt != EPQ_N_NUMBER) { return $this->_qq($right_v, $left_v); } else { return $this->_qq($dummy = '', $left_v); } } else { if ($left_nt != EPQ_N_VARIABLE && false === strpos($left_nt, 'EPQ_N_EXPR_') && $right_nt == EPQ_N_VARIABLE) { if ($left_nt != EPQ_N_NUMBER) { return $this->_qq($left_v, $right_v); } else { return $this->_qq($dummy = '', $right_v); } } } // case three: left func, right value if (false !== strpos($left_nt, 'EPQ_N_FUNC_') && $right_nt != EPQ_N_VARIABLE && false === strpos($right_nt, 'EPQ_N_EXPR_')) { if ($right_nt != EPQ_N_NUMBER) { $right_v = $this->pm->quote($right_v); } return true; } else { if ($right_nt == EPQ_N_EXPR_UNARY && $left_nt == EPQ_N_VARIABLE && ($right_v == 'NULL' || $right_v == 'NOT NULL')) { return $this->_qq($dummy = '', $left_v); } else { if ($right_nt == EPQ_N_VARIABLE && $left_nt == EPQ_N_VARIABLE) { $this->_qq($dummy = '', $left_v); $this->_qq($dummy = '', $right_v); } } } // done for all else return true; }