July 04, 2008 | 07:30 PM  
Welcome

Don't have an account yet? You can create one, it is free, just click here

as a registered user you have some advantages like free downloads, comments and posting on our forums, depending upon this site's configuration and options.

 • •  Control Panel - Register - Login  • • 
Current Stable MDPro Lite 1.0821 Download
  Forum FAQForum FAQ   SearchSearch  UsergroupsUsergroups  PreferencesPreferences  Options forumOptions forum  Watched TopicsWatched Topics  Watched ForumsWatched Forums
Latest forum posts Latest forum posts  Log in to check your private messages Log in to check your private messages    Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Shorty
MD user level 5
MD user level 5


Joined: Jan 10, 2006
Posts: 149

Member
Post  Posted: July 16, 2006 - 06:47 AM Reply with quote Back to top
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
View user's profile
PeteBest
MD user level 5
MD user level 5


Joined: Oct 06, 2003
Posts: 4845

bannato
Post  Posted: July 16, 2006 - 07:21 AM Reply with quote Back to top

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
View user's profile
Shorty
MD user level 5
MD user level 5


Joined: Jan 10, 2006
Posts: 149

bannato
Post  Posted: July 16, 2006 - 07:34 AM Reply with quote Back to top

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
View user's profile
Shorty
MD user level 5
MD user level 5


Joined: Jan 10, 2006
Posts: 149

bannato
Post  Posted: July 16, 2006 - 07:43 AM Reply with quote Back to top

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
View user's profile
PeteBest
MD user level 5
MD user level 5


Joined: Oct 06, 2003
Posts: 4845

bannato
Post  Posted: July 16, 2006 - 08:21 AM Reply with quote Back to top

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
View user's profile
Shorty
MD user level 5
MD user level 5


Joined: Jan 10, 2006
Posts: 149

bannato
Post  Posted: July 16, 2006 - 08:41 AM Reply with quote Back to top

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
View user's profile
PeteBest
MD user level 5
MD user level 5


Joined: Oct 06, 2003
Posts: 4845

bannato
Post  Posted: July 16, 2006 - 08:47 AM Reply with quote Back to top

Nope, that's a call to the get_user_name function. You shouldn't need to change that

_________________
Retired from official MAXdev duties
View user's profile
Shorty
MD user level 5
MD user level 5


Joined: Jan 10, 2006
Posts: 149

bannato
Post  Posted: July 16, 2006 - 09:18 AM Reply with quote Back to top

This is an sql query right?
Code:
$user_name


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.....
View user's profile
Display posts from previous:     
Jump to:  
All times are GMT + 13 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by MDForum 2.0.8© 2003-2007 MAXdev Team
Credits