News:

Wondering if this will always be free?  See why free is better.

Main Menu

Create new table with MySQL

Started by bosswhite, March 05, 2015, 11:44:06 AM

Previous topic - Next topic

bosswhite

I have encountered many problems trying to install a mod through package manager so have resorted to a manual install.

I don't have any problem modifying the necessary files or uploading new files but there is one issue I am having.
The mod contains an install file which should create a new table in my database. The code from that file is shown below.

<?php
global $db_prefix$smcFunc;

$smcFunc['db_create_table']($db_prefix 'bookmarks',
array(
array(
'name' => 'id_member',
'type' => 'mediumint',
'size' => 8,
),
array(
'name' => 'id_topic',
'type' => 'mediumint',
'size' => 8,
),
),
array(
array(
'name' => 'bookmark',
'type' => 'unique',
'columns' => array('id_member''id_topic'),
),
),
array(),
'ignore');
?>


I need to create that table with an SQL query when logged in to my database but don't know how to do it.

Could anybody possibly convert the content of the file above in to an SQL query for me that would create what is required?

I am on an Apache server running MySQL 5.1.73 and the prefix to all my tables is smf_.

Any help would be gratefully appreciated. Thank you.
I've been down so long now it's beginning to look like up..

vbgamer45

Easy way is just to run that script
after

<?php

Add

require 'SSI.php';


Then copy that file to main directory of your forum then run it in browser by visiting the page in the address bar.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

bosswhite

Quote from: vbgamer45 on March 05, 2015, 11:55:39 AM
Easy way is just to run that script
after

<?php

Add

require 'SSI.php';


Then copy that file to main directory of your forum then run it in browser by visiting the page in the address bar.

I just tried that and get the following error message
Fatal error: Function name must be a string in /home/mysite/Z6OW6C36/htdocs/forum/install.php on line 7
I've been down so long now it's beginning to look like up..

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

bosswhite

Quote from: vbgamer45 on March 05, 2015, 12:30:04 PM
What SMF version are you using?

SMF 2.0.9

The mod was written for 2.0.2, would that make a difference?
I notice that if you parse the mod for manual installation it doesn't mention the new table.
http://custom.simplemachines.org/mods/index.php?mod=864
I've been down so long now it's beginning to look like up..

Illori

Quotesmf20/install.php
This file should not be able to execute standalone. You may have to run the following queries manually.


that is the part about the database table from the parse of that mod.

bosswhite

Quote from: Illori on March 05, 2015, 12:42:18 PM
Quotesmf20/install.php
This file should not be able to execute standalone. You may have to run the following queries manually.


that is the part about the database table from the parse of that mod.

Right, I understand.
So that takes me back to the original question about running the queries in SQL?
I've been down so long now it's beginning to look like up..

bosswhite

Not sure why this topic was moved from Scripting Board. I require assistance writing a SQL query which that board covers.

I don't think my issue is a problem with SMF Coding, but that is just my opinion.

I just want help to create a SQL query that will create the table as shown in the original post.
I've been down so long now it's beginning to look like up..

bosswhite

Solved. The query I required was

CREATE TABLE smf_bookmarks (id_member MEDIUMINT(8), id_topic MEDIUMINT(8), PRIMARY KEY(id_member,id_topic));
I've been down so long now it's beginning to look like up..

Advertisement: