• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mysqli_stmt_affected_rows函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleEditPage

function handleEditPage()
{
    include_once 'login.php';
    include_once 'showEventFunction.php';
    $backURL = "<br/><a href = \"index.php\">Back to Home</a>";
    // client side validation, if error, disable submit
    // if form is set and not empty, continue
    $showError = true;
    $errOutput = isFormFilled($showError);
    if ($errOutput) {
        $output = "<h1>Error</h1>";
        return $output . $errOutput . $backURL;
    }
    $event = array();
    $errMsg = array();
    // prevent sql injection & data sanitize
    foreach ($_POST as $field => $value) {
        $event[$field] = sanitizeData($value);
    }
    include_once 'database_conn.php';
    $columnLengthSql = "\n\t\tSELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH\n\t\tFROM INFORMATION_SCHEMA.COLUMNS\n\t\tWHERE TABLE_NAME =  'te_events'\n\t\tAND (column_name =  'eventTitle'\n\t\tOR column_name =  'eventDescription')";
    //, DATA_TYPE
    $COLUMN_LENGTH = getColumnLength($conn, $columnLengthSql);
    // check data type and length validation
    $isError = false;
    $errMsg[] = validateStringLength($event['title'], $COLUMN_LENGTH['eventTitle']);
    //title
    $errMsg[] = validateStringLength($event['desc'], $COLUMN_LENGTH['eventDescription']);
    //desc
    $errMsg[] = validateDate($event['startTime']);
    //startTime
    $errMsg[] = validateDate($event['endTime']);
    //endTime
    $errMsg[] = validateDecimal($event['price']);
    //price
    for ($i = 0; $i < count($errMsg); $i++) {
        if (!($errMsg[$i] === true)) {
            $pageHeader = "Error";
            $output = "<h1>{$pageHeader}</h1>";
            $output . "{$errMsg[$i]}";
            $isError = true;
        }
    }
    //if contain error, halt continue executing the code
    if ($isError) {
        return $output . $backURL;
    }
    // prepare sql statement
    $sql = "UPDATE te_events SET \n\t\teventTitle=?, eventDescription=?, \n\t\tvenueID=?, catID=?, eventStartDate=?, \n\t\teventEndDate=?, eventPrice=? WHERE eventID=?;";
    $stmt = mysqli_prepare($conn, $sql);
    mysqli_stmt_bind_param($stmt, "ssssssss", $event['title'], $event['desc'], $event['venue'], $event['category'], $event['startTime'], $event['endTime'], $event['price'], $event['e_id']);
    // execute update statement
    mysqli_stmt_execute($stmt);
    // check is it sucess update
    if (mysqli_stmt_affected_rows($stmt)) {
        $output = "<h1>{$event['title']} was successfully updated.</h1>";
        return $output . $backURL;
    } else {
        $output = "<h1>Nothing update for {$event['title']}</h1>";
        return $output . $backURL;
    }
    echo "<br/>";
    return;
}
开发者ID:lowjiayou,项目名称:YearTwoWebOne,代码行数:64,代码来源:handleEditPage.php


示例2: affectedRows

 public function affectedRows()
 {
     return \mysqli_stmt_affected_rows($this->res);
 }
开发者ID:webcraftmedia,项目名称:system,代码行数:4,代码来源:ResultMysqliPrepare.php


示例3: add_one

 function add_one($data_add)
 {
     $query = "INSERT INTO `{$this->_table}` SET `author` = ?";
     $stmt = mysqli_prepare($this->_c, $query);
     if ($stmt) {
         mysqli_stmt_bind_param($stmt, 's', $data_add);
         mysqli_stmt_execute($stmt);
     }
     return printf("Rows inserted: %d\n", mysqli_stmt_affected_rows($stmt));
 }
开发者ID:alenija,项目名称:custom,代码行数:10,代码来源:authors.php


示例4: mysqli_update

function mysqli_update($db, string $sql, ...$params) : int
{
    $stmt = mysqli_interpolate($db, $sql, ...$params);
    if (!mysqli_stmt_execute($stmt)) {
        throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
    }
    $affected = mysqli_stmt_affected_rows($stmt);
    mysqli_stmt_close($stmt);
    return $affected;
}
开发者ID:noodlehaus,项目名称:mysqli_etc,代码行数:10,代码来源:mysqli_etc.php


示例5: mysqli_update

