I have a yii application. And I am using the
widget('bootstrap.widgets.TbGridView
and in the column value of the widget I have this function:
<div class="row-fluid">
<div class="span12">
<?php $this->widget('bootstrap.widgets.TbGridView', [
'id' => 'result-grid',
'type' => 'striped bordered condensed hover',
'pagerCssClass' => "pagination viewpager",
'template' => "{summary}{items}n{pager}",
'dataProvider' => $result,
'columns' => [
[
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => '{Link}',
'buttons' => [
'Link' => [
'options' => ['class' => "btn-block viewEntry", 'target' => '_blank'],
'url' => function (Result $result) {
return $result->page_link;
},
],
],
],
[
'htmlOptions' => ['style' => 'width: 150px'],
'name' => 'coc_number',
'value' => function(Result $result){
return $result -> kvknumber($result);
}
],
]); ?>
</div>
</div>
And the model Resul looks like this:
class Result extends CActiveRecord
{
protected function getProductPageUrl()
{
return '<a href="' . $this->page_link . '" target="_blank"> ' . '<i class="fa fa-globe"></i>' . '</a>';
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'scrape_result';
}
public function kvknumber(Result $result)
{
$requestString = Google::GOOGLE_BASE_URL . 'key=' . Google::GOOGLE_API_KEY .
'&cx=' . Google::GOOGLE_CX . '&q=' . $result->page_url .
'"kvk"' . '&lr=lang_nl';
$clear = GuzzleHttpjson_decode((new Client)->request('GET', $requestString)->getBody()->getContents());
if (property_exists($clear, 'items')) {
foreach ($clear->items as $item) {
if (property_exists($item, 'snippet')) {
if (strpos(($item->snippet), 'KvK') !== false) {
// echo 'snippet' . $item->snippet;
preg_match('/[0-9]{8}/', $item->snippet, $match);
// echo ('match' . $match[0]);
if (isset($match[0])) {
$result->coc_number = $match[0];
$result->save();
}
sleep(4);
}
}
}
}
return $result->coc_number;
}
}
But when I load the page I get this error:
Fatal error: Maximum execution time of 120 seconds exceeded in C:xampphtdocswebScraperprotectedmodulesscrapemodelsResult.php on line 57
So my question is. How to resolve this?