第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 codeigniter 中調(diào)用自定義幫助程序的自定義同級方法并使用數(shù)據(jù)庫

如何在 codeigniter 中調(diào)用自定義幫助程序的自定義同級方法并使用數(shù)據(jù)庫

PHP
函數(shù)式編程 2022-08-05 16:05:50
編輯<?php   defined('BASEPATH') OR exit('No direct script access allowed'); function getCrud($table_name, $subject){    $CI =& get_instance();    $CI->load->database();    $crud = new grocery_Crud();    $crud->set_table($table_name);    $crud->set_subject($subject);    $crud->unset_read();    $crud->unset_clone();    $crud->where(array($table_name.'.flag' => '1'));    $crud->callback_delete(function ($primary_key) use ($table_name) {        return $CI->db->update($table_name, array('flag'=>'0'), array('id'=>$primary_key));    });    return $crud;} function oneToMany($table_name, $subject, $rel_table,$field='name'){    $crud = getGrocreyCrud($table_name, $subject);    $crud->set_relation($rel_table.'_id', $rel_table, 'name', array('flag' => '1'));    $output = $crud->render();    return $output;}我無法使用ci get實(shí)例調(diào)用上述函數(shù)getCrud。還有其他方法嗎?返回 $CI->db->update($table_name, array('flag'=>'0'), array('id'=>$primary_key));當(dāng)在控制器中使用這些代碼行時($CI將在控制器中$this),我可以將標(biāo)志設(shè)置為0,但在助手中它不會發(fā)生
查看完整描述

3 回答

?
繁星coding

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超4個贊

 class Gc_script

    {

        public $CI;

        public function __construct()

        {

            $this->CI =& get_instance();

            $this->CI->config->item('base_url');

        }


        public function getGrocreyCrud($table_name, $read=null)

        {

            $crud = new grocery_Crud();

            $crud->set_table($table_name);

            $crud->set_subject(ucwords(str_replace('_', ' ', $table_name)));


            $crud->callback_delete(function ($primary_key) use ($table_name) {

                return  $this->CI->db->update($table_name, array('flag'=>'0'), array('id'=>$primary_key));

            });


            return $crud;

        }

   }


查看完整回答
反對 回復(fù) 2022-08-05
?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個贊

可能以下應(yīng)該工作


<?php 

defined('BASEPATH') OR exit('No direct script access allowed');



if(!function_exists('getCrud'))

{

    function getCrud($table_name, $subject)

    {

        // some code

    }

}


if(!function_exists('oneToMany'))

{

    function oneToMany()

    {

        $CI =&get_instance();


        $crud = getCrud($table_name, $subject);

        return $crud ;

    }

}


查看完整回答
反對 回復(fù) 2022-08-05
?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗(yàn) 獲得超12個贊

<?php 

    defined('BASEPATH') OR exit('No direct script access allowed');



    function getCrud($table_name, $subject)

    {

          // some code

    }


     function oneToMany()

    {

        $CI =&get_instance();


        $crud = $CI->getCrud($table_name, $subject);

        return $crud ;

    }

試試這個


查看完整回答
反對 回復(fù) 2022-08-05
  • 3 回答
  • 0 關(guān)注
  • 131 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號