how to install multiple tables to a mysql database with php pdo -
i creating cms
, have created self installer creates tables in database.
i using php code works great on wamp script quites after 10 files on server.
if (!$db = new pdo('mysql:host='.$dbhost.'; dbname='.$dbname, $dbuser, $dbpass)){$msg = 'e|could not connect.';} elseif ($db = new pdo('mysql:host='.$dbhost.'; dbname='.$dbname, $dbuser, $dbpass)){ $sql = ''; foreach(glob('sql/*') $file) {$sql .= file_get_contents($file);} $db->exec($sql); }
there total of 48 txt files in sql/
this:
-- -- table structure table `block_grids` -- create table if not exists `block_grids` ( `block_grid_id` int(12) not null auto_increment, `block_grid_name` varchar(25) not null, `row_items_small` tinyint(2) not null, `row_items_medium` tinyint(2) not null, `row_items_large` tinyint(2) not null, `equalize_block_grid` tinyint(1) not null, primary key (`block_grid_id`) ) engine=innodb default charset=latin1 auto_increment=1 ;
the server set 200mmibs upload , total of 10 files executed 161kibs. not quite sure go it...
the code above concatenates files works fine on wamp. tried running each file individully code quite after 4 on every attempt:
if (!$db = new pdo('mysql:host='.$dbhost.'; dbname='.$dbname, $dbuser, $dbpass)){$msg = 'e|could not connect.';} elseif ($db = new pdo('mysql:host='.$dbhost.'; dbname='.$dbname, $dbuser, $dbpass)){ $sql = ''; foreach(glob('sql/*') $file) { $sql = file_get_contents($file); $db->exec($sql); } }
as on host , not wamp, following may not possible in hosted environment give shot. (note .cnf modification may not possible)
show variables '%wait_timeout%'; show global variables '%wait_timeout%';
you run @ mysql prompt:
set global wait_timeout=600
this 10 minutes, pathetically long time. choose value based on needs not nonsense.
any new sessions value.
mirror change in my.cnf. file. becomes effective on mysql restart.
any 1 transaction in reporting job (or otherwise) naturally of concern. think of non-wrapped statement outside of transaction transaction.
or work around make many teeenie files
Comments
Post a Comment