示例#1
0
文件: mysql.php 项目: tapiau/muyo
 /**
  * @param string|null $q
  * @param bool $collection
  * @return Lib_Model_Set
  * @throws Exception
  */
 public function loadSet($q = null, $collection = false)
 {
     $q = $this->getSelect();
     $pkey = $this->getPrimaryKey();
     if (count($q->getPart('columns')) == 0) {
         $q->columns(['*']);
     } elseif (!$collection && !array_some($this->getColumns(), function ($arr) use($pkey) {
         return $pkey == zend_column_name($arr);
     })) {
         $this->setColumns($pkey);
     }
     $db = $this->getDb();
     $this->preLoad();
     try {
         $result = $db->fetchAll($q);
     } catch (Exception $e) {
         throw new Exception('Error while loading: ' . $e->getMessage() . ' | SQL: ' . $q->assemble());
     }
     $this->postLoad();
     $set = new Lib_Model_Set();
     $set->setResultSet($result);
     $set->setModel($this);
     return $set;
 }
示例#2
0
文件: mongo.php 项目: tapiau/muyo
 /**
  * @return Lib_Model_Set
  */
 public function loadSet()
 {
     $alias = $this->getAlias();
     $array = $this->loadArray();
     $t = $this;
     $set = new Lib_Model_Set();
     $set->setResultSet($array[$alias]);
     $set->setModel($this);
     return $set;
 }