I am new with Phalcon and have the following problem:
The model is:
class Test extends \Phalcon\Mvc\Model
{
public $id;
public $label;
public function getSource()
{
return 'test';
}
}
In the controller:
public function indexAction()
{
$t1 = microtime(true);
// Testing just connect
$this->di['db']->connect();
$t2 = microtime(true);
// Get all the rows
$t = Test::find();
$t3 = microtime(true);
// Output some data
foreach ($t as $i)
{
print $i->id;
}
$t4 = microtime(true);
// Output result
print '<pre>Connect: ' . (round(($t2 - $t1) * 1000000) / 1000) . ' ms</pre>';
print '<pre>Find all: ' . (round(($t3 - $t2) * 1000000) / 1000) . ' ms</pre>';
print '<pre>Foreach: ' . (round(($t4 - $t3) * 1000000) / 1000) . ' ms</pre>';
}
And the output is:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
Connect: 2.308 ms
Find all: 2402.488 ms
Foreach: 0.554 ms
I can't find why there is such lag for model::find(). Any ideas and/or suggestions on it?