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) |
Definition at line 32 of file Query.php.
_beforeSave | ( | Mage_Core_Model_Abstract $ | object | ) |
Perform actions before object save
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
string | $field | |
mixed | $value |
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
Mage_Core_Model_Abstract | $object | |
mixed | $value | |
string | $field field to load by (defaults to model id) |
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
Mage_Core_Model_Abstract | $object | |
string | $value |
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 }