示例#1
0
 /**
  * Camelizes a word.
  *
  * @param string  $word
  * @param boolean $lowercaseFirstLetter
  * @return string
  * @link http://www.zend.com/codex.php?id=1564&single=1
  */
 function camelize($word, $lowercaseFirstLetter = false)
 {
     $camelizedWord = str_replace(' ', '', ucwords(preg_replace('/(?:(?<!\\d)[^A-Z^a-z^0-9](?!\\d))+/', ' ', $word)));
     if (!$lowercaseFirstLetter) {
         return $camelizedWord;
     } else {
         return Piece_ORM_Inflector::lowercaseFirstLetter($camelizedWord);
     }
 }
示例#2
0
 /**
  * Creates a criteria object from a method name and a value as
  * a criterion.
  *
  * @param string $methodName
  * @param mixed  $criterion
  * @return stdClass
  * @throws PIECE_ORM_ERROR_UNEXPECTED_VALUE
  */
 function &_createCriteria($methodName, $criterion)
 {
     if (preg_match('/By(.+)$/', $methodName, $matches)) {
         $criteria =& new stdClass();
         $criteria->{Piece_ORM_Inflector::lowercaseFirstLetter($matches[1])} = $criterion;
         return $criteria;
     } else {
         Piece_ORM_Error::push(PIECE_ORM_ERROR_UNEXPECTED_VALUE, "An unexpected value detected. {$methodName}() can only receive object or null. Or the method name does not contain the appropriate field name.");
         $return = null;
         return $return;
     }
 }