1
banned
[mySQL] A good query is a bad query
  • 2005/1/19 20:55

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


Why this query:
CREATE TABLE IF NOT EXISTS `chooseaname_misc` (
  `
misc_idsmallint(5unsigned NOT NULL auto_increment,
  `
misc_categoryvarchar(15NOT NULL default '',
  `
misc_titlevarchar(255NOT NULL default '',
  `
misc_contenttext NOT NULL,
  `
dirnamevarchar(15NOT NULL default '',
  
PRIMARY KEY  (`misc_id`)
TYPE=MyISAM ;
is wrong for XOOPS when it isn't wrong?

I'm working on a little-easily-clonable-module for add your single custom page on the fly (remember mypage? ), the idea is to use only a single table for all the cloned modules.

Thanks XOOPERS.

2
Dave_L
Re: [mySQL] A good query is a bad query
  • 2005/1/19 21:48

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


What is the error message?

3
banned
Re: [mySQL] A good query is a bad query
  • 2005/1/19 22:06

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


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 'NOT EXISTS `chooseaname_misc` ( `misc_id` smallint(5) unsigne

.. In phpmyadmin it works perfectly.

4
Dave_L
Re: [mySQL] A good query is a bad query
  • 2005/1/19 22:12

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Try removing "IF NOT EXISTS". XOOPS might not support that.

5
banned
Re: [mySQL] A good query is a bad query
  • 2005/1/19 22:28

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


Well, is the first thing i've do ( ), before posting here, and it works fine.
But I need 'if not exist' if I want use the same table for all the 'cloned' modules.

I think that the only way to do this is to use an external script for create the table (in this way I will resolve my other problem too.. 'how to don't drop a table when you are unistalling a module' )

6
Lance_
Re: [mySQL] A good query is a bad query
  • 2005/1/20 0:19

  • Lance_

  • Home away from home

  • Posts: 983

  • Since: 2004/1/12


I had this error when installing a module, Tiny-D I think.

Anyway, do not put those little bracket things ---> `

Once I took them out the SQL query worked for the module.

Cheers.

7
banned
Re: [mySQL] A good query is a bad query
  • 2005/1/20 1:38

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


Well, I've choose another way for make the little-easily-clonable-module for put you html in your custom modules/directory/ (2 changes per clone, directory and $dirname = "DirectoryOfYourModule"; in xoops_version.php).
At this point I've also added a dynamic image generator for the Admin CP, so there is not the same image for all the cloned modules.

I use NewBB2 for the text, so no one DB is required.
Also various text editor are been implemented in NewBB, so no hard work for newbie

I'll release this soon, for now you can give a look at it (and test it) here

8
Mithrandir
Re: [mySQL] A good query is a bad query

Quote:

Dave_L wrote:
Try removing "IF NOT EXISTS". XOOPS might not support that.
XOOPS? I hope you mean MySQL, because XOOPS just passes the SQL on to the database (after prefixing the table(s), that is)

9
banned
Re: [mySQL] A good query is a bad query
  • 2005/1/20 11:56

  • banned

  • Not too shy to talk

  • Posts: 159

  • Since: 2004/5/16


MySQL Manual
In MySQL 3.23 or later, you can use the keywords IF NOT EXISTS so that an error does not occur if the table already exists. Note that there is no verification that the existing table has a structure identical to that indicated by the CREATE TABLE statement.

My server is running MySql v. 4.0.20

10
Dave_L
Re: [mySQL] A good query is a bad query
  • 2005/1/20 13:52

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
I hope you mean MySQL, because XOOPS just passes the SQL on to the database (after prefixing the table(s), that is)


But does that work if "IF NOT EXISTS" is present?

I just tested function prefixQuery() in class/database/sqlutility.php on the above query, and the modified query is:

CREATE TABLE [color=ff0000]xoops_IF NOT EXISTS[/color] `chooseaname_misc` (
  `
misc_idsmallint(5unsigned NOT NULL auto_increment,
  `
misc_categoryvarchar(15NOT NULL default '',
  `
misc_titlevarchar(255NOT NULL default '',
  `
misc_contenttext NOT NULL,
  `
dirnamevarchar(15NOT NULL default '',
  
PRIMARY KEY  (`misc_id`)
TYPE=MyISAM ;

Login

Who's Online

226 user(s) are online (136 user(s) are browsing Support Forums)


Members: 0


Guests: 226


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits