class MySingleMysqlConnection {
private static $instance;
private $connection;
private function __clone() {}
private function __construct() {
$this->connection = new MysqlConnection();
}
public static function getConnection(){
if (null === self::$instance){
self::$instance = new self();
}
return self::$instance->connection;
}
MySingleMysqlConnection::getConnection()
if (isset($result) && $result){
$this->registerJs("$('#myModal').hide()");
}
INT(11) UNSIGNED
INET_ATON
- это функция mysql /**
* @param array $input
* @param array $items
*
* @return int|null
*/
function compare(array $input, array $items)
{
foreach ($items as $index => $item) {
$compareResult = version_compare(implode('.', $input), implode('.', $item));
if ($compareResult <= 0) {
if ($compareResult === 0 || !array_key_exists($index - 1, $items)) {
return $index;
}
return $index - 1;
}
}
return null;
}
$items = [
[1, 1, 1],
[1, 2, 1],
[1, 2, 2],
[1, 5, 4],
[1, 5, 6],
[2, 1, 6],
[2, 2, 2],
];
$input = [1, 5, 5];
if (null === $index = compare($input, $items)) {
echo 'Элемент не найден';
} else {
echo "Элемент под номером {$index} является наиболее близким";
}
'accessControl' => [
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallbak' => function($rule, $action){
return Yii::$app->user->identity->status !== User::STATUS_BLOCKED;
}
]
],
],