WARNING:I'm no expert with mysql, but I use it a lot.
Have you actually tried mysql app ? it's very slick and easy.
Simple one two three.. slurp the file with your commands.. then do
$handle->prepare($allyourcommands);
$handle->execute();
#that will do it.
For example; I have a txt file with commands for creating a table and place some records:
create table usertypes (
usertype varchar(5) not null,
usertype_label varchar(25) default 'user',
usertype_child_create TINYINT(1) DEFAULT 0,
usertype_child_assign_to_file TINYINT(1) DEFAULT 0,
usertype_child_assign_to_dir TINYINT(1) DEFAULT 0,
usertype_child_share TINYINT(1) DEFAULT 0,
usertype_child_toggle_live TINYINT(1) DEFAULT 0,
usertype_child_delete TINYINT(1) DEFAULT 0,
usertype_child_admin_all TINYINT(1) DEFAULT 0,
usertype_file_view_all TINYINT(1) DEFAULT 0,
usertype_file_download TINYINT(1) DEFAULT 0,
usertype_file_move TINYINT(1) DEFAULT 0,
usertype_file_rename TINYINT(1) DEFAULT 0,
usertype_dir_recurse TINYINT(1) DEFAULT 0,
usertype_dir_create TINYINT(1) DEFAULT 0,
usertype_dir_file_upload TINYINT(1) DEFAULT 0,
usertype_dir_incoming_file_upload TINYINT(1) DEFAULT 1,
usertype_dir_rename TINYINT(1) DEFAULT 0,
usertype_edit_description TINYINT(1) DEFAULT 0,
usertype_note TINYINT(1) DEFAULT 0,
usertype_scan_for_new_files TINYINT(1) DEFAULT 0,
usertype_usertypes_edit TINYINT(1) DEFAULT 0,
usertype_view_all_sessions TINYINT(1) DEFAULT 0,
row_last_modify integer(10),
PRIMARY KEY (usertype)
);
INSERT INTO usertypes (
usertype,
usertype_label,
usertype_child_create,
usertype_child_assign_to_dir,
usertype_child_toggle_live,
usertype_child_delete,
usertype_child_admin_all,
usertype_file_view_all,
usertype_dir_recurse,
usertype_dir_rename,
usertype_file_move
) values ('a','admin',1,1,1,1,1,1,1,1,1);
INSERT INTO usertypes (
usertype,
usertype_label,
usertype_child_create,
usertype_child_assign_to_file,
usertype_child_toggle_live,
usertype_child_delete,
usertype_file_view_all,
usertype_edit_description,
usertype_file_download,
usertype_child_admin_all,
usertype_file_rename,
usertype_dir_rename,
usertype_file_move
) values ('m','manager',1,1,1,1,1,1,1,1,1,1,1);
INSERT INTO usertypes (usertype, usertype_label, usertype_file_downloa
+d)
values ('u','user',1);
I can just cut and paste that into the mysql prompt or feed it through the handle. |