0
我有一個場景,我不得不使用一個類來擴展另一個類,它不是一個codeigniter類和方法內部,我需要調用另一個方法來執行數據庫操作。如何在同一文件的其他類中使用其他類方法?
我該如何實現?
<?php
require_once(APPPATH.'third_party/OauthPhirehose.php');
class Get extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('tweets_model');
}
public function getall()
{
$tags = $this->tags_model->get();
$result = $tags->row();
$first = $result->first_tag;
$second = $result->second_tag;
return array($first, $second);
}
public function insert_raw_tweet($raw_tweet, $tweet_id)
{
$this->tweets_model->save_raw($raw_tweet, $tweet_id);
}
}
class Consume extends OauthPhire {
public function enqueueStatus($status) {
$tweet_object = @json_decode($status);
if (!(isset($tweet_object->id_str))) { return;}
$tweet_id = $tweet_object->id_str;
$raw_tweet = base64_encode(serialize($tweet_object));
echo $tweet_object->text . "\r\n";
// here i need to use top class method to insert data
//$this->tasks->insert_raw_tweet($tweet_object, $tweet_id);
}
}
$get_track = new Get();
$list = $get_track->getall();
$stream = new Consume(OAUTH_TOKEN, OAUTH_SECRET, Phirehose::METHOD_FILTER);
$stream->setTrack($list);
$stream->consume();