2

So I Have recently run a few queries on the database through the Magento API calls such as

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$readresult = $connection_write->query("SELECT data_index FROM catalogsearch_fulltext WHERE MATCH(data_index) AGAINST ('anji') AND store_id = '1'");
$row = $readresult->fetch();

However, apparently this crashes the entire server after looping through about 30 records, manipulating them, and writing back to the records.

There has to be a way to manipulate values of database tables in Magento. Is there a way I can direclty query the database and bypass all of Magento's bulky API?

Thanks!

EDIT: To anyone that may find this later.

I had good success with bypassing the Magento API for database calls. Simply directly querying the database worked much much faster.

However, in my case my table was not interrelated with other tables. Many tables in Magento are interrelated and if you change something in one table, there will be a domino effect in other tables. SO ONLY DO THIS WITH EXTREME CAUTION.

Nathaniel Wendt
  • 1,194
  • 4
  • 23
  • 49
  • It's a mysql database and I am trying to access the catalogsearch_fulltext table. – Nathaniel Wendt Aug 17 '11 at 22:51
  • In my option, you should check what the magento core Model and Controller do. Because magento database use EAV schema, several tables are mix together, so make simple query to one table is not recommend. – Michael Bai Aug 18 '11 at 01:51
  • yes, usually this is the case. But in my case, I am just manipulating one table. It is one of the only tables that is not connected through the EAV schema...so could I just create a direct connection as usual and query the table? – Nathaniel Wendt Aug 18 '11 at 05:07

1 Answers1

1

Magento is SLOW by default, thats one of the Magento major problem in my opinion. It's slow and complex. You can use (call) this:

require_once '{ROOT_DIR}/app/Mage.php';
Mage::app('default');

and try to make a custom function but it will not be so much faster than Magento itself. You still use the Magento's classes but you can develop your own function but still you need some background knowledge which is not really easy to get - documentation is poor. Maybe you can start with some magento blogs and tips online.

You said it stopped working over about 30 seconds. Thats usually default time limit for PHP to stop executing. So also try to use set_time_limit at the top of your PHP file:

set_time_limit(0); //for unlimited time limit or
set_time_limit(120); //for 120 seconds time limit for example

Also connect using FTP and locate (usually) this directory:

{root}/var/cache/

There should be some subdirectories like: mage--0, mage--1, mage--2 ... etc. You can delete them from time to time. This is CACHE files and i noticed that if there are plenty of CACHE files magento work slowly. If you delete this cache files and directories it works better for some time.

StudioArena
  • 412
  • 5
  • 9