本文整理汇总了PHP中mysql_affected_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_affected_rows函数的具体用法?PHP mysql_affected_rows怎么用?PHP mysql_affected_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_affected_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeQuery
/**
* Enter description here...
*
* @param string $sql
* @param array $fields
* @return boolean
*/
function executeQuery($sql, $fields = array())
{
//if(substr_count($sql,'#')!=count($fields))
//return false;
if (count($fields) > 0) {
$sql = $this->makeQuery($sql, $fields);
}
// Security::makeQuery();
$i = 0;
$this->rs = mysql_query($sql);
$this->sql = $sql;
$this->insertid = mysql_insert_id();
if (is_resource($this->rs)) {
$this->totrows = mysql_num_rows($this->rs);
}
if (!mysql_affected_rows() || $this->totrows < 1) {
return false;
} else {
while ($fetch = mysql_fetch_array($this->rs)) {
$this->records[$i++] = $fetch;
}
for ($i = 0; $i < count($this->records); $i++) {
foreach ($this->records[$i] as $key => $item) {
if (is_numeric($key)) {
unset($this->records[$i][$key]);
}
}
}
return true;
}
}
示例2: getAffectedRows
public function getAffectedRows()
{
if (!$this->_affected_rows) {
$this->_affected_rows = mysql_affected_rows($this->_link);
}
return $this->_affected_rows;
}
示例3: sql_command
function sql_command($sql)
{
if (mysql_query($sql)) {
return mysql_affected_rows();
}
return -1;
}
示例4: SqlExecOrDie
function SqlExecOrDie($con, $sql)
{
if (!mysql_query($sql, $con)) {
die("Invalid query: " . mysql_error($con) . "\n{$sql}");
}
return mysql_affected_rows($con);
}
示例5: cancel_order
function cancel_order($orderid, $uid)
{
// cancel an order
$query = "\n UPDATE orderbook\n SET status='CANCEL'\n WHERE\n orderid='{$orderid}'\n AND uid='{$uid}'\n AND status='OPEN'\n ";
do_query($query);
if (mysql_affected_rows() != 1) {
if (mysql_affected_rows() > 1) {
throw new Error('Serious...', 'More rows updated than should be. Contact the sysadmin ASAP.');
} else {
if (mysql_affected_rows() == 0) {
throw new Problem(_('Cannot...'), _('Your order got bought up before you were able to cancel.'));
} else {
throw new Error('Serious...', 'Internal error. Contact sysadmin ASAP.');
}
}
}
// Refetch order in case something has happened.
$info = fetch_order_info($orderid);
if ($uid != $info->uid) {
throw new Error('Permission...', '... Denied! Now GTFO.');
}
add_funds($info->uid, $info->amount, $info->type);
// these records indicate returned funds.
create_record($orderid, $info->amount, 0, 0, -1, 0);
addlog(LOG_RESULT, " cancelled order {$orderid}");
}
示例6: retrieve_messages
function retrieve_messages()
{
global $dbc;
$query = "select m.subject, m.message_txt, u.username, m.date, m.parent_id, m.user_id, m.mess_block, m.topic_id, m.user_id from message AS m, users AS u where (m.user_id = u.user_id) order by m.mess_block, m.date;";
$result = mysql_query($query) or trigger_error("An Error Happened");
if (mysql_affected_rows() > 0) {
$tagSwitch = FALSE;
while ($messages = mysql_fetch_array($result, MYSQLI_ASSOC)) {
if ($messages['parent_id'] == 0) {
$tagSwitch ? print '</div>' : (print '<div class="commentBox">');
$tagSwitch = !$tagSwitch;
echo "<p><h3>{$messages['subject']}</h3></p>";
echo "<p>{$messages['message_txt']}</p>";
echo "<br />via: {$messages['username']} <a href='#' class='getComments'>Comments</a><hr />";
echo "<div class='comments'>";
echo "<form id='theForm'>";
echo "<textarea name='comment' class='comment' cols=60 rows=10>Enter Comment...</textarea><br />";
echo "<input type=hidden name='username' value={$messages['username']}>";
echo "<input type=hidden name='subject' value={$messages['subject']}>";
echo "<input type=hidden name='parent_id' value=1>";
echo "<input type=hidden name='mess_block' value={$messages['mess_block']}>";
echo "<input type=hidden name='token_id' value={$_SESSION['token_id']}>";
echo "<input type=hidden name='topic_id' value={$messages['topic_id']}>";
echo "<input type=hidden name='user_id' value={$messages['user_id']}>";
echo "<button type='button' id='oneButton'>Post Comment</button></form></div>";
} else {
echo "<div class='comments'>";
echo "{$messages['message_txt']}<br />";
echo "via: {$messages['username']}<br /><hr />";
echo "</div>";
}
}
}
}
示例7: mysql_modified_rows
function mysql_modified_rows($conn)
{
$info_str = mysql_info($conn);
$a_rows = mysql_affected_rows();
ereg("Rows matched: ([0-9]*)", $info_str, $r_matched);
return $a_rows < 1 ? $r_matched[1] ? $r_matched[1] : 0 : $a_rows;
}
示例8: writeFile
function writeFile($path)
{
global $karyawanid;
global $conn;
global $dbname;
$dir = $path;
$ext = split('[.]', basename($_FILES['photo']['name']));
$ext = $ext[count($ext) - 1];
$ext = strtolower($ext);
if ($ext == 'jpg' or $ext == 'jpeg' or $ext == 'gif' or $ext == 'png' or $ext == 'bmp') {
$path = $dir . "/" . $karyawanid . "." . $ext;
//remove if exist;
//write to a file
try {
if (move_uploaded_file($_FILES['photo']['tmp_name'], $path)) {
$str = "update " . $dbname . ".datakaryawan set photo='" . $path . "'\r\n\t\t\t\t where karyawanid=" . $karyawanid;
mysql_query($str);
//echo mysql_error($conn);
if (mysql_affected_rows($conn) > 0) {
echo "<script>\r\n\t\t\t\t\tparent.document.getElementById('displayphoto').removeAttribute('src');\r\n\t\t\t\t\tparent.document.getElementById('displayphoto').setAttribute('src','" . $path . "');\r\n\t\t\t\t\t//parent.document.getElementById('displayphoto').getAttribute('src').value;\r\n\t\t\t\t\t</script>";
}
chmod($path, 0775);
}
} catch (Exception $e) {
echo "<script>alert(\"Error Writing File" . addslashes($e->getMessage()) . "\");</script>";
}
} else {
echo "<script>alert('Filetype not support');</script>";
}
}
示例9: getdata
function getdata($id = 0)
{
global $str;
$res = mysql_query('select id,zwname,pid,path,`desc` from ' . $this->table . ' where pid=' . $id . ' and state=0 ');
if ($res && mysql_affected_rows()) {
$str .= '<ul class="lu" >';
while ($row = mysql_fetch_array($res)) {
if ($row['pid'] == 0 && $row['path'] == 0) {
$this->person[$row['zwname']][] = $this->getOT($row['zwname']);
}
$sql = 'select * from ' . $this->table . ' where path="' . ($row['path'] . ',' . $row['id'] . '"');
if (mysql_num_rows(mysql_query($sql))) {
$this->dep[] = $row;
$str .= <<<cd
\t\t\t\t\t<li class='afl' onclick="listu(this)" ondblclick="chat({$row['zwname']})" path="{$row['path']}" desc="{$row['desc']}" myinner="{$row['zwname']}" sid="{$row['id']}" onmousedown="fun(this)"><input class="ltclasscheckbox" type="checkbox">{$row['zwname']} <span style="display:none" class="btns"><button class="select_daily_list" depname="{$row['zwname']}">查看报表</button><button class="input_daily_job" depname="{$row['zwname']}">日常工作</button></span></li>
cd;
$this->getdata($row['id']);
} else {
$str .= <<<cd
\t\t\t\t\t<li class='afl' onclick="listu(this)" ondblclick="chat({$row['zwname']})" path="{$row['path']}" desc="{$row['desc']}" myinner="{$row['zwname']}" sid="{$row['id']}" onmousedown="fun(this)"><input class="ltclasscheckbox" type="checkbox">{$row['zwname']} </li>
cd;
}
}
$str .= '</ul>';
}
$result = array();
$result['tree'] = $str;
$result['dep'] = $this->dep;
$result['person'] = $this->person;
return $result;
}
示例10: fof_db_query
function fof_db_query($sql, $live = 0)
{
global $fof_connection;
list($usec, $sec) = explode(" ", microtime());
$t1 = (double) $sec + (double) $usec;
$result = mysql_query($sql, $fof_connection);
if (is_resource($result)) {
$num = mysql_num_rows($result);
}
if ($result) {
$affected = mysql_affected_rows();
}
list($usec, $sec) = explode(" ", microtime());
$t2 = (double) $sec + (double) $usec;
$elapsed = $t2 - $t1;
$logmessage = sprintf("%.3f: [%s] (%d / %d)", $elapsed, $sql, $num, $affected);
fof_log($logmessage, "query");
if ($live) {
return $result;
} else {
if (mysql_errno()) {
//echo "<pre>";
//print_r(debug_backtrace());
//echo "</pre>";
die("Cannot query database. Have you run <a href=\"install.php\"><code>install.php</code></a> to create or upgrade your installation? MySQL says: <b>" . mysql_error() . "</b>");
}
return $result;
}
}
示例11: countAffectedRows
public function countAffectedRows()
{
if (!($rows = mysql_affected_rows($this->mysql->conId))) {
throw new Exception('Error counting affected rows');
}
return $rows;
}
示例12: update_poll
function update_poll()
{
global $INSTALLER09, $CURUSER, $mc1;
$total_votes = 0;
if (!isset($_POST['pid']) or !is_valid_id($_POST['pid'])) {
stderr('USER ERROR', 'There is no poll with that ID!');
}
$pid = intval($_POST['pid']);
if (!isset($_POST['poll_question']) or empty($_POST['poll_question'])) {
stderr('USER ERROR', 'There is no title defined!');
}
$poll_title = sqlesc(htmlspecialchars(strip_tags($_POST['poll_question']), ENT_QUOTES));
//get the main crux of the poll data
$poll_data = makepoll();
$total_votes = isset($poll_data['total_votes']) ? intval($poll_data['total_votes']) : 0;
unset($poll_data['total_votes']);
if (!is_array($poll_data) or !count($poll_data)) {
stderr('SYSTEM ERROR', 'There was no data sent');
}
//all ok, serialize
$poll_data = sqlesc(serialize($poll_data));
$username = sqlesc($CURUSER['username']);
@sql_query("UPDATE polls SET choices={$poll_data}, starter_id={$CURUSER['id']}, starter_name={$username}, votes={$total_votes}, poll_question={$poll_title} WHERE pid={$pid}") or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('poll_data_' . $CURUSER['id']);
if (-1 == mysql_affected_rows()) {
$msg = "<h2>An Error Occured!</h2>\r\n <a href='javascript:history.back()' title='Go back and fix the error' style='color:green;font-weight:bold'><span class='btn' style='padding:3px;'><img style='vertical-align:middle;' src='{$INSTALLER09['pic_base_url']}/polls/p_delete.gif' alt='Go Back' />Go Back</span></a>";
} else {
$msg = "<h2>Groovy, everything went hunky dory!</h2>\r\n <a href='staffpanel.php?tool=polls_manager&action=polls_manager' title='Return to Polls Manager' style='color:green;font-weight:bold'><span class='btn' style='padding:3px;'><img style='vertical-align:middle;' src='{$INSTALLER09['pic_base_url']}/polls/p_tick.gif' alt='Success' />Success</span></a>";
}
echo stdhead('Poll Manager::Add New Poll') . $msg . stdfoot();
}
示例13: pg_editPegawai
function pg_editPegawai($id, $nama, $jk, $tgllhr, $jabatan, $notelp, $idkc, $password, $idrutepeg)
{
if (!empty($password)) {
$query = sprintf("UPDATE pegawai SET nama='%s',jk='%s',tgllahir='%s',jabatan='%s',notelp='%s',idkantorcabang='%s',password='%s' WHERE id='%s'", mysql_real_escape_string($nama), mysql_real_escape_string($jk), mysql_real_escape_string($tgllhr), mysql_real_escape_string($jabatan), mysql_real_escape_string($notelp), mysql_real_escape_string($idkc), md5(mysql_real_escape_string($password)), mysql_real_escape_string($id));
} else {
$query = sprintf("UPDATE pegawai SET nama='%s',jk='%s',tgllahir='%s',jabatan='%s',notelp='%s',idkantorcabang='%s' WHERE id='%s'", mysql_real_escape_string($nama), mysql_real_escape_string($jk), mysql_real_escape_string($tgllhr), mysql_real_escape_string($jabatan), mysql_real_escape_string($notelp), mysql_real_escape_string($idkc), mysql_real_escape_string($id));
}
$result = mysql_query($query);
if (!$result) {
return false;
} else {
if ($jabatan == 'peg. pengiriman') {
$query = sprintf("UPDATE detailpegpengiriman SET idrute='%s' WHERE id='%s'", mysql_real_escape_string($idrutepeg), mysql_real_escape_string($id));
$result = mysql_query($query);
$jml = mysql_affected_rows($GLOBALS["link"]);
if (!$result) {
return false;
}
if ($jml == 0) {
$query = sprintf("INSERT INTO detailpegpengiriman values('%s',%s,NULL)", mysql_real_escape_string($id), mysql_real_escape_string($idrutepeg));
$result = mysql_query($query);
if (!$result && mysql_errno() != 1062) {
return false;
}
}
return true;
} else {
return true;
}
}
}
示例14: database_void_query
/**
* Database void query
* @param $sql
* @param $debug
* @param $zero_affected
*/
function database_void_query($sql, $debug = false, $zero_affected = true)
{
$result = mysql_query($sql);
if ($debug == true) {
echo $sql . ' - ' . mysql_error();
}
$affected_rows = mysql_affected_rows();
if (preg_match('/update /i', $sql)) {
if ($zero_affected && $affected_rows >= 0) {
return true;
}
if (!$zero_affected && $affected_rows > 0) {
return true;
}
} else {
if (preg_match('/drop t/i', $sql)) {
if ($affected_rows >= 0) {
return true;
}
} else {
if (preg_match('/create t/i', $sql)) {
if ($affected_rows >= 0) {
return true;
}
} else {
if ($affected_rows > 0) {
return true;
}
}
}
}
return false;
}
示例15: update
function update($sql)
{
$result = $this->execute($sql, $dbbase);
$this->affected_rows = mysql_affected_rows($this->dbLink);
$this->free_result($result);
return $this->affected_rows;
}