Skip to content

Instantly share code, notes, and snippets.

@dayfuaim
dayfuaim / closure_table.md
Created Jun 8, 2016
Persistent tree structure using closure table in MySQL
View closure_table.md

Using closure tables to manage hierarchical relations in MySQL

Create DB tables

Create a table to represent tree nodes.

CREATE TABLE `tree_node` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `data_body` text,
    `node_deleted` datetime DEFAULT NULL,
View tst_ae.pl
#!/usr/bin/perl -w
#
use strict;
use feature ':5.10';
use utf8;
use open qw(:std :utf8);
use DDP;
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
@dayfuaim
dayfuaim / DenisYurashkuFindIndex.pm
Last active Nov 1, 2015
Поиск в массиве индекса элемента, ближайшего к заданному. OOPed. :)
View DenisYurashkuFindIndex.pm
package DenisYurashkuFindIndex;
use strict;
use utf8;
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {};
bless($self, $class);
$self->{STEPS} = 0;