Results 1 to 4 of 4

Thread: question about custom module

  1. #1
    lausing is offline Member
    Join Date
    Apr 2009
    Posts
    16

    Default question about custom module

    Hi all,

    could u tell me how to connect to a different database(other than sugar db) in a new custom module? Do u think I can still use the sugar template to show the data from another db?
    OR actually how can I made my own query in sugar?Thanks. I'm really appreciated ur helps.

    Regards,
    Richard

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: question about custom module

    Short answer: yes.

    There are tons of ways to do this. Easiest way is to create the custom module in Studio/MB and deploy. Then override the custom module bean's retrieve function to call your external database. I'd suggest a 3rd party db library like adodb. I've hacked Sugar's db lib to use the same lib in the past but it's not worth it. I've since switched to adodb which works quite well. You'll also need to override create_new_list_query for the list views. There should be some examples on this forum. Searching Google works best (site:sugarcrm.com/forums retrieve external database).

  3. #3
    lausing is offline Member
    Join Date
    Apr 2009
    Posts
    16

    Default Re: question about custom module

    thx for your reply eggsurplus. sorry for the confusion. Actually, I have them in the same host but just diff databases like db1 and db2. Like, in sugarconfig it sets up the db config to db1(sugardb) ... so how can I get some of the data from db2 and related to sugardb? Thanks.

  4. #4
    jayrb is offline Sugar Community Member
    Join Date
    Dec 2007
    Posts
    57

    Default Re: question about custom module

    MySQL will let you access a different database other than the one selected. Just prefix your table name with the database name in your query.

    Code:
    SELECT * FROM db2.mytable
    The key is that both databases must be using the same user/password. If the user/pass is different, you will need to create a new db connection using the appropriate credentials. I find this isn't an issue because it just makes sense to use the same db user if you have two apps sharing data like this.

    Hope this helps!

    Jay

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Question about the Custom Fields
    By Virog in forum Developer Help
    Replies: 3
    Last Post: 2008-08-12, 04:47 PM
  2. Question on Custom Fields
    By Execupay in forum Developer Help
    Replies: 2
    Last Post: 2008-07-31, 07:00 PM
  3. Custom Module Question.
    By dblake in forum Developer Help
    Replies: 2
    Last Post: 2007-09-26, 02:51 PM
  4. question about custom fields
    By davidmcb in forum Help
    Replies: 0
    Last Post: 2005-12-23, 11:11 PM
  5. Beginner Custom Module question / Mr Milk
    By mikesugar in forum Help
    Replies: 1
    Last Post: 2005-12-07, 03:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •