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


PHP mysql_affected_rows函数代码示例

本文整理汇总了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;
     }
 }
开发者ID:kingsj,项目名称:zeuscart,代码行数:38,代码来源:Query.php

示例2: getAffectedRows

 public function getAffectedRows()
 {
     if (!$this->_affected_rows) {
         $this->_affected_rows = mysql_affected_rows($this->_link);
     }
     return $this->_affected_rows;
 }
开发者ID:kstep,项目名称:pnut,代码行数:7,代码来源:Mysql.php

示例3: sql_command

function sql_command($sql)
{
    if (mysql_query($sql)) {
        return mysql_affected_rows();
    }
    return -1;
}
开发者ID:rtsfc,项目名称:moodle-block_mrbs,代码行数:7,代码来源:mysql.php

示例4: SqlExecOrDie

function SqlExecOrDie($con, $sql)
{
    if (!mysql_query($sql, $con)) {
        die("Invalid query: " . mysql_error($con) . "\n{$sql}");
    }
    return mysql_affected_rows($con);
}
开发者ID:ctcit,项目名称:mailchimp,代码行数:7,代码来源:alastair.php

示例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}");
}
开发者ID:martinkirov,项目名称:intersango,代码行数:26,代码来源:order_utils.php

示例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>";
            }
        }
    }
}
开发者ID:saeed81,项目名称:data_portal_project,代码行数:34,代码来源:configmsgbrd.php

示例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;
}
开发者ID:kumarkvk,项目名称:kumar_shifts,代码行数:7,代码来源:disconnect.php

示例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>";
    }
}
开发者ID:halimc17,项目名称:magsys,代码行数:30,代码来源:sdm_slave_simpan_photo_karyawan.php

示例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;
    }
开发者ID:871263000,项目名称:zdl,代码行数:31,代码来源:lt.php

示例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;
    }
}
开发者ID:nevun,项目名称:feed-on-feeds,代码行数:29,代码来源:fof-db.php

示例11: countAffectedRows

 public function countAffectedRows()
 {
     if (!($rows = mysql_affected_rows($this->mysql->conId))) {
         throw new Exception('Error counting affected rows');
     }
     return $rows;
 }
开发者ID:garethcmurphy,项目名称:plasmadatabase,代码行数:7,代码来源:mysql.php

示例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&amp;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();
}
开发者ID:CharlieHD,项目名称:U-232-V2,代码行数:31,代码来源:polls_manager.php

示例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;
        }
    }
}
开发者ID:sakti,项目名称:andes,代码行数:31,代码来源:pegawai.php

示例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;
}
开发者ID:mozdial,项目名称:Directory,代码行数:39,代码来源:functions.database.inc.php

示例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;
 }
开发者ID:shihminciou,项目名称:MessageBoard,代码行数:7,代码来源:sql_class.php


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