function mysqli_update($db, $sql)
{
    $stmt = call_user_func_array('mysqli_interpolate', func_get_args());
    if (!mysqli_stmt_execute($stmt)) {
        throw new mysqli_sql_exception(mysqli_stmt_error($stmt), mysqli_stmt_errno($stmt));
    }
    $affected = mysqli_stmt_affected_rows($stmt);
    mysqli_stmt_close($stmt);
    return (int) $affected;
}
开发者ID:s-melnikov,项目名称:booking,代码行数:10,代码来源:functions.php


示例6: model_delete

function model_delete($id)
{
    global $l;
    $query = 'DELETE FROM areinman__kaubad WHERE Id=? LIMIT 1';
    $stmt = mysqli_prepare($l, $query);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $deleted = mysqli_stmt_affected_rows($stmt);
    mysqli_stmt_close($stmt);
    return $deleted;
}
开发者ID:TaaviTilk,项目名称:i244_kodutood,代码行数:11,代码来源:model.php


示例7: saveUser

/**
 * @param $connection
 * @param array $user
 * @return bool
 */
function saveUser($connection, array &$user)
{
    $query = 'INSERT IGNORE INTO users (name, email, hashed_password) VALUES (?, ?, ?)';
    $statement = mysqli_prepare($connection, $query);
    mysqli_stmt_bind_param($statement, 'sss', $user['name'], $user['email'], $user['hashed_password']);
    mysqli_stmt_execute($statement);
    $inserted = (bool) mysqli_stmt_affected_rows($statement);
    if ($inserted) {
        $user['id'] = mysqli_stmt_insert_id($statement);
    }
    mysqli_stmt_close($statement);
    return $inserted;
}
开发者ID:Ezaki113,项目名称:expl-3,代码行数:18,代码来源:create.php


示例8: add_one

 function add_one($array)
 {
     $query = "INSERT INTO `{$this->_table}` SET `{$this->_fields_aut}` = ?";
     $stmt = mysqli_prepare($this->_c, $query);
     if ($stmt) {
         $count = count($data_add);
         for ($i = 0; $i < $count; $i++) {
             mysqli_stmt_bind_param($stmt, 's', $data_add[$i]);
             mysqli_stmt_execute($stmt);
         }
     }
     return printf("Rows inserted: %d\n", mysqli_stmt_affected_rows($stmt));
     mysqli_stmt_close($stmt);
 }
开发者ID:alenija,项目名称:custom,代码行数:14,代码来源:books.php


示例9: create_cookie

function create_cookie($dbc, $username)
{
    $create_token = "INSERT INTO tokens (username, token) VALUES (?, ?)";
    $stmt = mysqli_prepare($dbc, $create_token);
    $token = password_hash($username . "pickem", PASSWORD_DEFAULT);
    mysqli_stmt_bind_param($stmt, "ss", $username, $token);
    mysqli_stmt_execute($stmt);
    $affected_rows = mysqli_stmt_affected_rows($stmt);
    if ($affected_rows == 1) {
        setcookie("username", $username);
        setcookie("auth_token", $token);
    }
    mysqli_stmt_close($stmt);
}
开发者ID:AndrewBerlin,项目名称:cfbpickem,代码行数:14,代码来源:account_utils.php


示例10: model_delete

/**
 * Kustutab valitud rea andmebaasist.
 *
 * @param int $id Kustutatava rea ID
 *
 * @return int Mitu rida kustutati
 */
function model_delete($id)
{
    global $l, $prefix;
    $query = 'DELETE FROM ' . $prefix . '__kaubad WHERE Id=? LIMIT 1';
    $stmt = mysqli_prepare($l, $query);
    if (mysqli_error($l)) {
        echo mysqli_error($l);
        exit;
    }
    mysqli_stmt_bind_param($stmt, 'i', $id);
    mysqli_stmt_execute($stmt);
    $deleted = mysqli_stmt_affected_rows($stmt);
    mysqli_stmt_close($stmt);
    return $deleted;
}
开发者ID:andris9,项目名称:itk,代码行数:22,代码来源:model.php


示例11: versionsinsert

 function versionsinsert($stmt)
 {
     global $style, $lowbeam, $lbtech, $highbeam, $hbtech;
     mysqli_stmt_bind_param($stmt, "sssss", $style, $lowbeam, $lbtech, $highbeam, $hbtech);
     mysqli_stmt_execute($stmt);
     $affected_rows = mysqli_stmt_affected_rows($stmt);
     if ($affected_rows == 1) {
         echo 'Headlamp Entered';
         mysqli_stmt_close($stmt);
         mysqli_close($dbc);
     } else {
         echo 'Error Occurred <br/>';
         echo mysqli_error();
         mysqli_stmt_close($stmt);
         mysqli_close($dbc);
     }
 }
开发者ID:allisontharp,项目名称:Headlamps,代码行数:17,代码来源:headlampadded.php


示例12: verify

function verify($uuid)
{
    $msconf = getDatabaseCredentials();
    $dbcon = mysqli_connect($msconf['host'], $msconf['user'], $msconf['pass'], $msconf['db']);
    if (mysqli_connect_errno($dbcon)) {
        echo "Failed to connect to MySQL: " . mysqli_connect_errno($dbcon) . " : " . mysqli_connect_error();
        die;
    }
    $dbcon->query('CREATE TABLE IF NOT EXISTS `Users` (`Username` varchar(16) NOT NULL, `Name` varchar(60) NOT NULL, `PassHash` varchar(256) NOT NULL, `APIKey` varchar(256) NULL, `Permission` varchar(2) NOT NULL DEFAULT \'NN\', UNIQUE KEY `Username` (`Username`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;');
    $dbcon->query('CREATE TABLE IF NOT EXISTS `Blog` (`PUID` varchar(200) NOT NULL,`Post` varchar(10000) NOT NULL,`Date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `Author` varchar(16) NOT NULL, `Title` varchar(60) NOT NULL, UNIQUE KEY `PUID` (`PUID`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;');
    $dbcon->query('INSERT INTO `Users` (`Username`, `Name`, `PassHash`, `Permission`) VALUES (\'ace\', \'Cory Redmond\', \'2y11$WULjGCfjZEvtGEXfZkL3G.uzF3fRlJPGVsR.jCGguRhKIuph28572\', \'YY\');');
    // Default database connect //
    $preparedStm = $dbcon->prepare("UPDATE `Users` SET `Verified`='Y' WHERE `Verified` = ?;");
    $preparedStm->bind_param("s", $uuid);
    $preparedStm->execute();
    $aff = mysqli_stmt_affected_rows($preparedStm);
    if ($aff > 0) {
        return true;
    }
    return false;
}
开发者ID:nfell2009,项目名称:profile,代码行数:21,代码来源:user_functions.php


示例13: customerInsert

function customerInsert($data)
{
    $dbh = @mysqli_connect($servername, $username, $password, $dbname);
    if (!$dbh) {
        die(mysqli_connect_error());
    }
    $sql = "INSERT INTO customers (custid, firstname, lastname, email, company, phone, comment) VALUES (NULL, ?, ?, ?, ?, ?, ?)";
    $stmt = mysqli_prepare($dbh, $sql);
    mysqli_stmt_bind_param($stmt, "sssssss", $data["firstname"], $data["lastname"], $data["email"], $data["company"], $data["phone"], $data["comment"]);
    mysqli_stmt_execute($stmt);
    print "Rows inserted: " . mysqli_stmt_affected_rows($stmt) . "<br />";
    // printf("Error: %s.\n", mysqli_stmt_error($stmt));
    /*
    if(mysqli_stmt_execute($stmt)){
      print "customerInsert().executed<br />";
      print("Rows inserted: " . mysqli_stmt_affected_rows($stmt));
    }
    */
    $error = mysqli_connect_error($dbh);
    mysqli_close($dbh);
    return $error;
}
开发者ID:srichardson23,项目名称:PHP,代码行数:22,代码来源:index.php


示例14: customerInsert

function customerInsert($data)
{
    print "customerInsert().start<br />";
    $dbh = @mysqli_connect("localhost", "root", "", "custorders");
    if (!$dbh) {
        die(mysqli_connect_error());
    }
    print "customerInsert().connected<br />";
    $sql = "INSERT INTO customers (custid, fname, lname, address, city, prov, post, phone) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)";
    $stmt = mysqli_prepare($dbh, $sql);
    mysqli_stmt_bind_param($stmt, "sssssss", $data["fname"], $data["lname"], $data["address"], $data["city"], $data["prov"], $data["post"], $data["phone"]);
    mysqli_stmt_execute($stmt);
    print "Rows inserted: " . mysqli_stmt_affected_rows($stmt) . "<br />";
    // printf("Error: %s.\n", mysqli_stmt_error($stmt));
    /*
    if(mysqli_stmt_execute($stmt)){
      print "customerInsert().executed<br />";
      print("Rows inserted: " . mysqli_stmt_affected_rows($stmt));
    }
    */
    $error = mysqli_error($dbh);
    mysqli_close($dbh);
    return $error;
}
开发者ID:srichardson23,项目名称:PHP,代码行数:24,代码来源:functions.php


