Magento Forum

any easy way to make a database select? 
 
senders
Member
 
Avatar
Total Posts:  49
Joined:  2008-02-26
Germany, Mannheim
 

Hi,

I hope someone can help me.

I have written an own shipping modul. And I have got an own database table where rates are inserted.

But now my problem is, I need to get the rates out of the table.

Is there an easy way to make a select ?

I tried it with Zend fetchAll but I don’t know the magento object which points to it.

I also tried it with getReadAdapter but I first have to implement this function.
But how.

I just need an easy and fast way to do only one select!

My structure depends on: http://www.magentocommerce.com/boards/viewthread/7247/

Hope you can help me.

Kind regards,

Sebastian

 
Magento Community Magento Community
Magento Community
Magento Community
 
senders
Member
 
Avatar
Total Posts:  49
Joined:  2008-02-26
Germany, Mannheim
 

Has nobody got an idea?

:-(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Fontis
Sr. Member
 
Avatar
Total Posts:  99
Joined:  2007-08-31
Melbourne, Australia
 

I came up with the following way of doing it: http://www.chnorton.com.au/2008/06/18/running-arbitrary-database-queries/

I think this is basically where you were going and just needed the right object to call fetch on. I’m not sure if this is the best way but it works everywhere I’ve tried to use it and it’s only a couple lines of code. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Unirgy
Guru
 
Avatar
Total Posts:  478
Joined:  2007-09-07
 

hey there’s another way to get any connection:

$read Mage::getSingleton('core/resource')->getConnection('core_read');

$write Mage::getSingleton('core/resource')->getConnection('core_write');
it’s better to keep ‘em separated for cluster environments smile
 
Magento Community Magento Community
Magento Community
Magento Community
 
senders
Member
 
Avatar
Total Posts:  49
Joined:  2008-02-26
Germany, Mannheim
 
Chris Norton - 01 July 2008 03:43 PM

I came up with the following way of doing it: http://www.chnorton.com.au/2008/06/18/running-arbitrary-database-queries/

I think this is basically where you were going and just needed the right object to call fetch on. I’m not sure if this is the best way but it works everywhere I’ve tried to use it and it’s only a couple lines of code. smile

Hi Chris.

perfect this is what I need.

Thanks a lot.

I tried a lot, but everything didn’t work.

You example is pretty fine.

Kind regards,

Sebastian

 
Magento Community Magento Community
Magento Community
Magento Community
 
senders
Member
 
Avatar
Total Posts:  49
Joined:  2008-02-26
Germany, Mannheim
 
Saharian - 01 July 2008 04:15 PM

hey there’s another way to get any connection:

$read Mage::getSingleton('core/resource')->getConnection('core_read');

$write Mage::getSingleton('core/resource')->getConnection('core_write');
it’s better to keep ‘em separated for cluster environments smile

Hi Saharian,

I tried this before,

But this didn’t work for me.

Magento doesn’t know the getConnection function.

For this example I have to create definition in the config.xml and a Mysql4 Model....

But I could’t create the right one. :-(

The example from chris is working for me.

Thanks a lot to your both.

Kind regards,

Sebastian

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top