SQL Prefix on installer - how to add sql prefix top installer or manually

Started by ZajferX, June 28, 2011, 10:13:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

Any query in your code will be like

$res = sql_query("SELECT id, seeders, poster, leechers, name FROM torrents ORDER BY seeders + leechers DESC LIMIT 5 ") or sqlerr(__FILE__, __LINE__);

To use a prefix then any SELECT UPDATE INSERT needs altered to

$res = sql_query("SELECT id, seeders, poster, leechers, name FROM ".$TBDEV['db_prefix']."torrents ORDER BY seeders + leechers DESC LIMIT 5 ") or sqlerr(__FILE__, __LINE__);

Every single table being selected,updated,inserted to has a table name - torrents - users they all have to have that prefix added to them

FROM torrents

FROM ".$TBDEV['db_prefix']."torrents

FROM users

FROM ".$TBDEV['db_prefix']."users


UPDATE users

UPDATE ".TBDEV['db_prefix']."users


Ect ect - every query.


ZajferX

Quote from: Mindless on June 28, 2011, 12:02:34 PM

mysql_query('SELECT * FROM '.$TBDEV[db_prefix'].'table_name ');


should this line of code be edited or should it be added ?

Mindless

$TBDEV['db_prefix'] = "source1_";

mysql_query('SELECT * FROM '.$TBDEV['db_prefix'].'table_name ');

ZajferX

and as writen in shoutbox i guess i must alter code in include/config.php 
edit
$DB_CONFIG['db_prefix'] = "'';

but in my case it would be   

$TBDEV['db_prefix'] = "source1_";

for example .. right?

putyn

prefix on table names requires some work its not hard but you need to edit every file where you have a query something like

mysql_query('SELECT * FROM '.$db_prefix.'table_name ');

also when you import the database you need to alter every table name something like
from users to source1_users and your prefix will be source1_ and so on for every table

ZajferX

hi

this shouldn't really be in here but Mindless was nice enough to let me post it here so that's why it's in this forum

i will add tbdev 09 (final) and heavy beta to same server in diff sub folders but when i do the install i see it doesn't have SQL Prefix added to installer ... how can it be added coz i need it .. my host only allow one db in phpmyadmin so that's why it's needed in my case

if anyone knows how this is done i would be happy if i can solve this issue :P

oh and to add i am of course talking about rev462 and 463

have been trying to alter sql tabels to heavy_ (for heavy beta rev463) but i guess i must do more than just alter the sql :S