小编sco*_*nes的帖子

获取所有类别(多级)

我正在使用codeigniter并且有一个包含3列的表(id,name,parent_id).类别可以具有许多子类别,子类别可以具有许多子子类别.

我一直在尝试使用此代码获取所有类别及其子类别:

public function getCategory($id)
{
        $categories = array();
        while($id != 0)
        {
                $this->db->from('categories'); //$this->table is a field with the table of categoris
                $this->db->where('id', $id);
                $this->db->limit(1);
                $result = $this->db->get()->row(); //fetching the result
                $categories[] = $result;
                $id = $result->parent_id;
        }
        return $categories;
}

   public function getAllCategories()
    {
            $this->db->select('id');
            $this->db->from('categories'); //$this->table is a field with the table of categoris
            $this->db->where('parent_id', 0);
            $mainCategories = $this->db->get()->result(); //fetching the result
            $result = array();
            foreach($mainCategories as $id)
            {
                    $result[] = $this->getCategory($id->id);
            }
            return $result;
    }
Run Code Online (Sandbox Code Playgroud)

但它只返回1个级别的类别. …

php arrays recursion codeigniter

6
推荐指数
1
解决办法
1万
查看次数

Mailchimp 错误收件人最近的注册请求太多

我正在使用Mailchimp api订阅用户,但出现错误

Recipient "anonymized@gmail.com" has too many recent signup requests
Run Code Online (Sandbox Code Playgroud)

我试图直接从 mailchimp 帐户将用户添加到列表中,当我尝试通过 PHP 脚本添加用户时,我遇到相同的错误,甚至相同的错误。

我也尝试使用不同的浏览器和新系统,即使使用不同的互联网,但我遇到了同样的错误,请帮助我如何解决它?

php mailchimp mailchimp-api-v3.0

5
推荐指数
1
解决办法
7880
查看次数