Returns a PDO query resource ready for execution for an SQL union
@param array $arrParam SQL Parameter Array
@param array $arrParam SQL Parameter Array
... etc
@return \PDOStatement
8858
public function genUnionQuery  ()
	{

		$sql	= $this->genUnionSQL (func_get_args (), 'UNION ALL');

		// Prepare database query

		$query	= $this->prepare ($sql);
		
		// Bind values
		
		$this->genUnionBindValues ($query, func_get_args ());

		// Return query

		return $query;

	}
592946
private function pdoPrepare($sql)
    {
        try {
            $pdoStatement = $this->getPdo()->prepare($sql);
        } catch (\PDOException $e) {
            throw new \RuntimeException("Failed to prepare SQL query: {$sql} << {$e->getMessage()}", 0, $e);
        }

        return $pdoStatement;
    }
328422
protected function bindParams($stm, $sqlParams)
    {
        if (empty($sqlParams)) {
            $sqlParams = [];
        }
        uksort(
            $sqlParams,
            function ($k1, $k2) {
                return strlen($k1) < strlen($k2);
            }
        );
        $paramNum = 0;
        foreach ($sqlParams as $paName => $paValue) {
            $type = gettype($paValue);
            if ($type === 'array') {
                foreach ($paValue as $i=>$value) {
                    $paramType = $this->typeToPDOParamType(gettype($value));
                    $paramName = ":pdoParam$paramNum";
                    $paramNum++;
                    // $stm->bindValue($paName . "_param$i", $value, $paramType);
                    $stm->bindValue($paramName, $value, $paramType);
                }
            } else {
                $paramType = $this->typeToPDOParamType($type);
                $stm->bindValue($paName, $paValue, $paramType);
            }
        }
    }
497795
public function getRow($sql, array $args = [])
    {
        $result = $this->query($sql, $args);
        
        if (!$result) {
            return [];
        }
        
        $row = $result->fetch_row();
        
        return $row;
    }
966600
public static function uriParams2Array(string $uriParams) : array
    {
        $stringUriParams = str_replace("?", "", $uriParams);
        $arrSingleParams = explode("&", $stringUriParams);
        
        $arrReturn = [];
        
        foreach ($arrSingleParams as $param) {
            $arrParam = explode("=", $param);
            $key = $arrParam[0];
            $val = '';
            if (isset($arrParam[1])) {
                $val = $arrParam[1];
            }
            $arrReturn[urldecode($key)] = urldecode($val);
        }
        return $arrReturn;
    }
1075529
public static function check(array $pParams)
    {
        foreach ($pParams as $type => $value) {
            $func = 'is' . $type;

            if (method_exists(__CLASS__, $func)) {
                if (is_array($value)) {
                    foreach ($value as $subValue) {
                        if (self::$func($subValue) === false) {
                            return false;
                        }
                    }
                } else if (self::$func($value) === false) {
                    return false;
                }
            } else {
                if (! self::isRegex($type, $value)) {
                    return false;
                }
            }
        }

        return true;
    }
635443
function query($sql, $parms = array(), $alias = null)
    {
        $this->sql = $sql;
        $sth = $this->connect($alias)->prepare($sql);
        $sth->execute($parms);
        $this->rows = $sth->rowCount();
        $this->error[$sql] = $sth->errorInfo();

        if ($sth->columnCount() > 0) {
            return $this->result = $sth->fetchAll(PDO::FETCH_CLASS, __NAMESPACE__.'\Row', [$this->sql, $parms]);
        } else {
            $this->result = false;
            return $this->rows;
        }
    }
127657
public function getValueFrom(array $values, $argName, $argAltName) {
		if( isset($values[$argName]) ) {
			return $values[$argName];
		}
		if( $argAltName && isset($values[$argAltName]) ) {
			return $values[$argAltName];
		}
		return null;
	}
565636
function DBParameter($param)
	{
		if (empty($this->settings[$param])) return false;
		$sql = $this->settings[$param][1];
		return $this->_DBParameter($sql);
	}
344658
public static function get(array $arg_params)
    {
        //validate params
        $data = self::getParams($arg_params);
        $url = '/ecommerce/customers';
        if(!empty($data['id'])){
            $url .= '/'.$data['id'];
        }else{
            return null;
        }

        //submit to api
        $customer_data = APIRequests::request(
            $url,
            APIRequests::METHOD_GET
        );

        //return response
        return self::toObj($customer_data['body']);
    }