示例15: customerInsert

function customerInsert($data)
{
    // this is the SQL code to use for your DB. You could type this out or, in this case, add a dummy row through phpmyadmin, and copy the
    // code from there
    $sql = "INSERT INTO customers (CustomerId, CustFirstName, CustLastName, CustAddress, CustCity, CustProv, CustPostal, CustCountry, CustHomePhone, CustBusPhone, CustEmail, AgentId) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
    // this is the connection to your DB. $dbh is a variable to save the information of mysqli_connect. You could store the login information
    // into variables - $server, $username, $password, $tableToBeEditted
    $dbh = mysqli_connect("localhost", "travel", "password", "travelexperts");
    // if the connection fails...
    if (!$dbh) {
        // return the connection error and exit function.
        return mysqli_connect_error();
    }
    // this is preparing a variable with the parameters needed to INSERT info.
    // $dbh is the connection being used.
    // $sql is the code needed to change your DB table
    $stmt = mysqli_prepare($dbh, $sql);
    // mysqli_stmt_bind_param takes the prepared variable ($stmt) with the connection and SQL code, and replace the ? with the array data.
    // It uses the 'sssssssssi' as the types information being passed.
    mysqli_stmt_bind_param($stmt, "ssssssssssi", $data['CustFirstName'], $data['CustLastName'], $data['CustAddress'], $data['CustCity'], $data['CustProv'], $data['CustPostal'], $data['CustCountry'], $data['CustHomePhone'], $data['CustBusPhone'], $data['CustEmail'], $data['AgentId']);
    // execute all the above steps.
    mysqli_stmt_execute($stmt);
    // if the number of rows change...
    if (mysqli_stmt_affected_rows($stmt)) {
        // this returns different values for success and failures. 1 means success and 0 or -1 are failures.
        // print this message. This says that rows have changed, but doesn't tell you of it worked properly. Needs to be a 1 not 0 or-1
        $message = "Customer added successfully!";
    } else {
        // this will print if nothing has change or mysqli_stmt_affected_rows returns a 0.
        $message = "Adding Customer Failed. Call Technical Support";
    }
    // always close your table and DB so that it can be accessed by others.
    mysqli_close($dbh);
    // return the message
    return $message;
}
开发者ID:srichardson23,项目名称:PHP,代码行数:36,代码来源:insertCustomer.php


示例16: db_vexec

function db_vexec($query, $args) {
	$stmt = db_vce_stmt($query, $args);

	if (($affected_rows = mysqli_stmt_affected_rows($stmt)) < 0)
		fatal_mysqli('mysqli_affected_rows');

	mysqli_stmt_close($stmt);
	
	return $affected_rows;
}
开发者ID:rsnel,项目名称:logdb,代码行数:10,代码来源:db.php


示例17: array_map

    $scrubbed = array_map("spam_scrubber", $_POST);
    // Handle the form
    if (!empty($scrubbed["gbComment"])) {
        // Create the query
        $gb_query = "INSERT INTO guestbook (gbName, gbEmail, gbComment, gbDateAdded) VALUES (?, ?, ?, NOW())";
        // Prepare the statement
        $stmt = mysqli_prepare($li, $gb_query);
        // Bind the variables:
        mysqli_stmt_bind_param($stmt, 'sss', $name, $email, $comment);
        // Assign values to the variables
        $name = $scrubbed["gbName"];
        $email = $scrubbed["gbEmail"];
        $comment = $scrubbed["gbComment"];
        // Execute the query
        mysqli_stmt_execute($stmt);
        $res = mysqli_stmt_affected_rows($stmt);
        // See if insert was successful or not
        if ($res == 1) {
            $ret_str = "Your guestbook entry was successfully added.";
        } else {
            $ret_str = "Your guestbook entry was NOT successfully added.";
        }
        // Append success/failure message
        $gb_str .= "<span class=\"ret\">{$ret_str}</span><br />";
    }
}
// Get entries from database
$get_query = "SELECT gbName, gbEmail, gbComment, DATE_FORMAT(gbDateAdded, '%m-%d-%y %H:%i') gbDateAdded\n\t\tFROM guestbook";
$get_rs = mysqli_query($li, $get_query);
$gb_str .= "<hr size=\"1\" />";
// While there are still results
开发者ID:jmyroup,项目名称:uci_projects,代码行数:31,代码来源:guestbook_script.php


