protected function inTransaction($fn) {
$connection = ...
$transaction = $connection->beginTransaction();
$result = false;
try {
$result = call_user_func($fn);
$transaction->commit();
} catch (Exception $e) {
$transaction->rollBack();
}
return $result;
}
$result = $this->inTransaction(function() use ($data) {
...
});
$result = $this->inTransaction(array('ClassName', 'methodName'));
isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
if (isMobile.any()) {
alert('is mobile !');
}
function is_touch_device() {
return !!('ontouchstart' in window);
}
<select id='search_komnat' name='komnat'>
<select id='search_komnat' name='komnat2'>
$(field).show().focus().click().hide();
SELECT * FOM table WHERE id = :user_input;
id list
1 "Вишня"
2 "Банан"
list
"1 => Вишня"
"2 => Банан"
<img src="site.com/delivery_report/{{ id письма }}" />