· 8 years ago · Dec 07, 2017, 07:50 PM
1CREATE TABLE IF NOT EXISTS `blocks` (
2 `bid` int(10) NOT NULL AUTO_INCREMENT,
3 `blockNumber` int(255) NOT NULL,
4 `date` int(11) NOT NULL,
5 PRIMARY KEY (`bid`)
6) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
7
8CREATE TABLE IF NOT EXISTS `locks` (
9 `name` varchar(11) NOT NULL,
10 `locked` tinyint(4) NOT NULL,
11 PRIMARY KEY (`name`)
12) ENGINE=MyISAM DEFAULT CHARSET=utf8;
13
14LOCK TABLES locks WRITE
15
16SELECT locked FROM locks WHERE name = 'somename'
17
18-- do some checks if there is a a row in that table, if not, add it
19
20-- if there is then we unlock
21
22UNLOCK TABLES
23
24-- execute some php code which inserts stuff in other tables
25
26when done
27
28UNLOCK TABLES