| Author |
Message |
Shorty
MD user level 5


Joined: Jan 10, 2006
Posts: 149
Member
|
 Posted:
July 16, 2006 - 06:47 AM |
|
| Post subject: Query change question if you don`t mind |
Hi.
In the wait for the MDLite i`m testing a lot of things out and i`m currently working on joining a few databases. It`s not that difficult really but as i`m a bit n00b on the php i was wondering if someone could help me out a bit.
I`m going to change from one database query to another one and i got stuck on this:
| Code:
|
|
$sql = "INSERT INTO {$CONFIG['TABLE_FAVPICS']} (user_ id, user_favpics) VALUES (" . USER_ID . ", '$data')";
|
In this query i haveto change from "user_id" to "id" in the files. So this part"(user_ id, user_favpics)" will be (id, user_favpics)". No big deal, but will i haveto change this ". USER_ID ." to ". ID ."?
As i see it i don`t. Am i wrong?
Shorty |
|
|
|
 |
PeteBest
MD user level 5


Joined: Oct 06, 2003
Posts: 4845
bannato
|
 Posted:
July 16, 2006 - 07:21 AM |
|
|
The SQL query is easily broken down
INSERT INTO {$CONFIG['TABLE_FAVPICS']}
This sets the table to be inserted to. $CONFIG['TABLE_FAVPICS'] will have a value declared in the script to convert to a valid table name in the database
(user_ id, user_favpics)
This is the destination columns inside the $CONFIG['TABLE_FAVPICS'] table
VALUES (" . USER_ID . ", '$data')";
This is the data gathered inside the script that you wish to add to the database.
Not sure what you mean by you have to change... but you're right, the " . USER_ID . " variable in the query won't change if you change the database column name, just the destination needs to change.
If in doubt with SQL problems like this, simply echo the $sql variable after the statement. Refresh your page and then copy and paste the line into phpmyadmin and it's much easier to see where you've gone wrong |
_________________ Retired from official MAXdev duties |
|
|
 |
Shorty
MD user level 5


Joined: Jan 10, 2006
Posts: 149
bannato
|
 Posted:
July 16, 2006 - 07:34 AM |
|
|
Think you answered me quite good, thanks.
That was exactly what i meant. The sql query like "user_id" is the one to be changed as the ".USER_ID." is a php variable. It`s so hard to understand and read all the coding but i`m getting the hang on a lot on the database configurations.
Remember the request i had on converting users or something like that earlier. I`ve just for "fun" converted users and their data from any system i`ve tried into whatever i`ve liked. But the php/html i have a tough time having control over. Time, time.
Can`t wait for the MDLite as i delayed my projects on the MD to wait for this as this is the way you guys are heading. Don`t want to waste time when the MDlite is coming. Take your time and make some quality instead of rushing it. Great job guys, really.
Shorty |
|
|
|
 |
Shorty
MD user level 5


Joined: Jan 10, 2006
Posts: 149
bannato
|
 Posted:
July 16, 2006 - 07:43 AM |
|
|
One more thing i`m wondereing about. If i say have a database installed with prefix, can i then have some tables without prefix?
Like this:
| Code:
|
CREATE TABLE comments (
pid mediumint(10) NOT NULL default '0',
msg_id mediumint(10) NOT NULL auto_increment,
msg_author varchar(25) NOT NULL default '',
msg_body text NOT NULL,
msg_date datetime NOT NULL default '0000-00-00 00:00:00',
msg_raw_ip tinytext,
msg_hdr_ip tinytext,
author_md5_id varchar(32) NOT NULL default '',
author_id int(11) NOT NULL default '0',
PRIMARY KEY (msg_id),
KEY com_pic_id (pid)
) TYPE=MyISAM;
# --------------------------------------------------------
CREATE TABLE SFT_config (
name varchar(40) NOT NULL default '',
value varchar(255) NOT NULL default '',
PRIMARY KEY (name)
) TYPE=MyISAM;
|
Or will it automatically look for prefix on all, or on noone?
Shorty |
|
|
|
 |
PeteBest
MD user level 5


Joined: Oct 06, 2003
Posts: 4845
bannato
|
 Posted:
July 16, 2006 - 08:21 AM |
|
|
Yes, you can have a mix of tables with and without a prefix, the trick is that when you access them via the pntables array. Inside the pntables.php file it defines the prefix before the table name, so if you edit that you can access any prefix you like |
_________________ Retired from official MAXdev duties |
|
|
 |
Shorty
MD user level 5


Joined: Jan 10, 2006
Posts: 149
bannato
|
 Posted:
July 16, 2006 - 08:41 AM |
|
|
One more thing if you don`t mind again.
This code here:
| Code:
|
|
$cpg_udb->get_user_name($row['owner_id']);
|
I`m changing all sql queries from "user_name" to "username", so will this "get_user_name" haveto be changed to "get_username"?
Shorty |
|
|
|
 |
PeteBest
MD user level 5


Joined: Oct 06, 2003
Posts: 4845
bannato
|
 Posted:
July 16, 2006 - 08:47 AM |
|
|
Nope, that's a call to the get_user_name function. You shouldn't need to change that |
_________________ Retired from official MAXdev duties |
|
|
 |
Shorty
MD user level 5


Joined: Jan 10, 2006
Posts: 149
bannato
|
 Posted:
July 16, 2006 - 09:18 AM |
|
|
This is an sql query right?
this will also haveto be changed to $username...?
Shorty
EDIT. Stupid question.... sry. Got an database error so i just lashed out this dumb Q..... |
|
|
|
 |
|
|