collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: how to get a table from other db  (Read 2938 times)

0 Members and 1 Guest are viewing this topic.

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
how to get a table from other db
« on: June 06, 2006, 07:57:46 pm »
Ok so i have more bots running atm
What i want is to put all bots to use only 1 table from other db(diferent then hes own db),
this table is the whois catch one from alreadythere so we dont wait for FC site evrytime,
however i want all bots to use 1, so i dont have to make 1 on evry bot i start lol
I know it is possible and maybe is a really simple way, but i cant really see how to do it.
any help apreciate :P

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: how to get a table from other db
« Reply #1 on: June 06, 2006, 09:08:37 pm »
In MySQL.php
Code: [Select]
function cngdb($db) {
mysql_select_db($db,$this->CONN);
}

In script files
Code: [Select]
$this->bot->db->cngdb("newDB");
-script stuff here-
$this->bot->db->cngdb("oldDB");
Too many toons.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #2 on: June 06, 2006, 09:23:57 pm »
I have to say this :)

If you go and use my tablename functions, you can use a prefix/suffix for each bot. So you can put all tables for lot's of bots in just one database.

I'm running 10+ bots, all using one database.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: how to get a table from other db
« Reply #3 on: June 06, 2006, 11:43:47 pm »
It can non the less be made easier to connect to more than one database (thinking primarily different database hosts) by making some simple changes to MySQL.php to allow passing of the connection information to the connect function.

For switching between local databases, Wolfbiter's suggestion is a very good one however.
BeBot Founder and Fixer Kingpin

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #4 on: June 07, 2006, 12:02:53 pm »
If your table is in database "a", and you're connected to database "b"...you can still just do "SELECT * from a.whoiscache". It will return the content of "whoiscache" table in database "a". This is ofc if database "a" and "b" is running on the same service.
« Last Edit: June 07, 2006, 12:07:14 pm by Zacix »
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #5 on: June 07, 2006, 01:38:21 pm »
I dont have time to test atm, but thanks alot for help guys :P
anyway i like Zacix way and already,

Well corect me if undertood wrong,
This is the origial function lookup from WhoisCache.php

Code: [Select]
function lookup($name)
{
$lookup = $this -> bot -> db -> select("SELECT * FROM " . $this -> bot -> get_tablename("whois") . " WHERE name = '" . $name . "'");



I guess i will need to set it up something like :

Code: [Select]
function lookup($name)
{
$lookup = $this -> bot -> db -> select("SELECT * FROM whois.whois  " WHERE name = '" . $name . "'");


About Alreadythere way of puting prefix/sufix, do i have to do that on evry modules/bot core etc? I mean i have to change the tables the bot use? or is there a faster way to do it?

Offline Zacix

  • Contributor
  • *******
  • Posts: 73
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #6 on: June 07, 2006, 04:33:25 pm »
Phar

"SELECT * FROM whois.whois  " WHERE name = '" . $name . "'"

would imply that the database name that the whois table is in, is called whois. Just thought that "whois" was a strange name for a database...just mentioning in case you misunderstood my first post. The default select syntax is (simplified):

SELECT * FROM [databasename.]table [WHERE column = 'value']
Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #7 on: June 07, 2006, 08:00:21 pm »
yea man, i made a db that only handle that and is named whois hehe :P well was a exemple anyway, im gonna test it, its alot easyer how Zacix say, if i cant get it work, i'll ask again.
Thanks for help ;D

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #8 on: June 07, 2006, 09:17:23 pm »
About Alreadythere way of puting prefix/sufix, do i have to do that on evry modules/bot core etc? I mean i have to change the tables the bot use? or is there a faster way to do it?
If you put all into one databse then yes, you would have to do that. Implementing those functions the first time is quite a bit of work, you have to edit all database queries.
For new modules it's not much more work, just a bit longer writing.

Offline Pharexys

  • BeBot Apprentice
  • ***
  • Posts: 117
  • Karma: +0/-0
Re: how to get a table from other db
« Reply #9 on: June 07, 2006, 11:05:18 pm »
Ok i made it, created a fresh DB called Whois as i said on exemple,
used the Zacix way, had to modify only WhoisCache.php,
and works awesome so far :D
alot of less work, if i had to put all on 1 db it'll take ages for me to do it, since my time is limited and i want to play ao also :P
Well thanks all for replys and help :P



 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 760
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal