當前位置: 首頁>>代碼示例>>PHP>>正文


PHP fORM::isClassMappedToTable方法代碼示例

本文整理匯總了PHP中fORM::isClassMappedToTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP fORM::isClassMappedToTable方法的具體用法?PHP fORM::isClassMappedToTable怎麽用?PHP fORM::isClassMappedToTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fORM的用法示例。


在下文中一共展示了fORM::isClassMappedToTable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: determineSubject

 /**
  * Takes information from a method call and determines the subject, route and if subject was plural
  * 
  * @param string $class    The class the method was called on
  * @param string $subject  An underscore_notation subject - either a singular or plural class name
  * @param string $route    The route to the subject
  * @return array  An array with the structure: array(0 => $subject, 1 => $route, 2 => $plural)
  */
 private static function determineSubject($class, $subject, $route)
 {
     $schema = fORMSchema::retrieve($class);
     $table = fORM::tablize($class);
     $type = '*-to-many';
     $plural = FALSE;
     // one-to-many relationships need to use plural forms
     $singular_form = fGrammar::singularize($subject, TRUE);
     if ($singular_form && fORM::isClassMappedToTable($singular_form)) {
         $subject = $singular_form;
         $plural = TRUE;
     } elseif (!fORM::isClassMappedToTable($subject) && in_array(fGrammar::underscorize($subject), $schema->getTables())) {
         $subject = fGrammar::singularize($subject);
         $plural = TRUE;
     }
     $related_table = fORM::tablize($subject);
     $one_to_one = fORMSchema::isOneToOne($schema, $table, $related_table, $route);
     if ($one_to_one) {
         $type = 'one-to-one';
     }
     if ($one_to_one && $plural || !$plural && !$one_to_one) {
         throw new fProgrammerException('The table %1$s is not in a %2$srelationship with the table %3$s', $table, $type, $related_table);
     }
     $route = fORMSchema::getRouteName($schema, $table, $related_table, $route, $type);
     return array($subject, $route, $plural);
 }
開發者ID:mrjwc,項目名稱:printmaster,代碼行數:34,代碼來源:fActiveRecord.php


注:本文中的fORM::isClassMappedToTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。