668419
public function sql($query, $args = []) {
		if (!is_string($query) || empty($query))
			throw new \InvalidArgumentException("Query is not a valid string");
	
		//open connection
		$this->driver->connect();
			
		//build statement
		$stmt = $this->driver->buildStatement($this->typeManager);
	
		//build query
		$query = $stmt->format($query, $args, $this->config);
		
		//invoke debug callback
		if ($this->hasOption('callback.debug')) {
			$callback = $this->getOption('callback.debug');
			if ($callback instanceof \Closure)
				$callback->__invoke($query);
		}
		
		//run query
		$result = $this->driver->query($query);
	
		//check query execution
		if ($result === false)
			$this->driver->throwQueryException($stmt);
	
		return $result;
	}
1144802
private function prepareArrayQuery(string $param_name, array $params): array
    {
        $params_name = [];
        $params_val = [];
        
        foreach ($params as $key => $val) {
            $name = ':' . 'arr_' . $key;
            $params_name[] = $name;
            $params_val[$name] = $val;
        }
        
        $sql = implode(', ', $params_name);
        
        str_replace($param_name, $sql, $this->sql);
        array_merge($this->params, $params_val);
        
        return [
            'sql' => $sql,
            'values' => $params_val
        ];
    }
616087
public function fetchAll($str_query = null, $arr_params = null)
    {
        if(null !== $str_query) {
            $this->query($str_query, $arr_params);
        }
        $arr_results = $this->obj_gateway
            ->withSchema($this->obj_schema)
            ->withTransaction($this->str_transaction_id)
            ->gql($this->str_last_query, $this->arr_last_params);
        return $arr_results;
    }
878118
function getQueryStatement(PDO $conn = null) {
		if (0 === count($this->conds)) {
			return null;
		}

		$stmnt = new QueryStatement($conn);

		$is_first = true;
		$is_second = false;
		foreach ($this->conds as &$cond) {
			$cond_stmnt = null;

			// avoid call_user_func_array for better stack traces
			switch (count($cond[1])) {
				case 1:
					$cond_stmnt = self::processCondition($cond[1][0]);
					break;
				case 2:
					$cond_stmnt = self::processCondition($cond[1][0], $cond[1][1]);
					break;
				case 3:
					$cond_stmnt = self::processCondition($cond[1][0], $cond[1][1], $cond[1][2]);
					break;
				case 4:
					$cond_stmnt = self::processCondition($cond[1][0], $cond[1][1], $cond[1][2], $cond[1][3]);
					break;
			}

			if (null === $cond_stmnt) {
				continue;
			}

			if ($is_first) {
				$sep = '';
				$is_first = false;
				$is_second = true;
			} else {
				$sep = (($is_second && 'OR' === $this->conds[0][0]) ? 'OR' : $cond[0]) . ' ';
				$is_second = false;
			}

			$stmnt->string .= "\n\t$sep" . $cond_stmnt->string;
			$stmnt->addParams($cond_stmnt->params);
			$stmnt->addIdentifiers($cond_stmnt->identifiers);
		}
		return $stmnt;
	}
1108681
public function arosBuilder() {
        
        $newAros = array();
        $counter = 0;        
        $parent = null;
        
        $models = Configure::read('AclManager.aros');
        // foreach ($models as $model) {
        for($i = 0; $i < count($models); $i++) {
            $model = $models[$i];
            $this->{$model} = TableRegistry::get($model);

            // Build the roles.
            $items = $this->{$model}->find('all');
            foreach($items as $item) {
                if($i > 0 && isset($models[$i-1])) {
                    $pk = strtolower(Inflector::singularize($models[$i-1])).'_id';
                    $parent = $this->Aro->find('all',
                        ['conditions' => [
                            'model' => $models[$i-1],
                            'foreign_key' => $item->{$pk}
                        ]])->first();
                }
                
                // Prepare alias
                $alias = null;
                if(isset($item->name)) {
                    $alias = $item->name;
                }
                
                if(isset($item->username)) {
                    $alias = $item->username;
                }
                
                // Create aro
                $aro = new Aro([
                    'alias' => $alias,
                    'foreign_key' => $item->id,
                    'model' => $model,
                    'parent_id' => (isset($parent->id)) ? $parent->id : Null
                ]);

                if($this->__findAro($aro) == 0 && $this->Acl->Aro->save($aro)) {  
                    $counter++;
                }
            }
        }
        
        return $counter;
    }
433189
public function getRow($sql, array $args = [])
    {
        $query = $this->query($sql, $args);
        if (!$query) {
            return [];
        }
        
        $rs = $query->fetch(\PDO::FETCH_ASSOC);
        return $rs;
    }
1144623
public function query($url = '', $argsOrParams = array(), $params = array())
    {
        if (strpos($url, '%s') === false) {
            $argsOrParams = $argsOrParams + $this->request->getQueries();
        } else {
            $params += $this->request->getQueries();
        }
        return $this->__invoke($url, $argsOrParams, $params);
    }