예제 #1
0
 function __construct($link, $res)
 {
     parent::__construct($link, $res);
     if (gettype($res) == "boolean") {
         $this->res = null;
         $this->cur = 0;
         $this->max = 0;
     } else {
         $this->cur = 0;
         $this->max = mysqli_num_rows($this->res) - 1;
     }
 }
예제 #2
0
 function DbPdoResult($link, $res)
 {
     parent::__construct($link, $res);
     $this->cur = 0;
     //EchoBacktrace();
     if (!$this->res) {
         $this->rows = array();
     } else {
         $this->rows = $this->res->fetchAll();
     }
     $this->max = count($this->rows) - 1;
 }
예제 #3
0
 function __construct($link, $res)
 {
     parent::__construct($link, $res);
     $this->cur = 0;
     $this->max = mssql_num_rows($this->res) - 1;
 }
예제 #4
0
 /**
  * Fetches all SQL result rows as a sequential array.
  *
  * @param Zend_Db_Select $sql An SQL SELECT statement.
  * @param array $bind Data to bind into SELECT placeholders.
  * @return array
  */
 public function fetchObjects($class, $sql = null, $bind = array(), $authRole = null)
 {
     $tmp = new DbResultSet();
     $this->typeManager->includeType($class);
     $map = $this->typeManager->getTypeMap($class);
     $class = strtolower($class);
     if ($sql == null) {
         $sql = $this->select();
         $sql->from($class, '*');
     }
     if (!is_null($authRole)) {
         $itemtype = $class;
         $currentUser = za()->getUser()->getUsername();
         $sql->joinInner('userrole', 'userrole.itemid=' . $itemtype . '.id', new Zend_Db_Expr('userrole.itemtype as userrole_itemtype'));
         // $select->joinInner($usertable, $usertable.'.username=userrole.authority', new Zend_Db_Expr('userrole.authority as userrole_authority'));
         $sql->where('userrole.authority = ?', $currentUser);
         $sql->where(new Zend_Db_Expr('userrole.role & ' . $authRole));
     }
     $result = $this->query($sql, $bind);
     while ($row = $result->fetch(Zend_Db::FETCH_ASSOC)) {
         $obj = new $class();
         $obj = $this->unwrapRowToObject($obj, $row, $map);
         za()->inject($obj);
         $tmp[$obj->id] = $obj;
         // $tmp->append($obj);
     }
     if ($sql instanceof CountableSelect && $sql->isLimited()) {
         $countSql = $sql->getCountQuery();
         $count = $this->fetchOne($countSql);
         $tmp->setTotalResults($count);
     }
     return $tmp;
 }