Mage_CatalogSearch_Model_Mysql4_Query Class Reference

Inheritance diagram for Mage_CatalogSearch_Model_Mysql4_Query:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 loadByQuery (Mage_Core_Model_Abstract $object, $value)
 load (Mage_Core_Model_Abstract $object, $value, $field=null)
 _beforeSave (Mage_Core_Model_Abstract $object)

Protected Member Functions

 _construct ()
 _getLoadSelect ($field, $value, $object)


Detailed Description

Catalog search query resource model

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Query.php.


Member Function Documentation

_beforeSave ( Mage_Core_Model_Abstract object  ) 

Perform actions before object save

Parameters:
Varien_Object $object

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 94 of file Query.php.

00095     {
00096         $object->setUpdatedAt($this->formatDate(Mage::getModel('core/date')->gmtTimestamp()));
00097         return $this;
00098     }

_construct (  )  [protected]

Init resource data

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 38 of file Query.php.

00039     {
00040         $this->_init('catalogsearch/search_query', 'query_id');
00041     }

_getLoadSelect ( field,
value,
object 
) [protected]

Retrieve select object for load object data

Parameters:
string $field
mixed $value
Returns:
Zend_Db_Select

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 50 of file Query.php.

00051     {
00052         $select = $this->_getReadAdapter()->select()
00053             ->from($this->getMainTable())
00054             ->where($this->getMainTable().'.'.$field.'=?', $value);
00055         return $select;
00056     }

load ( Mage_Core_Model_Abstract object,
value,
field = null 
)

Load an object

Parameters:
Mage_Core_Model_Abstract $object
mixed $value
string $field field to load by (defaults to model id)
Returns:
Mage_Core_Model_Mysql4_Abstract

Reimplemented from Mage_Core_Model_Mysql4_Abstract.

Definition at line 83 of file Query.php.

00084     {
00085         if (is_numeric($value)) {
00086             return parent::load($object, $value);
00087         }
00088         else {
00089             $this->loadByQuery($object,$value);
00090         }
00091         return $this;
00092     }

loadByQuery ( Mage_Core_Model_Abstract object,
value 
)

Custom load model by search query string

Parameters:
Mage_Core_Model_Abstract $object
string $value
Returns:
Mage_CatalogSearch_Model_Mysql4_Query

Definition at line 65 of file Query.php.

00066     {
00067         $select = $this->_getReadAdapter()->select()
00068             ->from($this->getMainTable())
00069             ->where('query_text=:query_text')
00070             ->where('store_id=:store_id');
00071         $bind = array(
00072             ':query_text' => $value,
00073             ':store_id'   => $object->getStoreId()
00074         );
00075         if ($data = $this->_getReadAdapter()->fetchRow($select, $bind)) {
00076             $object->setData($data);
00077             $this->_afterLoad($object);
00078         }
00079 
00080         return $this;
00081     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:49 2009 for Magento by  doxygen 1.5.8