Zen Follower
- Join Date:
- May 2007
- Posts:
- 136
- Plugin Contributions:
- 0
How to get a new mod to automatically create its own table?
Hello everyone,
I’m working on a customer testimonials mod for ZenCart and I want to make this mod setup the tables automatically I know you can create tables using php but I’m not having any luck :( I’m not that great with my php coding just yet so any suggestions on what I’m doing wrong would be great, thanks guys.
<?PHP
$buildSQL = "
CREATE TABLE `zen_testimonials` (
`id` int(6) NOT NULL auto_increment,
`image` varchar(255) default NULL,
`quote` longtext,
`business_name` varchar(255) default NULL,
`location` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `zen_testimonials_settings` (
`id` int(6) NOT NULL auto_increment,
`testimonials_title` varchar(255) default NULL,
`testimonials_link_title` varchar(255) default NULL,
`items_per_row` char(3) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `zen_testimonials_settings` VALUES ('1', 'Testimonials', 'Testimonials v1.0', '5');";
@mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD) or die("Unable to connect");
@mysql_select_db(DB_DATABASE) or die("Unable to select database DB_DATABASE");
$result = mysql_query("SELECT testimonials_link_title FROM zen_testimonials_settings");
$i = mysql_fetch_row($result);
if(!$i){mysql_query($buildSQL);}
$testimonials_link_title = $i[0];
$za_contents[] = array("text" => "$testimonials_link_title", "link" => zen_href_link("testimonials.php?session=display", "", "NONSSL"));
mysql_close();
?>