Esempio n. 1
0
 /**
  * Constructor
  *
  * @param DB_Common $db An instance of a class that extends DB_Common.
  *
  * @throws XML_Query2XML_DBException If the fetch mode cannot be set to
  *                               DB_FETCHMODE_ASSOC.
  */
 public function __construct(DB_common $db)
 {
     $fetchModeError = $db->setFetchMode(DB_FETCHMODE_ASSOC);
     if (PEAR::isError($fetchModeError)) {
         // no unit tests for this one
         throw new XML_Query2XML_DBException('Could not set fetch mode to DB_FETCHMODE_ASSOC: ' . $fetchModeError->toString());
     }
     $this->_db = $db;
 }
Esempio n. 2
0
 private function getNumberAds($cat_id)
 {
     $result = 0;
     $q = 'SELECT COUNT(*) FROM ' . $this->mTbCompanies . ' WHERE id_cat = \'' . $cat_id . '\'';
     $result += $this->mDb->getOne($q);
     $q = 'SELECT id FROM ' . $this->mTbCats . ' WHERE parent = "' . $cat_id . '" AND active = 1';
     $db =& $this->mDb->query($q);
     $res = array();
     while ($row = $db->fetchRow()) {
         $result += $this->getNumberAds($row['id']);
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * 準備済みSQL文をまとめて実行する(INSERT/UPDATE/DELETE専用)
  * ※配列データを一括登録するなどに使用する。
  * ※SQLの解析が繰り返し行なわれないため処理が早い。
  * (同じSQLを繰り返し実行する場合に使用する)
  * <処理内容>
  * ・SQLの解析(prepare)はせずに準備済みのSQL文を実行する
  * ・実行途中で処理が失敗した場合、以降のデータは処理されません。
  * ・SQL文の実行エラーが発生したら、トランザクションをロールバックする
  * @access public
  * @param string $sql SQL文
  * @param array $data SQL文にセットする配列データ
  * @return object SQL文の実行結果
  * 		(INSERT/UPDATE/DELETEが成功した場合、DB_OKをセットする)
  * @throws DatabaseException SQL文の実行エラーが発生した時
  */
 function execMultipleSql($sth, $data = array())
 {
     $rs =& $this->db->executeMultiple($sth, $data);
     if (DB::isError($rs)) {
         $this->db->rollback();
         throw new DatabaseException($rs->getMessage());
     }
     return $rs;
 }
Esempio n. 4
0
    private function createBlackListTable($tableName)
    {
        $quotedTableName = $this->db->quoteIdentifier($tableName);
        $sql = <<<SQL
CREATE TABLE {$quotedTableName} (
    id     {$this->serialPriamryKey},
    uri    VARCHAR (255),
    size   INTEGER NOT NULL,
    md5    CHAR (32) NOT NULL,
    type   SMALLINT NOT NULL DEFAULT 0
){$this->tableExtraDefs};
SQL;
        return $this->doCreateTable($tableName, $sql);
    }
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);
 }
Esempio n. 6
0
 /**
  * Checks if the given query is a manipulation query. This also takes into
  * account the _next_query_manip flag and sets the _last_query_manip flag
  * (and resets _next_query_manip) according to the result.
  *
  * @param string The query to check.
  *
  * @return boolean true if the query is a manipulation query, false
  * otherwise
  *
  * @access protected
  */
 function _checkManip($query)
 {
     return preg_match('/^\\s*(SAVEPOINT|RELEASE)\\s+/i', $query) || parent::_checkManip($query);
 }
Esempio n. 7
0
File: oci8.php Progetto: roojs/pear
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_oci8()
 {
     parent::__construct();
 }
Esempio n. 8
0
File: odbc.php Progetto: roojs/pear
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_odbc()
 {
     parent::__construct();
 }
Esempio n. 9
0
 /**
  * This constructor calls <kbd>parent::__construct()</kbd>
  *
  * @return void
  */
 function __construct()
 {
     parent::__construct();
 }
Esempio n. 10
0
File: dbase.php Progetto: roojs/pear
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_dbase()
 {
     parent::__construct();
 }
Esempio n. 11
0
 public function affectedRows()
 {
     $res = $this->db->affectedRows();
     $this->assertError($res);
     return $res;
 }
Esempio n. 12
0
File: ifx.php Progetto: roojs/pear
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_ifx()
 {
     parent::__construct();
 }
Esempio n. 13
0
 /**
  * @see DB_common::escapeSimple
  */
 public function escapeSimple($str)
 {
     $res = $this->db->escapeSimple($str);
     $this->assertError($res);
     return $res;
 }
Esempio n. 14
0
File: DB.php Progetto: stof/pearweb
 function setOption($opt, $value)
 {
     if ($opt == 'mock') {
         $this->setMock($value);
     } else {
         parent::setOption($opt, $value);
     }
 }
Esempio n. 15
0
 /**
  * トランザクションロールバック
  * トランザクションをロールバックし、オートコミットに設定する。
  * @access public
  */
 function rollback()
 {
     $this->db->query("ROLLBACK");
     $this->db->autoCommit(true);
 }
Esempio n. 16
0
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_sqlite()
 {
     parent::__construct();
 }