示例18: mysqli_query

 if (empty($errors)) {
     // If everything's OK...
     // test for unique email address:
     $q = "SELECT user_id FROM users WHERE email='{$e}' AND user_id != {$id}";
     $r = mysqli_query($dbc, $q) or trigger_error("Query: {$q}\n<br />MySQL Error: " . mysqli_error($dbc));
     if (mysqli_num_rows($r) == 0) {
         // Available.
         // Add the user to the database:
         $q = "UPDATE users SET first_name = ?, last_name = ?, email = ?, pass = ?, user_level = ? WHERE user_id = ? LIMIT 1";
         //prepare the statement
         $stmt = mysqli_prepare($dbc, $q);
         //bind the variables
         mysqli_stmt_bind_param($stmt, 'ssssii', $fn, $ln, $e, SHA1($p), $ul);
         //execute statement
         mysqli_stmt_execute($stmt);
         if (mysqli_stmt_affected_rows($dbc) == 1) {
             // If it ran OK.
             // Finish the page:
             echo '
                 <section class="fullPanel">
                     <div class="container-fluid">
                         <div class="col-sm-2"></div>
                         <div class="col-sm-8">
                             <p>The user has been edited.</p>
                         </div>
                         <div class="col-sm-2"></div>
                     </div>
                 </section>
                         ';
             include 'includes/template_bottom.inc.php';
             // Include the HTML footer.
开发者ID:artofjohnbaker,项目名称:Yellowspine,代码行数:31,代码来源:edit_user.php


示例19: execute

 function execute($sql)
 {
     $stmt = mysqli_prepare(self::$mysqli, $sql);
     mysqli_stmt_execute($stmt);
     return mysqli_stmt_affected_rows($stmt);
 }
开发者ID:shiyake,项目名称:PHP,代码行数:6,代码来源:Mysqli.php


示例20: mysqli_stmt_bind_param

             $pgroup = $rowEmp['pgroup'];
             $upload_file = $rowEmp['upload_file'];
             //$forpc=$rowEmp['pccd'];
             //$usercode=$rowmaxcode['usercode'];
             $f_cd = 1;
             $edcpb = 'E';
             $forassembly = NULL;
             $groupid = NULL;
             $booked = NULL;
             $rand_numb = NULL;
             mysqli_stmt_bind_param($stmt, 'sssssssssssiisssssssssssssssssssssssissisis', $personcd, $officecd, $officer_name, $off_desg, $present_addr1, $present_addr2, $perm_addr1, $perm_addr2, $dateofbirth, $gender, $scale, $basic_pay, $grade_pay, $workingstatus, $email, $resi_no, $mob_no, $qualificationcd, $languagecd, $epic, $acno, $slno, $partno, $poststat, $assembly_temp, $assembly_off, $assembly_perm, $districtcd, $subdivision, $forsubdivision, $bank_acc_no, $bank_cd, $branchcd, $remarks, $pgroup, $upload_file, $usercd, $forpc, $forassembly, $groupid, $booked, $rand_numb, $edcpb);
             mysqli_stmt_execute($stmt);
             mysqli_stmt_bind_param($stmt_up, 'is', $f_cd, $personcd);
             mysqli_stmt_execute($stmt_up);
             $row_aff += mysqli_stmt_affected_rows($stmt);
             mysqli_stmt_affected_rows($stmt_up);
             $rowEmp = NULL;
         }
         if (!mysqli_commit($link)) {
             print "Transaction commit failed\n";
             exit;
         } else {
             $msg = "<div class='alert-success'>" . $row_aff . " Record(s) transffered successfully</div>";
         }
         mysqli_stmt_close($stmt);
         mysqli_stmt_close($stmt_up);
         /* close connection */
         mysqli_close($link);
         $rsEmp = NULL;
     }
 }
开发者ID:MUN06,项目名称:Lok-Sabha-Election-16th,代码行数:31,代码来源:swapping-direct.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mysqli_stmt_bind_param函数代码示例发布时间:2022-05-15
下一篇:
PHP mysqli_ssl_set函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap