How to invoke the code of another controller inside the TP framework Controller

Source: Internet
Author: User
My Site TP frame, a foreground D:\WWW\User\Home\Controller\CommonController.class file, a backstage D:\WWW\snadmin\Home\ Controllercommoncontroller.class file, I want to in the foreground of the file inside the code inside call, do not know can?

Front Desk Commoncontroller.class File code
 
  Checkadminsessiona ();  So call the background Commoncontroller.class file Public Function Checkadminsessiona (), so call error, do not know there is no good way?         }}}




Background Commoncontroller.class File Code
Public Function Checkadminsessiona () {
if (! M (' Aconfig ')->where (Array (' Date ' =>0))->find ()) {
$tgbz _user = M (' tgbz ')->where (Array (' zt ' = ' 0 '))->select ();

$pipeits = 0;

foreach ($tgbz _user as $val) {
$JSBZ _list = TGBZ_ZD_CL ($val [' id ']);

foreach ($jsbz _list as $val 1) {

if ($val [' jb '] = = $val 1[' jb '] && $val [' user '] <> $val 1[' user ') {

if (Ppdd_add ($val [' id '], $val 1[' id ')) {

$pipeits + +;

M (' Tgbz ')->where (array (' id ' = = $val [' id ']))->save (Array (' cf_ds ' = ' 1 '));

Break
}
}
}
}
}
}


Reply to discussion (solution)

You can.

Use Think\controller;

Use method

You can.

Use Think\controller;

Use method

Can you make it a little more specific?

You can.

Use Think\controller;

Use method



I've already used I was going to call another one of the Commoncontroller.class controller file code

Non-static method: called after instantiation
static method: Real Direct static call

Non-static method: called after instantiation
static method: Real Direct static call




static method: How to write a real direct static call code

The definition of a static method is not seen in the code of your sample

If there is a definite definition, then
\ namespace \ Class Name:: Method Name ()

The definition of a static method is not seen in the code of your sample

If there is a definite definition, then
\ namespace \ Class Name:: Method Name ()



Background D:\WWW\snadmin\Home\ControllerCommonController.class file

Front desk D:\WWW\user\Home\ControllerCommonController.class File

Call to undefined function home\controller\tgbz_zd_cl ()
Wrong location
file:d:\www\user\home\controller\commoncontroller.class.php line:62


Public Function Checkadminsessiona () {//Set auto-match function        if (! M (' Aconfig ')->where (Array (' Date ' =>0)->find ()) {       $tgbz _user = M (' tgbz ')->where (Array (' zt ' = ' 0 ') ))->select ();        $pipeits = 0;        foreach ($tgbz _user as $val) {            //dump ();d ie;            $JSBZ _list =new \ tgbz_zd_cl ($val [' id ']);             The wrong word is this            foreach ($jsbz _list as $val 1) {                //echo $val [' JB ']. ' --
'; echo $val 1[' JB ']. '
'; if ($val [' jb '] = = $val 1[' jb '] && $val [' user '] <> $val 1[' user ') {//If the match successfully processed if (Ppdd_add ($val [' id '], $val 1[' id ')) { $pipeits + +; M (' Tgbz ')->where (array (' id ' = = $val [' id ']))->save (Array (' cf_ds ' = ' 1 ')); Break;}}}} $this->error ('/admin.php/home/index/zdpp_cl '); } }

Open your eyes and see clearly.
\ Namespace \ Class Name:: Method Name ()

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.