SELECT `ebids`.*, IFNULL(`c`.`qqq`, 0) AS `has_qqq_comment`,
IFNULL(`c`.`www`, 0) AS `has_www_comment`, IFNULL(`c`.`eee`, 0) AS `has_eee_comment`
FROM `ebids`
LEFT JOIN (
SELECT `item_id`, SUM(`itemtype` = 'qqq') AS 'qqq',
SUM(`itemtype` = 'www') AS 'www', SUM(`itemtype` = 'eee') AS 'eee'
FROM `comment_system`
GROUP BY `item_id`
) AS `c` ON `c`.`item_id` = `ebids`.`id`
WHERE `ebids`.`status` != 'auto'
ORDER BY `ebids`.`id` DESC
LIMIT 0, 100
Movie.belongsToMany(Director, { through: 'Movie_Director' });
Director.belongsToMany(Movie, { through: 'Movie_Director' });
$foo = ['order' => '100668327'];
echo $foo['order'];
или$foo = (object)['order' => '100668327'];
echo $foo->order;
$foo = json_decode('{"order":"100668327"}');
echo $foo->order;
или$foo = json_decode('{"order":"100668327"}', true);
echo $foo['order'];
$data = [
['id' => 1, 'field1' => 'Вася'],
['id' => 2, 'field1' => 'Петя'],
['id' => 3, 'field1' => 'Миша']
];
foreach ($data as $row) {
$stmt->execute($row);
}
или$data = [
1 => 'Вася',
2 => 'Петя',
3 => 'Миша'
];
foreach ($data as $id => $field1) {
$stmt->execute(['id' => $id, 'field1' => $field1]);
}
const deepEqual = (a, b) => {
if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every(
(key) => bKeys.includes(key) && deepEqual(a[key], b[key]),
);
}
class A
{
private static array $instances = [];
public readonly int $value;
public function __construct(?int $value = null)
{
if ($value !== null) {
$this->value = $value;
static::$instances[] = $this;
}
}
public function summ(): int
{
return array_reduce(
static::$instances,
fn($acc, $cur) => $acc + $cur->value,
0
);
}
}
new A(2);
new A(3);
$summ = (new A())->summ();
print $summ; // 5
const p = new Promise(...).then(...).then(...).catch();
можно записать какconst p1 = new Promise(...);
const p2 = p1.then(...);
const p3 = p2.then(...);
const p4 = p3.catch(...);