当前位置: 首页>>代码示例>>PHP>>正文


PHP Dal::validate_sql方法代码示例

本文整理汇总了PHP中Dal::validate_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Dal::validate_sql方法的具体用法?PHP Dal::validate_sql怎么用?PHP Dal::validate_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dal的用法示例。


在下文中一共展示了Dal::validate_sql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute_multiple

 public static function execute_multiple($sql, $args = array(NULL))
 {
     global $query_count_on_page;
     $db = Dal::get_connection();
     $sql = Dal::validate_sql($sql);
     $prh = $db->prepare($sql);
     if (PEAR::isError($prh)) {
         Logger::log(" Throwing exception DB_QUERY_FAILED while preparing a query for multiple execution | Message: " . $prh->getMessage() . " | SQL that caused this exception: " . $sql, LOGGER_ERROR);
         throw new PAException(DB_QUERY_FAILED, $prh->getMessage());
     }
     foreach ($args as $params) {
         Dal::execute_pre_hooks($sql, $params);
         $sth = $db->execute($prh, $params);
         Dal::execute_post_hooks($sql, $params);
         if (PEAR::isError($sth)) {
             Logger::log(" Throwing exception DB_QUERY_FAILED while in multiple query execution | Message: " . $sth->getMessage() . " | SQL that caused this exception: " . $sql, LOGGER_ERROR);
             throw new PAException(DB_QUERY_FAILED, $sth->getMessage());
         }
         $query_count_on_page++;
     }
     $db->freePrepared($prh);
     return TRUE;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:23,代码来源:Dal.php

示例2: migrateLegacyFiles

 public function migrateLegacyFiles($dry_run = TRUE)
 {
     $this->dry_run = $dry_run;
     require_once PA::$path . "/db/Dal/DbUpdate.php";
     echo "Migrating legacy files to new storage system\n";
     $this->all_files = array();
     if (!($h = opendir(PA::$path . '/web/files'))) {
         throw new PAException(GENERAL_SOME_ERROR, "Unable to open web/files directory");
     }
     while (false !== ($f = readdir($h))) {
         if ($f[0] == '.') {
             continue;
         }
         $this->all_files[$f] = TRUE;
     }
     closedir($h);
     $this->unmatched = count($this->all_files);
     $this->unmatchable = 0;
     $this->matched = 0;
     $this->dupes = 0;
     echo "{$this->unmatched} files found\n";
     echo "Matching with user images ...\n";
     $sql = Dal::validate_sql("SELECT user_id,picture FROM {users}", $network);
     $sth = Dal::query($sql);
     while ($r = Dal::row($sth)) {
         list($uid, $pic) = $r;
         // user avatar
         $this->_matchLegacyFile($pic, array("role" => "avatar", "user" => $uid));
         //TODO: user header image
     }
     $this->_dumpMatchResults();
     $networks = DbUpdate::get_valid_networks();
     echo "Processing " . count($networks) . " networks\n";
     foreach ($networks as $network) {
         echo " Network: {$network}\n";
         // network level stuff
         list($network_id, $act, $logo, $extra) = Dal::query_one("SELECT network_id, is_active, inner_logo_image, extra FROM networks WHERE address=?", array($network));
         assert($act);
         // sanity check
         $extra = unserialize($extra);
         // network avatar
         $this->_matchLegacyFile($logo, array("role" => "avatar", "network" => $network_id));
         // network header image
         $header_image = @$extra["basic"]["header_image"]["name"];
         if (!empty($header_image)) {
             $this->_matchLegacyFile($header_image, array("role" => "header", "network" => $network_id));
         }
         // emblems
         foreach (unserialize(Dal::query_first(Dal::validate_sql("SELECT data FROM {moduledata} WHERE modulename='LogoModule'"))) as $emblem) {
             $this->_matchLegacyFile($emblem["file_name"], array("role" => "emblem", "network" => $network_id));
         }
         // group pictures
         $sth = Dal::query(Dal::validate_sql("SELECT collection_id, picture FROM {contentcollections} WHERE type=1 AND is_active=1", $network));
         while ($r = Dal::row($sth)) {
             list($cid, $pic) = $r;
             $this->_matchLegacyFile($pic, array("role" => "avatar", "network" => $network_id, "group" => $cid));
             $header = Dal::query_first(Dal::validate_sql("SELECT header_image FROM groups WHERE group_id=?", $network), array($cid));
             $this->_matchLegacyFile($header, array("role" => "header", "network" => $network_id, "group" => $cid));
         }
         /* disabled until we update peopleaggregator.net
         	    $sth = Dal::query(Dal::validate_sql("SELECT group_id, header_image FROM {groups}", $network));
         	    while ($r = Dal::row($sth)) {
         		list ($gid, $pic) = $r;
         		$this->_matchLegacyFile($network, "group", $gid, $pic);
         	    }
         	    */
         //TODO: advertisements
         // images, audio, video
         foreach (array("image", "audio", "video") as $table) {
             $sth = Dal::query(Dal::validate_sql('SELECT mc.content_id, mc.' . $table . '_file, c.author_id, c.collection_id, c.is_active FROM {' . $table . 's} mc LEFT JOIN {contents} c ON mc.content_id=c.content_id HAVING c.is_active=1', $network));
             while ($r = Dal::row($sth)) {
                 list($cid, $fn, $uid, $ccid, $act) = $r;
                 $this->_matchLegacyFile($fn, array("role" => "media", "network" => $network_id, "content" => $cid));
             }
         }
     }
     $this->_dumpMatchResults();
     foreach ($this->all_files as $fn => $v) {
         if ($v === TRUE) {
             echo " * unmatchable: {$fn}\n";
         }
     }
     echo "Overall results from web/files: ";
     $this->_dumpMatchResults();
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:85,代码来源:Storage.php

示例3: qup_all_networks

  function qup_all_networks($k, $sql_stmts) {
    if (!is_array($sql_stmts)) $sql_stmts = array($sql_stmts);
    if (!$this->quiet) { $this->note("Applying '$k' update to all networks ..."); }
    foreach ($sql_stmts as $sql) {
      if (!is_callable($sql) && (strpos($sql, "{") === FALSE)) {
        die("ERROR: SQL '$sql' is to be applied to all networks, but contains no {bracketed} table names!");
      }
    }
    //    $sth = Dal::query("SELECT address FROM networks WHERE is_active=1");
    $seen_default = FALSE;
    //    while (list($network_address) = Dal::row($sth)) {
    //    var_dump($this->networks);
    global $network_prefix;
    $prev_network_prefix = $network_prefix;
    $nets_done = $nets_updated = 0; $nets_total = count($this->networks);
    $last_prefix = ""; // to work out spacing
    foreach ($this->networks as $network_prefix) {
      set_time_limit(30);
      ++ $nets_done;
      if ($network_prefix == 'default') {
	$network_prefix = ''; // default network has network=='' in mc_db_status table
	$seen_default = TRUE;
      }

      if ($this->is_applied($k, $network_prefix)) continue;
      if (!$this->quiet) {
	if ($this->running_on_cli) {
	  echo "\r";
	  $len_diff = strlen($last_prefix) - strlen($network_prefix);
	  $spacing = ($len_diff > 0) ? str_repeat(" ", $len_diff) : "";
	} else {
	  $spacing = "";
	}
	$this->write("* $nets_done/$nets_total [$network_prefix]$spacing", FALSE);
      }
      foreach ($sql_stmts as $sql) {
        if (is_callable($sql)) {
          $sql();
        } else {
          $new_sql = Dal::validate_sql($sql, $network_prefix);
          Dal::query($new_sql);
        }
      }
      Dal::query("INSERT INTO mc_db_status SET stmt_key=?, network=?", Array($k, $network_prefix));
      ++ $nets_updated;
      $last_prefix = $network_prefix;
    }
    $network_prefix = $prev_network_prefix;
    if (!$seen_default && $this->full_update) {
      $this->write("WARNING: applied change '$k' to all known networks, but the default network doesn't have an entry in the 'networks' table.  This means net_extra.php hasn't been run; something has gone wrong with the upgrade.");
    }
    if (!$this->quiet && $this->running_on_cli && $nets_updated) echo "\n";
  }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:53,代码来源:db_update.php


注:本文中的Dal::validate_sql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。