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


PHP Sql_Affected_rows函数代码示例

本文整理汇总了PHP中Sql_Affected_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP Sql_Affected_rows函数的具体用法?PHP Sql_Affected_rows怎么用?PHP Sql_Affected_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: fill

function fill($prefix, $listid)
{
    global $server_name, $tables, $table_prefix;
    # check for not too many
    $domain = getConfig('domain');
    $res = Sql_query("select count(*) from {$tables['user']}");
    $row = Sql_fetch_row($res);
    if ($row[0] > 50000) {
        error('Hmm, I think 50 thousand users is quite enough for a test<br/>This machine does need to do other things you know.');
        print '<script language="Javascript" type="text/javascript"> document.forms[0].output.value="Done. Now there are ' . $row[0] . ' users in the database";</script>' . "\n";
        return 0;
    }
    # fill the database with "users" who have any combination of attribute values
    $attributes = array();
    $res = Sql_query("select * from {$tables['attribute']} where type = \"select\" or type = \"checkbox\" or type=\"radio\"");
    $num_attributes = Sql_Affected_rows();
    $total_attr = 0;
    $total_val = 0;
    while ($row = Sql_fetch_array($res)) {
        array_push($attributes, $row['id']);
        ++$total_attr;
        $values[$row['id']] = array();
        $res2 = Sql_query("select * from {$table_prefix}" . 'listattr_' . $row['tablename']);
        while ($row2 = Sql_fetch_array($res2)) {
            array_push($values[$row['id']], $row2['id']);
            ++$total_val;
        }
    }
    $total = $total_attr * $total_val;
    if (!$total) {
        Fatal_Error('Can only do stress test when some attributes exist');
        return 0;
    }
    for ($i = 0; $i < $total; ++$i) {
        $data = array();
        reset($attributes);
        while (list($key, $val) = each($attributes)) {
            $data[$val] = current($values[$val]);
            if (!$data[$val]) {
                reset($values[$val]);
                $data[$val] = current($values[$val]);
            }
            next($values[$val]);
        }
        $query = sprintf('insert into %s (email,entered,confirmed) values("testuser%s",now(),1)', $tables['user'], $prefix . '-' . $i . '@' . $domain);
        $result = Sql_query($query, 0);
        $userid = Sql_insert_id();
        if ($userid) {
            $result = Sql_query("replace into {$tables['listuser']} (userid,listid,entered) values({$userid},{$listid},now())");
            reset($data);
            while (list($key, $val) = each($data)) {
                if ($key && $val) {
                    Sql_query("replace into {$tables['user_attribute']} (attributeid,userid,value) values(" . $key . ",{$userid}," . $val . ')');
                }
            }
        }
    }
    return 1;
}
开发者ID:gillima,项目名称:phplist3,代码行数:59,代码来源:stresstest.php

示例2: getUniqid

function getUniqid($table = "") {
  global $tables;
  if (!$table) {
  	if ($tables["user"])
	  	$table = $tables["user"];
    else
    	$table = "user";
  }
  # make sure it is really unique
  $id = md5(uniqid(mt_rand()));
  $req = Sql_Query("select id from $table where uniqid = \"$id\"");
  while (Sql_Affected_rows()) {
    $id = md5(uniqid(mt_rand()));
    $req = Sql_Query("select id from $table where uniqid = \"$id\"");
  }
  return $id;
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:17,代码来源:userlib.php

示例3: reset

    reset($_SESSION['export']['cols']);
    while (list($key, $val) = each($_SESSION['export']['cols'])) {
        fwrite($exportfile, strtr($user[$val], $col_delim, ',') . $col_delim);
    }
    reset($attributes);
    while (list($key, $val) = each($attributes)) {
        $value = UserAttributeValue($user['id'], $val['id']);
        fwrite($exportfile, quoteEnclosed($value, $col_delim, $row_delim) . $col_delim);
    }
    if ($exporthistory) {
        fwrite($exportfile, quoteEnclosed($user['ip'], $col_delim, $row_delim) . $col_delim);
        fwrite($exportfile, quoteEnclosed($user['summary'], $col_delim, $row_delim) . $col_delim);
        fwrite($exportfile, quoteEnclosed($user['detail'], $col_delim, $row_delim) . $col_delim);
    }
    $lists = Sql_query("select listid,name from\n    {$tables['listuser']},{$tables['list']} where userid = " . $user['id'] . " and\n    {$tables['listuser']}.listid = {$tables['list']}.id {$listselect_and}");
    if (!Sql_Affected_rows($lists)) {
        fwrite($exportfile, 'No Lists');
    }
    while ($list = Sql_fetch_array($lists)) {
        fwrite($exportfile, stripslashes($list['name']) . '; ');
    }
    fwrite($exportfile, $row_delim);
}
print '<script type="text/javascript">
var parentJQuery = window.parent.jQuery;
parentJQuery("#progressbar").updateProgress("' . $todo . ',' . $todo . '");
parentJQuery("#busyimage").hide();
parentJQuery("#progresscount").html("' . s('All done') . '");
</script>';
flush();
$_SESSION['export']['fileready'] = $exportfileName;
开发者ID:gillima,项目名称:phplist3,代码行数:31,代码来源:export.php

