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


PHP unknown::getType方法代碼示例

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


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

示例1: setItemByNode

 /**
  * 分離isset結構中的類型
  * isset($id) ? $_GET['id'] : 2;
  * 轉為:
  * 		array($_GET[id],2)
  * @param unknown $node
  */
 public function setItemByNode($node)
 {
     //處理三元表達式
     if ($node->getType() == "Expr_Ternary") {
         if ($node->if->getType() == "Expr_Ternary") {
             $this->setItemByNode($node->if);
         }
         if ($node->else->getType() == "Expr_Ternary") {
             $this->setItemByNode($node->else);
         }
         $if_node = SymbolUtils::getSymbolByNode($node->if);
         $else_node = SymbolUtils::getSymbolByNode($node->else);
         $if_node && $this->addSymbol($if_node);
         $else_node && $this->addSymbol($else_node);
     } else {
         return;
     }
 }
開發者ID:getcode2git,項目名稱:phpvulhunter,代碼行數:25,代碼來源:MutipleSymbol.class.php

示例2: normalizeRelatedRecords

 /**
  * Normalize the related records so they can be added into the response object
  *
  * @param unknown $baseRecord            
  * @param unknown $relatedRecords            
  * @param unknown $relation            
  * @return boolean
  */
 protected function normalizeRelatedRecords($baseRecord, $relatedRecords, $relation)
 {
     $refType = $relation->getType();
     $refModelNameSpace = $relation->getReferencedModel();
     // store a copy of all related record (PKIDs)
     // this must be attached w/ the parent records for joining purposes
     $relatedRecordIds = null;
     $refModel = new $refModelNameSpace();
     $primaryKeyName = $refModel->getPrimaryKeyName();
     // save the PKID for each record returned
     if (count($relatedRecords) > 0) {
         // 1 = hasOne 0 = belongsTo 2 = hasMany
         switch ($refType) {
             // process hasOne records as well
             case 1:
                 // do nothin w/ hasOne since these are auto merged into the main record
                 break;
             case 0:
                 // this doesn't seem right, why are they occasionally showing up inside an array?
                 if (isset($relatedRecords[$primaryKeyName])) {
                     $relatedRecordIds = $relatedRecords[$primaryKeyName];
                     // wrap in array so we can store multiple hasOnes from many different main records
                     $relatedRecords = array($relatedRecords);
                 } else {
                     $relatedRecordIds = $relatedRecords[0][$primaryKeyName];
                 }
                 break;
             default:
                 $relatedRecordIds = array();
                 foreach ($relatedRecords as $rec) {
                     $relatedRecordIds[] = $rec[$primaryKeyName];
                 }
                 break;
         }
     } else {
         $relatedRecordIds = null;
     }
     // we map table names to end point resource names and vice versa
     // regardless of relationship, the related records are returned as part of the end point resource name
     $this->updateRestResponse($relation->getTableName(), $relatedRecords);
     // add related record ids to the baseArray
     // this is how JSON API suggests that you related resources
     // will save nothing, a single value or an array
     // does this only run when working with hasMany?
     // belongsTo and hasOne are already in place, yes?
     if ($relatedRecordIds !== null) {
         if ($refType == 2 || $refType == 4) {
             $suffix = '_ids';
             // populate the linked property or merge in additional records
             // attempt to store the name similar to the table name
             $name = $relation->getTableName('singular');
             $this->baseRecord[$name . $suffix] = $relatedRecordIds;
         }
     }
     return true;
 }
開發者ID:marceloandrader,項目名稱:phalcon-json-api-package,代碼行數:64,代碼來源:Entity.php


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