Esempio n. 1
0
 /**
  * @see DB_common::getAssoc
  */
 public function fetchAssoc($query, $params = array(), $fetchmode = DB_FETCHMODE_DEFAULT)
 {
     $query = $this->quoteSql($query, $params);
     $res = $this->db->getAssoc($query, false, $params, $fetchmode, false);
     $this->assertError($res);
     return $res;
 }
Esempio n. 2
0
 /**
  * Gets the packages of sub-categories of a category indexed by the
  * sub-category id
  *
  * @param integer $categoryId optional. The id of the category. If null,
  *                            the top-level category is used. Defaults
  *                            to null.
  * @param string  $php        optional. PHP version on which to filter. If
  *                            not specified, defaults to 'all'.
  *
  * @return array an associative array with the sub-category id as the key
  *               and an array of packages as the value.
  */
 protected function getSubPackages($categoryId = null, $php = 'all')
 {
     $categoryWhere = $this->getCategoryWhereClause($categoryId);
     $sql = '
         SELECT
             p.category, p.id AS id, p.name AS name, p.summary AS summary
         FROM categories c
         LEFT JOIN packages p ON p.category = c.id';
     $sql .= $this->getPhpVersionJoinClause($php);
     $sql .= '
         WHERE
             c.parent ' . $categoryWhere . '
             AND p.approved = 1
             AND p.package_type = "' . SITE . '"
             AND (p.newpk_id IS NULL OR p.newpk_id = 0)
             AND p.category = c.id';
     $sql .= $this->getPhpVersionWhereClause($php);
     if ($php != 'all') {
         $sql .= '
             GROUP BY p.id';
     }
     $sql .= '
         ORDER BY p.name';
     return $this->dbh->getAssoc($sql, false, null, DB_FETCHMODE_ASSOC, true);
 }
Esempio n. 3
0
 /**
  * SQL文を実行し、連想配列データを取得する(SELECT専用)
  * ※ループ処理などでは使用しない。
  * ※SQLの解析が繰り返し行なわれるため処理が遅い。
  * (SQLの結果セットを連想配列データで取得したい(プルダウンリスト)場合に
  * 使用する)
  * <処理内容>
  * ・selectの先頭カラムをキー(key)に、残りのカラムを値配列(array)として
  *  取得する。
  *	(データ形式) array([key]=>array([0]=>data, ・・・・)
  * ・selectのカラムが2列しかない場合は、値として取得する。
  *	(データ形式) array[key]=>data
  * ・SQLの解析(prepare)を行なってからSQL文を実行する
  * ・SQL文の実行エラーが発生したら、トランザクションをロールバックする
  * @access public
  * @param string $sql SQL文
  * @param boolean $force 連想配列ではなく配列にするか
  * 			(デフォルト:false)
  * @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…)で取得する
  * @param boolean $group キー重複時に配下の配列を入れ子にするか
  * 			(デフォルト:false)
  * @return array SQL文の実行結果(全レコード)
  * 		(Selectが成功した場合、連想配列オブジェクトをセットする)
  * @throws DatabaseException SQL文の実行エラーが発生した時
  */
 function execQuerySqlAssoc($sql, $force = false, $params = array(), $fetchMode = DB_FETCHMODE_DEFAULT, $group = false)
 {
     $rs =& $this->db->getAssoc($sql, $force, $params, $fetchMode, $group);
     if (DB::isError($rs)) {
         $this->db->rollback();
         throw new DatabaseException($rs->getMessage());
     }
     return $rs;
 }
Esempio n. 4
0
 /**
  * Calls DB_common::getAssoc()
  *
  * @param $query the SQL query
  * @param $force_array (optional) used only when the query returns
  * exactly two columns.  If true, the values of the returned array
  * will be one-element arrays instead of scalars.
  * starting at 0] or string [column name])
  * @param array $data if supplied, prepare/execute will be used
  *        with this array as execute parameters
  * @param $fetchmode the fetch mode to use
  * @param boolean $group see DB_Common::getAssoc()
  * @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 indexed array with the data from the first
  * row at index 0, or a DB error code.
  * @see DB_common::getAssoc()
  * @access public
  */
 function &getAssoc($query, $force_array = false, $data = array(), $fetchmode = DB_FETCHMODE_ORDERED, $group = false, $action = null, $params = array())
 {
     $this->q_action = $action ? $action : $this->action;
     $this->q_params = $params;
     $result = parent::getAssoc($query, $force_array, $data, $fetchmode, $group);
     return $result;
 }
Esempio n. 5
0
 /**
  * Calls DB_common::getAssoc()
  *
  * @param $query the SQL query
  * @param $force_array (optional) used only when the query returns
  * exactly two columns.  If true, the values of the returned array
  * will be one-element arrays instead of scalars.
  * starting at 0] or string [column name])
  * @param array $data if supplied, prepare/execute will be used
  *        with this array as execute parameters
  * @param $fetchmode the fetch mode to use
  * @param boolean $group see DB_Common::getAssoc()
  * @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 indexed array with the data from the first
  * row at index 0, or a DB error code.
  * @see DB_common::getAssoc()
  * @access public
  */
 function &getAssoc($query, $force_array = false, $data = array(), $fetchmode = DB_FETCHMODE_ORDERED, $group = false, $action = 'search', $params = array())
 {
     $this->q_action = $action;
     $this->q_params = $params;
     return parent::getAssoc($query, $force_array, $data, $fetchmode, $group);
 }