medoo action 如何传参

public static function create($title, $content, $label_ids){

    self::$db->action(function($db){
        $db->insert('articles', [
            'title' => $title,
            'content' => $content,
            'created_at' => self::$t,
            'updated_at' => self::$t,
            'created_date' => self::$t_date,
            'updated_date' => self::$t_date,
        ]);
        $article_id = $db->id();
        $data = [];
        foreach(explode(',', $label_ids) as $id){
            $data[] = [
                'article_id' => $article_id,
                'label_id' => $id,
                'created_at' => self::$t,
                'updated_at' => self::$t,
                'created_date' => self::$t_date,
                'updated_date' => self::$t_date,
            ];
        }
        $db->insert('article_labels', $data);
    });
}

如何将action外的变量传递进去

阅读 4.2k
2 个回答
新手上路,请多包涵

图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题