Call to function in console command class fails

Hi,

I’d like to create a Yii console command. It’s about database maintenance. The logic is kind of complex, impossible to implement in one function (an action or the run-method). Therefore, I need to store some logic in separate functions. But it seems I cannot call functions from withing the run-method, e.g.:


<?php

class MyCommand extends CConsoleCommand

{

  public function run($args)

  {

    // The next line causes...

    // Fatal error: Call to undefined function myHelperFunction()

    myHelperFunction();

  }


  public function myHelperFunction()

  {

    echo "myHelperFunction";

  }

}

?>

Can anyone explain me why?

Thanks.

you have missed $this-> before method

Try This




<?php

class MyCommand extends CConsoleCommand

{

  public function run($args)

  {

    // The next line causes...

    // Fatal error: Call to undefined function myHelperFunction()

	$this->myHelperFunction();

  }


  public function myHelperFunction()

  {

    echo "myHelperFunction";

  }

}

?>



Ok, thanks: that was obviously a silly question.