Skip to content

Instantly share code, notes, and snippets.

View OMGZui's full-sized avatar
:octocat:
Focusing

omgzui OMGZui

:octocat:
Focusing
  • DXY
  • HangZhou, China
View GitHub Profile
SELECT * FROM doc WHERE id = #{id};
@OMGZui
OMGZui / 2.sql
Last active June 21, 2022 14:39
UPDATE doc SET prevId = #{currentData.prevId} WHERE id = #{curActivity.siblingId};
UPDATE doc SET siblingId = #{currentData.siblingId} WHERE id = #{currentData.prevId};
SELECT * FROM doc WHERE id = #{prevId};
UPDATE doc SET prevId = #{id} WHERE id = #{prevData.siblingId};
UPDATE doc SET siblingId = #{prevData.siblingId} WHERE id = #{id};
UPDATE doc SET prevId = #{prevId} WHERE id = #{id};
UPDATE doc SET siblingId = #{id} WHERE id = #{prevId};
CREATE TABLE `doc` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`prevId` int(11) DEFAULT NULL COMMENT 'prevID',
`siblingId` int(11) DEFAULT NULL COMMENT 'siblingID',
`position` int(11) DEFAULT NULL COMMENT 'position',
PRIMARY KEY (`id`),
KEY `idx_prevId` (`prevId`),
KEY `idx_siblingId` (`siblingId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@OMGZui
OMGZui / 1.php
Last active June 27, 2022 07:59
if (!empty($foo)) $data['foo'] = $foo; // A
if (!empty($foo)) {
$data['foo'] = $foo; // B
}
!empty($foo) && $data['foo'] = $foo; // C
@OMGZui
OMGZui / 2.php
Last active June 27, 2022 08:00
// A
foreach ($list as $item) {
if ($item['status'] == true) {
// ...
}
}
// B
foreach ($list as $item) {
if ($item['status'] == false) {
@OMGZui
OMGZui / 3.php
Last active June 27, 2022 08:00
// A
$data = [];
$data['a'] = 1;
$data['b'] = 1;
// B
$data = [
'a' => 1,
'b' => 1,
];
@OMGZui
OMGZui / 4.php
Last active June 27, 2022 08:00
// A
$count = 0;
while ($count < 10) {
// ...
$count++;
}
// B
$count = 0;
while (++$count < 10) {
@OMGZui
OMGZui / 5.php
Last active June 27, 2022 08:01
// A
if ($result == true)
// B
if (true == $result)