UPDATE Pricelist as p JOIN Lots as l
ON p.id = l.ID_of_price
SET p.Own_Price = IF (p.prices = l.prices, 1, 0)
WHERE p.id = l.ID_of_price
UPDATE Pricelist SET Own_Price = 0;
UPDATE Pricelist as p JOIN Lots as l
ON p.id = l.ID_of_price
SET p.Own_Price = IF (p.prices = l.prices, 1, 0);
class Album extends Eloquent {
public function photos()
{
return $this->hasMany(Photo::class);
}
}
class Photo extends Eloquent {
public function album()
{
return $this->belongsTo(Album::class);
}
}
class AlbumController extends Controller {
...
public function show($id)
{
$album = Album::find($id);
return view('album')->with(['photos' => $album->photos]);
}
...
}
deleteArticle: function (url) {
let self = this;
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function () {
self.$http.delete(url, function () {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
});
}
<a href="#"
v-on:click="deleteArticle()">Удалить</a>
window.Laravel = <?= json_encode([
'base_url' => url(),
'article' => isset($article) ? $article->toArray() : null,
]); ?>
var article_form = new Vue({
el: '#article_form',
data: {
delete_url: window.Laravel.base_url + '/article/' + window.Laravel.article.id + '/delete'
},
methods: {
deleteArticle: function () {
var self = this;
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function () {
self.$http.delete(self.delete_url, function () {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
});
});
}
}
});
var Ctrl = function (condition) {
var self = this;
this.condition = condition;
this.result = null;
this.init = function () {
this.check();
};
this.check = function () {
$.getJSON('/path/to/file', {param1: 'value1'}, function(data, textStatus) {
if (data.result !== self.condition)
self.check();
else
self.result = data.result;
});
};
this.getResult = function () {
return this.result;
};
this.init();
}
var condition = 'условие для ответа';
var controller = new Ctrl(condition);
var result = null;
var myInterval = setInterval(function() {
result = controller.getResult();
if (result) {
console.log('ожидаемый ответ: ', result);
clearInterval(myInterval);
}
}, 4000);
$ npm install --save-dev gulp-remove-html-comments
var gulp = require('gulp');
var removeHtmlComments = require('gulp-remove-html-comments');
gulp.task('html', function () {
return gulp.src('src/*.html')
.pipe(removeHtmlComments())
.pipe(gulp.dest('dist'));
});
первое число минута (0-59)
второе число час (0-23)
третье число день месяца (1-31)
четвертое число месяц (1-12)
пятое число день недели (0-6)
upstream first_server {
server 127.0.0.1:3000;
}
upstream second_server {
server 127.0.0.1:1337;
}
server {
listen 80;
server_name domain1.com;
location / {
proxy_pass http://first_server;
}
}
server {
listen 80;
server_name domain2.com;
location / {
proxy_pass http://second_server;
}
}
$link = mysqli_connect("localhost", "username", "password", "database");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$table = "table_name";
if ($stmt = mysqli_prepare($link, "INSERT INTO $table SET id_user=? ON DUPLICATE KEY UPDATE id_user=?")) {
mysqli_stmt_bind_param($stmt, "ss", $_POST['id_user'], $_POST['id_user']); // или $_GET
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($link);
die('OK');
}
/* close connection */
mysqli_close($link);
die('ERROR');