Forums / General Questions / How to get a new mod to automatically create its own table?

How to get a new mod to automatically create its own table?

Locked

Views: 1,594

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
16 Oct 2007, 9:59 PM
#1
illusionguy avatar

illusionguy

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();
?>
16 Oct 2007, 11:29 PM
#3
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: How to get a new mod to automatically create its own table?

Yes, that mod would not install there was a problem with the .sql file it would not work via zencart admin or Navicat. Also the mod I'm working on has other features that Testimonial Manager does not have.

16 Oct 2007, 11:47 PM
#4
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: How to get a new mod to automatically create its own table?

IllusionGuy:

Yes, that mod would not install there was a problem with the .sql file it would not work via zencart admin or Navicat. Also the mod I'm working on has other features that Testimonial Manager does not have.

I'd be interested to know exactly what problem(s) you had installing "Testimonial Manager"

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

17 Oct 2007, 1:23 AM
#5
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: How to get a new mod to automatically create its own table?

This is the error I get from: admin -> tools -> install sql patches

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Test Site', '', 'This is just a test submission to show you how it looks, grea' at line 1
in:
[INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde's Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), '0000-00-00 00:00:00');]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
 

Navicat:

1146 - Table 'loyaltee.configuration_group' doesn't exist
17 Oct 2007, 1:38 AM
#6
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: How to get a new mod to automatically create its own table?

IllusionGuy:

This is the error I get from: admin -> tools -> install sql patches

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Test Site', '', 'This is just a test submission to show you how it looks, grea' at line 1
in:
[INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde's Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), '0000-00-00 00:00:00');]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

>  
> Navicat:
> ```
1146 - Table 'loyaltee.configuration_group' doesn't exist

You can try this and see if it works (the correction is highlighted):

INSERT INTO zen_testimonials_manager VALUES (1, 'Great', '', 'Clyde's Test Site', '', 'This is just a test submission to show you how it looks, great, eh?', '[email protected]', NULL, NULL, NULL, 0, 1, now(), , NULL);

The newest version of the mod has this correction. This version also includes the following features:

* options in admin for image display (Width, Height, and Directory
* options in admin to display "Company", "City" and "State/Country" fields on the Add testimonial page.
* administrators can add an image as well as a link to the author's site
* Submission of testimonials can be restricted to registered customers
* Random display of testimonials in side box
* Display testimonial title, truncated text in sidebox
* Display testimonial submission date

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.