var request = require('sync-request');
var cheerio = require('cheerio');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '',
database: 'prsr'
});
var baseUrl = 'https://en.wikipedia.org';
var startUrl = 'https://en.wikipedia.org/wiki/Category:Video_games_with_3D_graphics';
var res = request('GET', startUrl);
var $ = cheerio.load(res.getBody());
$('#mw-pages').find('.mw-category-group').each(function (index) {
var fullUrl = baseUrl + $(this).find('a').attr('href');
var data = parsePage(fullUrl);
if (data) {
connection.query('INSERT INTO games SET ?', data, function (err, result) {
if (err) throw err; // выкидывает ошибку здесь
console.log(result.insertId);
}
});
});
echo Nav::widget([
'activateItems' => true,
'items' => [
[
'label' => 'Home',
'url' => ['site/index'],
'linkOptions' => [...],
],
[
'label' => 'Dropdown',
'items' => [
['label' => 'Level 1 - Dropdown A', 'url' => '#'],
'<li class="divider"></li>',
'<li class="dropdown-header">Dropdown Header</li>',
['label' => 'Level 1 - Dropdown B', 'url' => '#'],
],
],
[
'label' => 'Login',
'url' => ['site/login'],
'visible' => Yii::$app->user->isGuest
],
],
'options' => ['class' =>'nav-pills'], // set this to nav-tab to get tab-styled navigation
]);
<?php
class Math {
private static $count = 0;
public function __construct() {
self::$count++;
}
public static function calcSin($x) {
return sin($x);
}
public static function calcSQRT($x) {
return sqrt($x);
}
public static function getCount() {
return self::$count;
}
}
echo Math::calcSin(1);
echo "<br />";
echo Math::calcSQRT(9);
echo "<br />";
$math = new Math();
$math_2 = new Math();
echo Math::getCount();
?>