[development] new dev q: are mysql queries possible within drupal?

spartaguy spartaguy spartaguy300 at gmail.com
Mon Nov 16 12:55:01 UTC 2009


 I have two databases - one is for drupal data. The other db is for customer
data. Inside the customer data db is a table - customer_data.

I want to do a select * on customer_data in the customer database and show
the result on screen.

Can someone tell me how to do this?



On Mon, Nov 16, 2009 at 7:36 PM, Frederik Grunta <fgrunta at gmail.com> wrote:

> I don't understand what you mean regarding the menu. But regarding you
> question about if its possible to use a second database - yes it is,
> provididing they are both the same type (ie, two Mysql databases). Change
> settings.php to read:
>
> $db_url['default'] = 'mysql://username1:password1@localhost/drupal';
> $db_url['otherdb'] = 'mysql://username2:password2@localhost/otherdb';
>
> And to query it:
>
> db_set_active('otherdb');
>
> //Run queries as normal
>
> db_set_active('default');
>
> Don't forget to set the active database back to default when you are done,
> or interesting things happen.
>
> 2009/11/16 spartaguy spartaguy <spartaguy300 at gmail.com>
>
>
>>  I want to do a select on a table and just display the results in main
>> window pane.
>>
>> ie header is standard logo, left hand side is navigation menu.
>> One of the navigation items should be able to do a query on a table in the
>> local drupal database or ideally in a separate database.
>>
>> the mysql syntax is the easy part. its the creating a menu item that will
>> do the mysql select statement and display the results in the main window
>> pane.
>>
>> Does this make sense?
>>
>>
>> Paul
>>
>>
>> On Mon, Nov 16, 2009 at 10:37 AM, Nancy Wichmann <nan_wich at bellsouth.net>wrote:
>>
>>>  Spartaguy wrote:
>>>
>>> > How can I add a menu item to the Primary Links menu that will do a
>>> select * from table1 and then print it out in the right hand panel?
>>> Your information is less than complete.
>>>
>>>
>>>
>>> Select on what? Is there a dialog of some sort? I’m guessing what you
>>> really want is a block.
>>>
>>>
>>>
>>> Nancy E. Wichmann, PMP
>>>
>>> Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L.
>>> King, Jr.
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091116/ce7f9ba0/attachment.html 


More information about the development mailing list