UPDATE `products` SET `status` = 1 WHERE `product_id` = 1;
UPDATE `products` SET `status` = 1 WHERE `product_id` = 2;
--
UPDATE `products` SET `status` = 1 WHERE `product_id` = 1000;
UPDATE `products` SET `status` = 1 WHERE `product_id` IN (1, 2, 3, 4, 5);
UPDATE `products` SET `status` = 2 WHERE `product_id` IN (6, 7, 8, 9);
WHERE TIMESTAMPDIFF(
DAY,
DATE_ADD(`birthday`, INTERVAL YEAR(NOW())-YEAR(`birthday`) YEAR),
NOW()
) BETWEEN 0 AND 7
<a onclick="$(document).scrollTop(0);">Наверх</a>
<button type="button" onclick="$(document).scrollTop(0);">Наверх</button>
<a href="#" onclick="$(document).scrollTop(0);return false;">Наверх</a>
CREATE TABLE IF NOT EXISTS `table_table` (
`table_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
INSERT INTO `table` (`table_id`, `name`) VALUES
(1, 'accounts');
CREATE TABLE IF NOT EXISTS `table_field` (
`table_field_id` int(11) NOT NULL AUTO_INCREMENT,
`table_id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`alias` varchar(32) NOT NULL,
`label` varchar(64) NOT NULL,
PRIMARY KEY (`table_field_id`),
KEY `table_id` (`table_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE `table_field`
ADD CONSTRAINT `table_field_ibfk_1` FOREIGN KEY (`table_id`)
REFERENCES `table_table` (`table_id`) ON DELETE CASCADE ON UPDATE CASCADE;
INSERT INTO `table_field` (`table_field_id`, `table_id`, `name`, `alias`, `label`) VALUES
(1, 1, 'id', 'id', 'ID'),
(2, 1, 'username', 'username', 'Ваше имя'),
(3, 1, 'password', 'pass', 'Пароль');
<?php
// Эта строчка — где-то в другом файле — где в данный момент инициализируется соединение с БД
$db = new PDO('mysql:dbname=testdb;host=127.0.0.1', 'username', 'password');
$sth = $db->prepare("
SELECT
t.`id`,
DATE_FORMAT(rt.`data`, '%d.%m.%Y') remont_date,
ma.`name` marka,
mo.`name` model,
t.`serial`,
rt.`work_id`,
rt.`sum`
FROM `tech` t
LEFT JOIN `remont_tech` rt ON rt.`tech_id` = t.`id` AND rt.`status` <> 'delete'
LEFT JOIN `marka` ma ON ma.`marka` = t.`marka`
LEFT JOIN `model` mo ON mo.`id` = t.`model`
WHERE
t.`user` = ? AND
TIMESTAMPDIFF(DAY, rt.`data`, NOW()) BETWEEN 0 AND 30
ORDER BY rt.`data` DESC
");
$sth->execute(array($myrow['id']));
$result = $sth->fetchAll();
?>
<table>
<tr>
<th>№</th>
<th>Дата</th>
<th>Оборудование</th>
<th>Проделанная работа</th>
<th>Сумма</th>
</tr>
<?php if (!count($result)) : ?>
<tr>
<td>0</td>
<td colspan="4">Ничего не найдено.</td>
</tr>
<?php else : ?>
<?php $summ = 0; ?>
<?php foreach ($result as $key => $row) : ?>
<tr>
<td><?= $key+1 ?></td>
<td><?= $row['remont_date'] ?></td>
<td><?= sprintf('%s %s(%s)', $row['marka'], $row['model'], $row['serial']) ?></td>
<td><?= $row['work_id'] ?></td>
<td><?= number_format($row['sum'], 0, ',', ' ') ?> руб.</td>
</tr>
<?php $summ += $row['sum']; ?>
<?php endforeach; ?>
<tr>
<td colspan="3"></td>
<td><b>ИТОГО:</b></td>
<td><b><?= number_format($summ, 0, ',', ' ') ?> руб.</b></td>
</tr>
<?php endif; ?>
</table>
m = re.search('(\d+)[\s]?шт', 'Коробка шт с кирпичами 10 шт;')
m.group(1)
$(function(){
$("#occupancy_39311").change(function (){
if ($(this).val() == "1"){
$("#price_39315").addClass("p159");
} else {
$("#price_39315").removeClass("p159");
}
});
})
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !domain\.com$ [NC]
RewriteRule .* - [R=404,L]
class UserController extends Controller {
var $_model;
public function loadModel($id) {
$this->_model = User::model()->findByPk($id);
// ...
return $this->_model;
}
// ...
public function getBirthday($id) {
if (isset($this->_model->date) && $this->_model->user_id == $id) {
return $this->_model->date;
} else {
$criteria = new CDbCriteria;
$criteria->select = 'date';
$data = User::model()->findById($id,$criteria);
return $data !== null $data->date : null;
}
}
// ...
}
но, по моему, это будет слишком тяжело для баз