示例4: flush

 }
 flush();
 keepLock($send_process_id);
 $status = Sql_query('update ' . $tables["message"] . ' set status = "inprocess" where id = ' . $messageid);
 $sendstart = Sql_query('update ' . $tables["message"] . ' set sendstart = now() where sendstart is NULL and id = ' . $messageid);
 output($GLOBALS['I18N']->get('Looking for users'));
 if (Sql_Has_Error($database_connection)) {
     ProcessError(Sql_Error($database_connection));
 }
 # make selection on attribute, users who at least apply to the attributes
 # lots of ppl seem to use it as a normal mailinglist system, and do not use attributes.
 # Check this and take anyone in that case.
 $numattr = Sql_Fetch_Row_Query("select count(*) from " . $tables["attribute"]);
 if ($userselection && $numattr[0]) {
     $res = Sql_query($userselection);
     $num_users = Sql_Affected_rows($res);
     output($num_users . ' ' . $GLOBALS['I18N']->get('users apply for attributes, now checking lists'));
     $user_list = "";
     while ($row = Sql_Fetch_row($res)) {
         $user_list .= $row[0] . ",";
     }
     $user_list = substr($user_list, 0, -1);
     if ($user_list) {
         $user_attribute_query = " and listuser.userid in ({$user_list})";
     } else {
         output($GLOBALS['I18N']->get('No users apply for attributes'));
         $status = Sql_query("update {$tables["message"]} set status = \"sent\",sent = now() where id = \"{$messageid}\"");
         finish("info", "Message {$messageid}: \nNo users apply for attributes, ie nothing to do");
         $script_stage = 6;
         # we should actually continue with the next message
         return;
开发者ID:alancohen,项目名称:alancohenexperience-com,代码行数:31,代码来源:processqueue.php

示例5: Sql_Query

             $msg = $cnt . ' ' . $GLOBALS['I18N']->get("users were deleted from this list");
             break;
         default:
             # do nothing
             break;
     }
 }
 if ($_POST["tagaction_all"] != "nothing") {
     $req = Sql_Query(sprintf('select userid from %s where listid = %d', $tables["listuser"], $id));
     switch ($_POST["tagaction_all"]) {
         case "move":
             $cnt = 0;
             while ($user = Sql_Fetch_Row($req)) {
                 Sql_query("delete from {$tables["listuser"]} where listid = {$id} and userid =\n            {$user['0']}");
                 Sql_query("replace into {$tables["listuser"]} (listid,userid)\n            values({$_POST["movedestination_all"]},{$user['0']})");
                 if (Sql_Affected_rows() == 1) {
                     # 2 means they were already on the list
                     $cnt++;
                 }
             }
             $msg = $cnt . ' ' . $GLOBALS['I18N']->get("users were moved to") . ' ' . listName($_POST["movedestination_all"]);
             break;
         case "copy":
             $cnt = 0;
             while ($user = Sql_Fetch_Row($req)) {
                 Sql_query("replace into {$tables["listuser"]} (listid,userid)\n            values({$_POST["copydestination_all"]},{$user['0']})");
                 $cnt++;
             }
             $msg = $cnt . ' ' . $GLOBALS['I18N']->get("users were copied to") . ' ' . listName($_POST["copydestination_all"]);
             break;
         case "delete":
开发者ID:radicaldesigns,项目名称:amp,代码行数:31,代码来源:members.php

示例6: flush

  }

  flush();
  keepLock($send_process_id);
  $status = Sql_query('update '.$tables["message"].' set status = "inprocess",sendstart = now() where id = '.$messageid);
  output( "Looking for users");
  if (Sql_Has_Error($database_connection)) {  ProcessError(Sql_Error($database_connection)); }

  # make selection on attribute, users who at least apply to the attributes
  # lots of ppl seem to use it as a normal mailinglist system, and do not use attributes.
  # Check this and take anyone in that case.
  $numattr = Sql_Fetch_Row_Query("select count(*) from ".$tables["attribute"]);

  if ($userselection && $numattr[0]) {
    $res = Sql_query($userselection);
    $num = Sql_Affected_rows($res);
    output("$num users apply for attributes, now checking lists");
    $user_list = "";
    while ($row = Sql_Fetch_row($res)) {
      $user_list .= $row[0] . ",";
    }
    $user_list = substr($user_list,0,-1);
    if ($user_list)
      $user_attribute_query = " and ".$tables["listuser"].".userid in ($user_list)";
    else {
      output("No users apply for attributes");
      $status = Sql_query("update {$tables["message"]} set status = \"sent\",sent = now() where id = \"$messageid\"");
      finish("info","Message $messageid: \nNo users apply for attributes, ie nothing to do");
      $script_stage = 6;
      return;
    }
开发者ID:radicaldesigns,项目名称:amp,代码行数:31,代码来源:processqueue.php

示例7: Sql_Query

			default: # do nothing
				break;
		}
	}

	if ($tagaction_all != "nothing") {
		$req = Sql_Query(sprintf('select userid from %s where listid = %d',$tables["listuser"],$id));
		switch ($tagaction_all) {
			case "move":
				$cnt = 0;
				while ($user = Sql_Fetch_Row($req)) {
					Sql_query("delete from {$tables["listuser"]} where listid = $id and userid =
						$user[0]");
					Sql_query("replace into {$tables["listuser"]} (listid,userid)
						values($movedestination_all,$user[0])");
					if (Sql_Affected_rows() == 1) # 2 means they were already on the list
						$cnt++;
				}
				$msg = $cnt . ' users were moved to '.listName($movedestination_all);
				break;
			case "copy":
				$cnt = 0;
				while ($user = Sql_Fetch_Row($req)) {
					Sql_query("replace into {$tables["listuser"]} (listid,userid)
						values($copydestination_all,$user[0])");
					$cnt++;
				}
				$msg = $cnt .' users were copied to '.listName($copydestination_all);
				break;
			case "delete":
				Sql_Query(sprintf('delete from %s where listid = %d',$tables["listuser"],$id));
开发者ID:radicaldesigns,项目名称:amp,代码行数:31,代码来源:members.php

示例8: fill

function fill($prefix,$listid) {
  global $server_name,$tables,$table_prefix;
  # check for not too many
  $domain = getConfig("domain");
  $res = Sql_query("select count(*) from $tables[user]");
  $row = Sql_fetch_row($res);
  if ($row[0] > 50000) {
    error("Hmm, I think 50 thousand users is quite enough for a test<br>This machine does need to do other things you know.");
    print '<script language="Javascript" type="text/javascript">finish();</script>';
    print '<script language="Javascript" type="text/javascript"> document.forms[0].output.value="Done. Now there are '.$row[0].' users in the database";</script>'."\n";
    return 0;
  }

  # fill the database with "users" who have any combination of attribute values
  $attributes = array();
  $res = Sql_query("select * from $tables[attribute] where type = \"select\" or type = \"checkbox\" or type=\"radio\"");
  $num_attributes = Sql_Affected_rows();
  $total_attr = 0;
  $total_val = 0;

  while ($row = Sql_fetch_array($res)) {
    array_push($attributes,$row["id"]);
    $total_attr++;
    $values[$row["id"]] = array();
    $res2 = Sql_query("select * from $table_prefix"."listattr_".$row["tablename"]);
    while ($row2 = Sql_fetch_array($res2)) {
      array_push($values[$row["id"]],$row2["id"]);
      $total_val++;
    }
  }
  $total = $total_attr * $total_val;
  if (!$total) {
    print '<script language="Javascript" type="text/javascript"> finish(); </script>';
    Fatal_Error("Can only do stress test when some attributes exist");
		return 0;
  }

  for ($i = 0;$i< $total;$i++) {
    $data = array();
    reset($attributes);
    while (list($key,$val) = each ($attributes)) {
      $data[$val] = pos($values[$val]);
      if (!$data[$val]) {
        reset($values[$val]);
        $data[$val] = pos($values[$val]);
      }
      next($values[$val]);
    }

    $query = sprintf('insert into %s (email,entered,confirmed) values("testuser%s",now(),1)',
			$tables["user"], $prefix . '-' . $i . '@' . $domain);
    $result = Sql_query($query,0);

    $userid = Sql_insert_id();
		if ($userid) {
			$result = Sql_query("replace into $tables[listuser] (userid,listid,entered) values($userid,$listid,now())");
			reset($data);
			while (list($key,$val) = each ($data))
				if ($key && $val)
					Sql_query("replace into $tables[user_attribute] (attributeid,userid,value) values(".$key.",$userid,".$val.")");
		}
  }
  return 1;
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:64,代码来源:stresstest.php


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