Creates and returns SQL parts used in fetch functions

@param array $params

@return array
487188
public function createSqlParts( $params )
    {
        $returnArray = array( 'tables' => '', 'joins'  => '', 'columns' => '' );

        if ( !isset( $params['parent_tag_id'] ) )
        {
            return $returnArray;
        }

        if ( is_array( $params['parent_tag_id'] ) )
        {
            $parentTagIDsArray = $params['parent_tag_id'];
        }
        else if ( (int) $params['parent_tag_id'] > 0 )
        {
            $parentTagIDsArray = array( (int) $params['parent_tag_id'] );
        }
        else
        {
            return $returnArray;
        }

        $suffix = '/%';
        if ( isset( $params['exclude_parent'] ) && $params['exclude_parent'] )
        {
            $suffix = '/%/%';
        }

        $returnArray['tables'] = " INNER JOIN eztags_attribute_link i1 ON (i1.object_id = ezcontentobject.id AND i1.objectattribute_version = ezcontentobject.current_version)
                                   INNER JOIN eztags i2 ON (i1.keyword_id = i2.id)
                                   INNER JOIN eztags_keyword i3 ON (i2.id = i3.keyword_id)";

        $db = eZDB::instance();
        $dbStrings = array();

        if ( isset( $params['type'] ) && strtolower( $params['type'] ) == 'and' )
        {
            foreach ( $parentTagIDsArray as $parentTagID )
            {
                $dbStrings[] = "EXISTS (
                    SELECT 1
                    FROM
                        eztags_attribute_link j1,
                        ezcontentobject j2,
                        eztags j3
                    WHERE j3.path_string LIKE \"%/" . $db->escapeString( $parentTagID . $suffix ) . "
                    AND j1.object_id = j2.id
                    AND j2.id = ezcontentobject.id
                    AND j1.objectattribute_version = j2.current_version
                    AND j3.id = j1.keyword_id
                )";
            }

            $dbString = implode( ' AND ', $dbStrings );
        }
        else
        {
            foreach ( $parentTagIDsArray as $parentTagID )
            {
                $dbStrings[] = ' i2.path_string LIKE "%/' . $db->escapeString( $parentTagID . $suffix ) . '"';
            }

            $dbString = implode( ' OR ', $dbStrings );
        }

        if ( isset( $params['language'] ) )
        {
            $language = $params['language'];
            if ( !is_array( $language ) )
            {
                $language = array( $language );
            }

            eZContentLanguage::setPrioritizedLanguages( $language );
        }


        $returnArray['joins'] = " ( $dbString )
                                  AND " . eZContentLanguage::languagesSQLFilter( 'i2' ) . " AND " .
                                  eZContentLanguage::sqlFilter( 'i3', 'i2' ) . " AND ";

        if ( isset( $params['language'] ) )
        {
            eZContentLanguage::clearPrioritizedLanguages();
        }

        return $returnArray;
    }
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
        ];
    }
1088303
public function getList($params = array()) {
        $this->checkPermissions('getList');
        
        return $this->client->retrieveData($this->resourceName, $params);
    }
1304266
public function fetchAll($sql, array $params = [], $types = [])
    {
        return $this->executeQuery($sql, $params, $types)->fetchAll();
    }
1147663
public function rawQuery(string $sql, array $params=[]): array
  {
    $rows = [];

    # Sanity check
    if (empty($sql)) {
      return $rows;
    }

    # Obtain transaction, unelss already in a transaction
    $autoCommit = $this->beginTransaction();

    # Prepare
    if ($sth = $this->prepare($sql)) {

      # Binds
      foreach ($params as $bind=>$value) {
        $sth->bindValue( ':'.\ltrim($bind,':'), $value);
      }

      # Execute statement
      if ($sth->execute()) {
        $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
      }

      # Close the cursor
      $sth->closeCursor();
    }

    # If we had a loacl transaction, commit it
    if ($autoCommit) $this->commit();

    return $rows;
  }
438496
public function fetchArray($params = false)
    {
        if (\count($this->values) === 0) {
            return false;
        }
        if (\count($this->values) > 1) {
            return $this->values;
        }
        if ($params === true) {
            return $this->values;
        }
        if (\is_array($params) && array_key_exists('item', $params)) {
            $item = $params['item'];
            if (array_key_exists($item, $this->values)) {
                return $this->values[$item];
            }
            if (array_key_exists($item, $this->values[0])) {
                return $this->values[0][$item];
            }
            return false;
        }

        return $this->values[0];
    }
