Esempio n. 1
0
 /**
  * Retrieve a meta value from the database
  * This only works if the model is setup to work a meta table
  * If not, null will be returned
  *
  * @param Fishpig_Wordpress_Model_Meta_Abstract $object
  * @param string $metaKey
  * @param string $selectField
  * @return null|mixed
  */
 public function getMetaValue(Fishpig_Wordpress_Model_Abstract $object, $metaKey, $selectField = 'meta_value')
 {
     if ($object->hasMeta()) {
         $select = $this->_getReadAdapter()->select()->from($object->getMetaTable(), $selectField)->where($object->getMetaObjectField() . '=?', $object->getId())->where('meta_key=?', $metaKey)->limit(1);
         if (($value = $this->_getReadAdapter()->fetchOne($select)) !== false) {
             return trim($value);
         }
         return false;
     }
     return null;
 }