如何过滤 pyrocms 中流条目驱动程序的函数 get_entries() 返回的结果?

How to filter a result returned by a function get_entries() of a stream entries driver in pyrocms?

我有一个名为 profiles 的 stream/table。它的所有列都是流场。我试图根据某些条件限制函数 get_entries() 返回的结果。下面是我的代码:

    $data = [
        'stream'    => 'profiles',
        'namespace' => 'users',
        'where'     => 'user_id = 3'     // lets say, this is my criteria
    ];

    $row = $this->streams->entries->get_entries($data); // returns empty 

变量 $row 导致空数组。虽然在 table、profiles 中有一行,其中 user_id 是 3。我已经阅读了 pyrocms 的文档,它几乎说明了使用 where 子句的确切方法(就像上面一样).

注意:我也试过像

这样写

'where' => 'profiles.user_id = 3'`

快乐!避免 table 冲突。还是没有

但是当我这样写代码的时候: $row = $this->streams->entries->get_entries($query);

        $query = [
            'stream'    => 'profiles',
            'namespace' => 'users'     
        ];
        // No where clause this time

        $row = $this->streams->entries->get_entries($query);

这次 $row returns 所有行,包括用户 ID 为 3 的行。

我无法正确使用 get_entries 中的 where 子句。我可能犯了一些错误。帮帮我 guyz

注意:我使用的是社区版。

型号

public function get_entries($table, $where) {
        $this->db->select('*');
        $this->db->from($table);
        foreach ($where as $key => $value) {
            $this->db->where($key, $value);
        }
        $this->query = $this->db->get();
        foreach ($this->query->result_array() as $row) {
            $array1[] = $row;
        }
        if ($this->query->num_rows() == 0)
            return false;
        else
            return $array1;
    }

将此模型函数称为

$row = $this->streams->entries->get_entries('profiles',array('user_id '=>3));

我认为这可能是由于错误造成的(嗯,不是错误,而是无法按预期工作的功能)。

如果我故意发出错误的查询,sql 查询输出是

SELECT [ ... ] LEFT JOIN `default_profiles` as `profiles` ON `profiles`.`user_id`=`default_profiles`.`created_by` WHERE (user_id` = 1) ORDER BY `default_profiles`.`created` DESC

在这里您看到 PyroCMS 试图查找 "created_by" 字段的数据。这在这种情况下不起作用。

如果您禁用 'created_by' 字段,您应该得到正确的行:

$this->streams->entries->get_entries(
  array(
    'stream' => 'profiles',
    'namespace' => 'users',
    'where' => 'user_id = 3',
    'disable' => 'created_by'
  )
);

如果您能在 pyrocms github 页面上提出问题,那就太好了。如果你不会,我过几天再做。