Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How to use DB class in Thread class?
toshi_seblic
October 2015
I want to use task by multi thread.
I wrote following test code.
But I got 'DB class not found'.
fuel/app/tasks/test.php
<?php
namespace Fuel\Tasks;
class Test
{
public static function run()
{
// worked
\Foo_Bar::insert(10);
$bar = new \Foo_Bar();
// worked
$bar->run();
// not worked!!(Error: Class 'DB' not found)
$bar->start();
$bar->join();
}
}
fuel/app/classes/foo/bar.php
<?php
class Foo_Bar extends Thread
{
public static function insert($i)
{
DB::insert('test')->set(array(
'i' => $i,
))->execute();
}
public function run()
{
$this->insert(20);
}
}
Why DB class not found in thread?
How to use?
Harro
October 2015
Haven't got a clue what "Thread" is, but I assume it's something that executes outside the scope of the Framework...
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
October 2015