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


PHP mysqli_stmt_affected_rows函数代码示例

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


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


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