Results 1 to 4 of 4

Thread: database credentials from "config.php"

  1. #1
    shajiuddin is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Dubai UAE
    Posts
    50

    Default database credentials from "config.php"

    Hi,

    I want to use database credentials from "config.php" on my "logic hooks" file for database connectivity.
    Regards

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: database credentials from "config.php"

    You don't need to create a separate connection to query the database via a logic hook.

    Give this example a look:

    http://cheleguanaco.blogspot.com/200...k-example.html
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    shajiuddin is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Dubai UAE
    Posts
    50

    Default Re: database credentials from "config.php"

    Hi Angel,

    Yes you are right but see we define these lines in logic hooks file

    $hook_version = 1;
    $hook_array = Array();
    $hook_array['before_save'][] = Array(1, 'assignUser', 'custom/modules/Cases/autoUserAssignment.php', 'UserAssignment', 'updateCase');

    We don't need to configure database connection in our "logic_hooks.php" because there's no database activity is involve.

    But, In "autoUserAssignment.php" we should have to configure database connection just because of database activity is involve.

    Now, what you say about it?
    How can we configure database connection from (config.php database credentials) in "autoUserAssignment.php" ?

  4. #4
    care is offline Senior Member
    Join Date
    Mar 2011
    Location
    Netherlands
    Posts
    53

    Default Re: database credentials from "config.php"

    PHP Code:
    require_once pathtoconfig.php
    include_once pathtoconfig_override.php

    $sql_connection 
    mysql_connect($sugar_config['dbconfig']['db_host_name'], $sugar_config['dbconfig']['db_user_name'], $sugar_config['dbconfig']['db_password']);
    $sql_db mysql_select_db($sugar_config['dbconfig']['db_name']); 
    That should work

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Error in "Repair Database" -- inconsistent case control
    By aleksans in forum Developer Help
    Replies: 2
    Last Post: 2011-04-18, 12:56 PM
  2. Replies: 3
    Last Post: 2009-07-14, 11:28 AM
  3. Installer quits at "Populating the database tables with demo data"
    By nathanfunk in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2007-07-26, 12:04 AM
  4. "apache config test fails, aborting"
    By Bill P. in forum Help
    Replies: 1
    Last Post: 2006-02-20, 09:24 PM
  5. Should "Config.php" be empty?
    By Peterkb in forum General Discussion
    Replies: 4
    Last Post: 2005-09-07, 02:08 AM

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
  •