Welcome Guest, Not a member yet? Register   Sign In
Run another function in controller class - Background process
#11

[eluser]tonanbarbarian[/eluser]
if we make an instance of CI in the constructor of the library we can do anything

Code:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class sms {
  var $CI = null;

  function sms() {
    if ($this->CI===null)
      $CI =& get_instance();
  } // sms()

  function background() {
    $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
    if (!$fp) {
      log_message('error', 'Unable to connect to server');
      return;
    }
    $request = "GET /SendSMS/index HTTP/1.1\r\n"
      ."Host: www.example.com\r\n"
      ."Connection: Close\r\n\r\n";
    fwrite($fp, $request);
    fclose($fp);
  } // background()

  function query() {
    $this->CI->db->query();
    ...
  }
} // class sms

So if you want to call anything you could in the controller use $this->CI->... rather than $this->...


Messages In This Thread
Run another function in controller class - Background process - by El Forum - 12-07-2007, 03:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB