Skip to content

Instantly share code, notes, and snippets.

View kwolniak's full-sized avatar

Krzysztof Wolniak kwolniak

View GitHub Profile

Method 1 - BAD

<?php

$toDelete1 = [0, 1]; // if it's for example [0, 2] so there is no problem
$list1 = new ArrayObject([0, 1, 2, 3, 4, 5, 6]);

foreach ($list1 as $key1 => $item1) {
    if (in_array($item1, $toDelete1)) {
SELECT t1.*, u.*
FROM `msg` AS `t1`
INNER JOIN
(
SELECT MAX(m_date) AS maxDate, m_group
FROM msg
WHERE (m_to_u_id=1 OR m_from_u_id=1) AND m_deleted='0'
GROUP BY m_group
) t2
ON t1.m_group = t2.m_group