Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 按相关模型列排列的phalcon订单_Mysql_Phalcon - Fatal编程技术网

Mysql 按相关模型列排列的phalcon订单

Mysql 按相关模型列排列的phalcon订单,mysql,phalcon,Mysql,Phalcon,我想从表用户那里获取记录,这些用户按从相关表配置文件中查看的列排序。关键是我想用模型的方式来做 我只想在下面写一个查询,并得到相应的模型。 查询: 看我的例子 $Users = \User::query() ->leftJoin('UserDependence') ->where(implode(" AND ", $conditions)) ->bind($parameters) ->orderBy("Use

我想从表用户那里获取记录,这些用户按从相关表配置文件中查看的列排序。关键是我想用模型的方式来做

我只想在下面写一个查询,并得到相应的模型。 查询:

看我的例子

$Users = \User::query()
        ->leftJoin('UserDependence')
        ->where(implode(" AND ", $conditions))
        ->bind($parameters)
        ->orderBy("User.id DESC")
        ->bindTypes([
            "email" => Column::BIND_PARAM_STR,
            "active" => Column::BIND_PARAM_BOOL,
            "tags"  => Column::BIND_PARAM_STR
        ])
        ->execute();

    $paginator   = new PaginatorModel(
        array(
            "data"  => $Users,
            "limit" => 10,
            "page"  => (int) $this->request->get("page")
        )
    );

您可以使用模型管理器编写自己的SQL查询,如以下或任何类型。下面是一个链接,其中包含我尝试使用modelsManager执行此操作的示例,但phql和JOIN似乎有问题。我的意思是,当我执行简单的SELECT查询时,我可以在结果集上执行->toArray,但是当我尝试使用JOIN在查询中实现相同的操作时,我得到了具有非常奇怪构造的Phalcon\Mvc\Model\Row。还请注意,来自的示例不适用于我。有什么想法吗?事实上我解决了我的问题。我只需要查看所有用户,并将其添加到我的reslut数组键中,然后进行自定义多重排序,得到了我想要的结果。也许这个解决方案不如使用单个查询那么好,但已经足够了。谢谢你的帮助。
$Users = \User::query()
        ->leftJoin('UserDependence')
        ->where(implode(" AND ", $conditions))
        ->bind($parameters)
        ->orderBy("User.id DESC")
        ->bindTypes([
            "email" => Column::BIND_PARAM_STR,
            "active" => Column::BIND_PARAM_BOOL,
            "tags"  => Column::BIND_PARAM_STR
        ])
        ->execute();

    $paginator   = new PaginatorModel(
        array(
            "data"  => $Users,
            "limit" => 10,
            "page"  => (int) $this->request->get("page")
        )
    );