Esempio n. 17
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. 18
0
 /**
  * Install schema into the database
  *
  * @param string    $filename location of database schema file
  * @param DB_common $conn     connection to database
  *
  * @return boolean - indicating success or failure
  */
 function runDbScript($filename, DB_common $conn)
 {
     $sql = trim(file_get_contents(INSTALLDIR . '/db/' . $filename));
     $stmts = explode(';', $sql);
     foreach ($stmts as $stmt) {
         $stmt = trim($stmt);
         if (!mb_strlen($stmt)) {
             continue;
         }
         try {
             $res = $conn->simpleQuery($stmt);
         } catch (Exception $e) {
             $error = $e->getMessage();
             $this->updateStatus("ERROR ({$error}) for SQL '{$stmt}'");
             return false;
         }
     }
     return true;
 }
Esempio n. 19
0
File: fbsql.php Progetto: roojs/pear
 /**
  * This constructor calls <kbd>$this->DB_common()</kbd>
  *
  * @return void
  */
 function DB_fbsql()
 {
     parent::__construct();
 }
Esempio n. 20
0
 /**
  * Displays package information for the specified package
  *
  * @param array   $package associative array containing package information.
  * @param string  $php     optional. The PHP version on which to filter.
  *                         If not specified, defaults to 'all'.
  * @param integer $count   optional. The ordinal index of the package
  *                         being displayed.
  *
  * @return null
  */
 protected function displayPackage(array $package, $php = 'all', $count = 0)
 {
     $packageClass = $count === 0 ? 'package package-first' : 'package';
     echo " <div class=\"{$packageClass}\">\n";
     echo "  <div class=\"package-info\">\n";
     // name
     $packageName = htmlspecialchars($package['name']);
     echo "   <div class=\"package-title\">\n";
     echo "    <a href=\"package/{$packageName}\">{$packageName}</a>\n";
     echo "   </div>\n";
     // summary
     $packageSummary = trim(htmlspecialchars($package['summary']));
     echo "   <div class=\"package-description\">\n";
     echo "    <p>{$packageSummary}</p>\n";
     echo "   </div>\n";
     // deprecated note
     if (!empty($package['newpk_id'])) {
         echo "   <div class=\"package-notes\">\n";
         $newPackageName = $this->dbh->getOne('SELECT name FROM packages WHERE id = ' . $this->dbh->quote($package['newpk_id'], 'text') . ' ORDER BY id DESC LIMIT 1');
         $newPackageName = htmlspecialchars($newPackageName);
         echo "    <p>This package has been deprecated in favor of " . "<a href=\"/package/{$newPackageName}\">" . $newPackageName . "</a>.</p>";
         echo "   </div>\n";
     }
     echo "  </div>\n";
     echo "  <div class=\"package-more-info\">\n";
     echo "   <table class=\"package-data\">\n";
     echo "    <tbody>\n";
     // status
     switch ($package['status']) {
         case 'stable':
             $state = '<span class="package-stable">stable</span>';
             break;
         case 'beta':
             $state = '<span class="package-beta">beta</span>';
             break;
         case 'alpha':
         default:
             $state = '<span class="package-alpha">alpha</span>';
             break;
     }
     $timestamp = strtotime($package['releasedate']);
     $packageVersion = htmlspecialchars($package['version']);
     $packageDateIso = htmlspecialchars(date('c', $timestamp));
     $packageDate = htmlspecialchars(date('Y-m-d', $timestamp));
     echo "     <tr>\n";
     echo "      <th>Status:</th>\n";
     echo "      <td>" . $packageVersion . " " . "(" . $state . ") " . "released on <abbr class=\"date\" title=\"{$packageDateIso}\">" . $packageDate . "</abbr>" . "</td>\n";
     echo "     </tr>\n";
     // license
     $packageLicense = htmlspecialchars($package['license']);
     $packageLicenseStatus = license::isGood($package['license']);
     $packageLicenseLink = license::getLink($package['license']);
     $packageLicenseClass = $packageLicenseStatus ? 'package-license-good' : 'package-license-bad';
     echo "     <tr>\n";
     echo "      <th>License:</th>\n";
     echo "      <td>";
     echo "<span class=\"{$packageLicenseClass}\">";
     if ($packageLicenseLink === null) {
         echo $packageLicense;
     } else {
         echo "<a href=\"{$packageLicenseLink}\">{$packageLicense}</a>";
     }
     echo "</span>";
     echo "</td>\n";
     echo "     </tr>\n";
     // maintained
     echo "     <tr>\n";
     echo "      <th>Maintained:</th>\n";
     echo "      <td>";
     if ($package['unmaintained'] == 0) {
         echo "Yes";
     } else {
         echo "<span class=\"package-unmaintained\">No</span>";
     }
     echo "</td>\n";
     echo "     </tr>\n";
     // bugs
     if ($package['numbugs'] == 0) {
         $packageBugs = 'none';
     } else {
         $packageBugs = $package['numbugs'];
     }
     $packageBugsLink = 'bugs/search.php?cmd=display&amp;package_name[]=' . urlencode($package['name']);
     echo "     <tr>\n";
     echo "      <th>Open Bugs:</th>\n";
     echo "      <td>";
     echo "<a href=\"{$packageBugsLink}\">{$packageBugs}</a>";
     echo "</td>\n";
     echo "     </tr>\n";
     echo "    </tbody>\n";
     echo "   </table>\n";
     echo "  </div>\n";
     echo " </div>\n";
 }