title: Access model from Thread in Yii
body: <p>I have to parse a huge csv files in a Yii 1.1 Application.
  Each row has to be validated and saved to the database.
  I decided to use Multi Threading for this task. </p>
  
  <p>So here is my code in the Controller action:</p>
  
  <pre><code>public function parseData($) {
          $this-&gt;content = explode("\n", $this-&gt;content);
  
          $thread_1 = new DatalogThread(array_slice($this-&gt;content, 0, 7000));
          $thread_2 = new DatalogThread(array_slice($this-&gt;content, 7001));
  
          $thread_1-&gt;start();
          $thread_2-&gt;start();
      }
  </code></pre>
  
  <p>And the Thread (I put it in models folder):</p>
  
  <pre><code>class DatalogThread extends Thread {
      public $content;
  
  
      public function __construct($content) {
         $this-&gt;content = $content;
  
      }
  
  
      public function run() {
         foreach ($this-&gt;content as $value) {
              $row = str_getcsv($value);
  
              $datalog = new Datalog($row);
              $datalog-&gt;save();
  
          }
      }
  
  }
  </code></pre>
  
  <p>The problem is that the Thread does not get access to the model file:</p>
  
  <p><em>Fatal error: Class 'Datalog' not found in C:\xampp...\protected\models\DatalogThread.php</em> </p>
  
  <p>I tried Yii::autoload("Datalog"), but got The following error:</p>
  
  <p>Fatal error: Cannot access property Yii::$_coreClasses in ...\YiiMain\framework\YiiBase.php on line 402</p>