Subversion Repositories PHPX

Rev

Rev 75 | Rev 77 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 75 Rev 76
Line 572... Line 572...
572
   *   If provided, MUST start with ORDER BY or GROUP BY
572
   *   If provided, MUST start with ORDER BY or GROUP BY
573
   * @param string $limit Limit (optional)
573
   * @param string $limit Limit (optional)
574
   * @param int $fetch_style
574
   * @param int $fetch_style
575
   *   The mode that should be used for {@link PDOStatement::fetchAll()}.
575
   *   The mode that should be used for {@link PDOStatement::fetchAll()}.
576
   *   The default is {@link PDO::FETCH_ASSOC}.
576
   *   The default is {@link PDO::FETCH_ASSOC}.
-
 
577
   * @param bool $fetchAll
-
 
578
   *   If <code>true</code> (default), fetches all rows at once.
-
 
579
   *   You can set this to <code>false</code> in case of memory problems,
-
 
580
   *   in which case this function will return the prepared
-
 
581
   *   {@link PDOStatement} instead of the result array.  You can then use
-
 
582
   *   {@link PDOStatement::fetch()} to get the returned rows iteratively.
-
 
583
   *   <var>fetch_style</var> will be ignored then, so that you can safely
-
 
584
   *   pass <code>null</code>, for example.
577
   * @return array
585
   * @return array|PDOStatement
578
   * @see Database::prepare()
586
   * @see Database::prepare()
579
   * @see PDOStatement::fetchAll()
587
   * @see PDOStatement::fetchAll()
580
   */
588
   */
581
  public function select($tables, $columns = null, $where = null,
589
  public function select($tables, $columns = null, $where = null,
582
    $order = null, $limit = null, $fetch_style = \PDO::FETCH_ASSOC)
590
    $order = null, $limit = null, $fetch_style = \PDO::FETCH_ASSOC,
-
 
591
    $fetchAll = true)
583
  {
592
  {
584
    if (is_null($columns))
593
    if (is_null($columns))
585
    {
594
    {
586
      $columns = array('*');
595
      $columns = array('*');
587
    }
596
    }
Line 621... Line 630...
621
    if (!is_null($limit))
630
    if (!is_null($limit))
622
    {
631
    {
623
      $query .= " LIMIT $limit";
632
      $query .= " LIMIT $limit";
624
    }
633
    }
625
634
-
 
635
    $stmt = ($fetchAll
626
    $stmt = $this->prepare($query);
636
      ? $this->prepare($query)
-
 
637
      : $this->prepare($query, array(\PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL)));
627
638
628
    $params = array();
639
    $params = array();
629
640
630
    if (is_array($where) && $this->_isAssociativeArray($where))
641
    if (is_array($where) && $this->_isAssociativeArray($where))
631
    {
642
    {
Line 667... Line 678...
667
678
668
    $errorInfo =& $this->_lastError;
679
    $errorInfo =& $this->_lastError;
669
    $errorInfo =  $stmt->errorInfo();
680
    $errorInfo =  $stmt->errorInfo();
670
681
671
    $result =& $this->_lastResult;
682
    $result =& $this->_lastResult;
-
 
683
-
 
684
    if ($fetchAll)
-
 
685
    {
672
    $result =  $stmt->fetchAll($fetch_style);
686
      $result = $stmt->fetchAll($fetch_style);
-
 
687
    }
-
 
688
    else
-
 
689
    {
-
 
690
      $result = $stmt;
-
 
691
    }
673
692
674
    if (defined('DEBUG') && DEBUG > 1)
693
    if (defined('DEBUG') && DEBUG > 1)
675
    {
694
    {
676
      debug(array(
695
      debug(array(
677
        '_lastSuccess' => $success,
696
        '_lastSuccess' => $success,
Line 1041... Line 1060...
1041
      ));
1060
      ));
1042
    }
1061
    }
1043
1062
1044
    return $success;
1063
    return $success;
1045
  }
1064
  }
1046
}
-
 
1047
1065
}
-
 
1066