Esempio n. 1
0
 /**
  * SQL文を実行し、配列データを取得する(SELECT専用)
  *	(データ形式) array([0]=>array([0]=>data, ・・・・)
  * ※ループ処理などでは使用しない。
  * ※SQLの解析が繰り返し行なわれるため処理が遅い。
  * (SQLの結果セットを配列データで取得したい場合に使用する)
  * <処理内容>
  * ・SQLの解析(prepare)を行なってからSQL文を実行する
  * ・SQL文の実行エラーが発生したら、トランザクションをロールバックする
  * @access public
  * @param string $sql SQL文
  * @param array $params SQL文にセットするパラメータ
  * @param string $fetchModeフェッチモード(デフォルト:DB_FETCHMODE_ORDERED)
  *  DB_FETCHMODE_ORDERED・・・配列データをインデックス配列([0][1]…)で取得する
  *  DB_FETCHMODE_ASSOC・・・配列データを連想配列([id][name]…)で取得する
  *  DB_FETCHMODE_OBJECT・・・配列データをオブジェクト($data->id…)で取得する
  * @return array SQL文の実行結果(全レコード)
  * 		(Selectが成功した場合、2次元配列オブジェクトをセットする)
  * @throws DatabaseException SQL文の実行エラーが発生した時
  */
 function execQuerySqlAll($sql, $params = array(), $fetchMode = DB_FETCHMODE_DEFAULT)
 {
     $rs =& $this->db->getAll($sql, $params, $fetchMode);
     if (DB::isError($rs)) {
         $this->db->rollback();
         throw new DatabaseException($rs->getMessage());
     }
     return $rs;
 }
Esempio n. 2
0
 /**
  * @see DB_common::getAll
  */
 public function getAll($query, $params = array(), $fetchmode = DbInterface::DB_FETCHMODE_ASSOC)
 {
     $query = $this->quoteSql($query, $params);
     $res = $this->db->getAll($query, $params, $fetchmode);
     $this->assertError($res);
     return $res;
 }
Esempio n. 3
0
 /**
  * Gets detailed information about packages in a category.
  *
  * @param integer $categoryId the category to for which to get package
  *                            information.
  * @param string  $php        optional. The PHP version on which to filter.
  *                            If not specified, defaults to 'all'.
  *
  * @return array an array of packages with each array element being an array
  *               containing information about a specific package.
  */
 protected function getPackages($categoryId, $php = 'all')
 {
     $sql = '
         SELECT
             p.id, p.name, p.summary, p.license, p.unmaintained, p.newpk_id,
             (SELECT COUNT(package) FROM releases WHERE package = p.id) AS numreleases,
             (SELECT state FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS status,
             (SELECT version FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS version,
             (SELECT releasedate FROM releases WHERE package = p.id ORDER BY id DESC LIMIT 1) AS releasedate,
             (SELECT COUNT(1)
                 FROM bugdb
                 WHERE package_name = p.name AND status IN
                     (\'Open\', \'Verified\',  \'Assigned\')
             ) as numbugs
         FROM packages p';
     $sql .= $this->getPhpVersionJoinClause($php);
     $sql .= '
         WHERE
             p.package_type = ? AND p.approved = 1 AND p.category = ?';
     $sql .= $this->getPhpVersionWhereClause($php);
     if ($php != 'all') {
         $sql .= '
             GROUP BY p.id';
     }
     $sql .= '
         ORDER BY p.name ASC';
     $this->dbh->setFetchmode(DB_FETCHMODE_ASSOC);
     return $this->dbh->getAll($sql, array(SITE, $categoryId));
 }
Esempio n. 4
0
 /**
  * Fetch all the rows returned from a query.
  *
  * @param $query the SQL query
  * @param array $data if supplied, prepare/execute will be used
  *        with this array as execute parameters
  * @param $fetchmode the fetch mode to use
  * @param string $action type of request to perform, defaults to search (ldap_search())
  * @param array $params array of additional parameters to pass to the PHP ldap function requested
  * @access public
  * @return array an nested array, or a DB error
  * @see DB_common::getAll()
  */
 function &getAll($query, $data = null, $fetchmode = DB_FETCHMODE_DEFAULT, $action = null, $params = array())
 {
     $this->q_action = $action ? $action : $this->action;
     $this->q_params = $params;
     $result = parent::getAll($query, $data, $fetchmode);
     return $result;
 }
Esempio n. 5
0
 /**
  * Fetch all the rows returned from a query.
  *
  * @param $query the SQL query
  * @param array $data if supplied, prepare/execute will be used
  *        with this array as execute parameters
  * @param $fetchmode the fetch mode to use
  * @param string $action type of request to perform, defaults to search (ldap_search())
  * @param array $params array of additional parameters to pass to the PHP ldap function requested
  * @access public
  * @return array an nested array, or a DB error
  * @see DB_common::getAll()
  */
 function &getAll($query, $data = null, $fetchmode = DB_FETCHMODE_DEFAULT, $action = 'search', $params = array())
 {
     $this->q_action = $action;
     $this->q_params = $params;
     return parent::getAll($query, $data, $fetchmode);
 }