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


PHP Dao::create方法代碼示例

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


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

示例1: createDao

 public function createDao($tableName)
 {
     if (!$this->pdoReady()) {
         throw new PeeweeException("接続が初期化されていません");
     }
     if (empty($tableName)) {
         throw new PeeweeException("テーブル名が指定されていません。");
     }
     $dao = Dao::create($this->pdo, $tableName);
     return $dao;
 }
開發者ID:634,項目名稱:peewee2,代碼行數:11,代碼來源:Peewee.php

示例2: create

 public function create(Vo $vo)
 {
     $vo->setSenha(md5($vo->getSenha()));
     return parent::create($vo);
 }
開發者ID:JoaoAntonioMaruti,項目名稱:AulasUnipar2015,代碼行數:5,代碼來源:Usuario.php

示例3: search

 public function search($conditions = array(), $page = array(), $relations = array())
 {
     if (!$this->pdoReady()) {
         throw new Exception("接続が初期化されていません");
     }
     if (empty($this->tableName)) {
         throw new Exception("テーブル名を指定してください");
     }
     if ($conditions == null) {
         $conditions = array();
     }
     if ($page == null) {
         $page = array();
     }
     if ($relations == null) {
         $relations = array();
     }
     $sql = "select * from " . $this->tableName;
     if (!empty($conditions)) {
         $sql .= " where ";
         $index = 0;
         foreach ($conditions as $key => $value) {
             if ($index != 0) {
                 $sql .= " and ";
             }
             $sql .= $key . "= :{$key} ";
             $index++;
         }
     }
     $pageNumber = $page["page"];
     $pageCount = $page["count"];
     if (empty($pageNumber) || empty($pageCount)) {
     } else {
         $offset = ($pageNumber - 1) * $pageCount;
         $sql .= " limit " . $offset . " , " . $pageCount;
     }
     $stmt = $this->pdo->prepare($sql);
     foreach ($conditions as $key => $value) {
         $stmt->bindValue(":" . $key, $value);
     }
     $result = $stmt->execute();
     $resultArray = array();
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $Dto = new Dto($this->tableName);
         foreach ($row as $columnKey => $columnValue) {
             $Dto->{$columnKey} = $this->convertTypeMismatch($columnKey, $columnValue);
         }
         $resultArray[] = $Dto;
     }
     if (!empty($relations)) {
         for ($i = 0; $i < count($resultArray); $i++) {
             $result = $resultArray[$i];
             foreach ($relations as $relationTableName => $relationKeys) {
                 $relationParams = array();
                 foreach ($relationKeys as $relationKey => $foreignKey) {
                     $relationParams[$foreignKey] = $result->{$relationKey};
                 }
                 $relationDao = Dao::create($this->pdo, $relationTableName);
                 $relationList = $relationDao->search($relationParams);
                 $result->{$relationTableName} = $relationList;
             }
             $resultArray[$i] = $result;
         }
     }
     return $resultArray;
 }
開發者ID:634,項目名稱:peewee2,代碼行數:66,代碼來源:Dao.php


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