当前位置: 首页>>代码示例>>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;未经允许,请勿转载。