/** * Gets the length of the value in a particular field. This can be especially * useful for blob and longtext fields that aren't loaded into memory. It allows * you to see if there is indeed a value there. * * @param string $fieldname The name of the field to check. * @param integer $index If this is a related field then this is the index offset. * @param string $where If this is a related field this is a where clause to filter the results. * @param string $sort If this is a related field then this is a sort clause to sort the results. * @return integer The length of the specified field's value in bytes. */ function getLength($fieldname, $index = 0, $where = 0, $sort = 0) { if (strpos($fieldname, '.') !== false) { list($relname, $localfieldname) = explode('.', $fieldname); $record =& $this->getRelatedRecords($relname, false, $index, null, $where, $sort); $relatedRecord = new Dataface_RelatedRecord($this, $relname, $record); $relatedRecord->setValues($this->_relatedMetaValues[$relname][0][0][$index]); return $relatedRecord->getLength($localfieldname); //$key = '__'.$localfieldname.'_length'; //if ( isset($record[$key]) ){ // return $record[$key]; //} else { // return null; //} } else { $key = '__' . $fieldname . '_length'; if (isset($this->_metaDataValues[$key])) { return $this->_metaDataValues[$key]; } else { return strlen($this->getValueAsString($fieldname)); } } }