798803
public function sqlSearch($params)
    {
        $this->load($params);

        $where =[
           'id' => sprintf('id = "%s"',$this->id),
           'status' => sprintf('status = "%s"',$this->status),
           'created_at' => sprintf('created_at = "%s"',$this->created_at),
           'updated_at' => sprintf('updated_at = "%s"',$this->updated_at),
           'username' => sprintf('username like "%s%%"',$this->username),
           'auth_key' => sprintf('auth_key like "%s%%"',$this->auth_key),
           'password_hash' => sprintf('password_hash like "%s%%"',$this->password_hash),
           'password_reset_token' => sprintf('password_reset_token like "%s%%"',$this->password_reset_token),
           'email' => sprintf('email like "%s%%"',$this->email),
        ];

        $filtedParams = array_filter($this->attributes,
            function($val){return $val!='';});

        $FiltedWhere = ['1=1'];
        foreach ($filtedParams as $key => $value) {
            $FiltedWhere[] = $where[$key];
        }

        $querySql = sprintf('
            SELECT
                %s
            FROM
                %s
            WHERE
                %s
            ', '*', $this->tableName(), implode(' AND ', $FiltedWhere));

        $countSql = sprintf('
            SELECT
                %s
            FROM
                %s
            WHERE
                %s
            ', 'count(1)', $this->tableName(), implode(' AND ', $FiltedWhere));

        $sqlDataProvider = new SqlDataProvider([
            'sql' => $querySql,
            // 'params' => [':sex' => 1],
            'totalCount' => Yii::$app->db->createCommand($countSql)->queryScalar(),
            //'sort' =>false,//如果为假则删除排序
            'key' => 'id',
            'sort' => [
                'defaultOrder' => [
                    'id' => SORT_DESC
                ],
                'attributes' => array_keys($this->attributes),
            ],
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);

        return $sqlDataProvider;
    }
275847
public function fetchAllKeyPair(string $sql, array $params = [], array $types = []): array
    {
        $stmt = $this->conn->executeQuery($sql, $params, $types);

        return $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
    }
1204547
public function getRow($sql, $params = null)
    {
        $stmt = $this->execute($sql, $params);

        return $stmt->fetch(PDO::FETCH_ASSOC);
    }
346283
public function fetch( $query, $params = array(), $arguments = array( 'obj' ) )
	{
		$sth = $this->statement( $query, $params );
		
		$args = null;
		
		foreach( $arguments as $argument )
		{
			$args |= constant( "\PDO::FETCH_".strtoupper( $argument ) );
		}
				
		return $sth->fetchAll( $args );
	}
424908
protected function mapUriPartsFromServerParams(array $params)
    {
        $parts = [];
        
        $map = [
            'PHP_AUTH_USER' => 'user',
            'PHP_AUTH_PWD' => 'password',
            'HTTP_HOST' => 'host',
            'SERVER_PORT' => 'port',
            'REQUEST_URI' => 'path',
            'QUERY_STRING' => 'query'
        ];
        
        foreach ($map as $param => $key) {
            if (isset($params[$param])) {
                $parts[$key] = $params[$param];
            }
        }
        
        return $parts;
    }
658504
protected function prepareParams(array $params)
    {
        foreach ($params as $key => $param) {
            if (gettype($param) === 'boolean') {
                $params[$key] = (string)(($param) ? 'true' : 'false');
            }
        }
        return $params;
    }
266642
public function bindParams($params)
    {
        $bindParams = [''];
        
        foreach ($params as $dbColumnName => $dbColumnValue) {
            $dbColumnValueAry = (!is_array($dbColumnValue)) ? [$dbColumnValue] : $dbColumnValue;
            
            $i = 1;
            foreach ($dbColumnValueAry as $dbColumnValueAryValue) {
                ${$dbColumnName . $i} = $dbColumnValueAryValue;
                
                if (is_numeric($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'i';
                } else if (is_double($dbColumnValueAryValue)) {
                    $bindParams[0] .= 'd';
                } else if (is_string($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else if (is_null($dbColumnValueAryValue)) {
                    $bindParams[0] .= 's';
                } else {
                    $bindParams[0] .= 'b';
                }
                
                $bindParams[] = &${$dbColumnName . $i};
                $i++;
            }
        }
        
        call_user_func_array([$this->statement, 'bind_param'], $bindParams);
        
        return $this;
    }
1276598
private function formatSqlByParams(array $params)
    {
        if (empty($params)) {
            return;
        }
        foreach ($params as $key => $value) {
            $this->sql .= " $key=" . $value;
        }
    }
537527
public function getUpdates(array $params = [])
    {
        return array_map(function (stdClass $update) {
            return Update::create($update);
        }, $this->request('getUpdates', $params)->getResult());
    }
849242
public static function fetchSQL(string $sql, array $params, string $compileDir)
    {
        $sdopx = new Sdopx();
        $sdopx->setCompileDir($compileDir);
        $sdopx->assign($params);
        $sdopx->parsingType = Sdopx::PARSING_SQL;
        return $sdopx->fetch('string:' . $sql);
    }
244973
public function query(array $params = []) {
        $this->params = array_merge($this->params, $params);
        return $this->db->query($this->sql, $this->params);
    }