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


PHP DBObject::getAffected方法代码示例

本文整理汇总了PHP中DBObject::getAffected方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::getAffected方法的具体用法?PHP DBObject::getAffected怎么用?PHP DBObject::getAffected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObject的用法示例。


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

示例1: array

    $numbers = array('Age', 'offhours', 'onhours', 'HasPhoto', 'HasCert', 'HasEvalForm', 'schoolyear', 'semester');
    $bools = array('HasPhoto' => 'rp', 'HasCert' => 'rc', 'HasEvalForm' => 're');
    foreach ($_POST as $key => $value) {
        if ($key == 'sid' || $key == 'onid' || $key == 'offid') {
            ctype_digit($value) or die('Error: record does not exist.');
            $id = $value;
            $col = $db->escape($key);
        } else {
            $key = in_array($key, $bools) ? array_search($key, $bools) : $db->escape($key);
            $value = $key === 'Bday' ? date('Y-m-d', strtotime(trim($value))) : $db->escape($value);
            if (strstr($key, '-') === false) {
                $value = in_array($key, $numbers) ? $value : "'{$value}'";
                $sql = "UPDATE students SET {$key} = {$value} WHERE {$col} = {$id}";
            } else {
                $arrkey = explode('-', $key);
                $value = in_array($arrkey[1], $numbers) ? "{$value}" : "'{$value}'";
                if (empty($col)) {
                    $sql = "UPDATE {$arrkey['0']} SET {$arrkey['1']} = {$value}";
                } else {
                    $sql = "UPDATE {$arrkey['0']} SET {$arrkey['1']} = {$value} WHERE {$col} = {$id}";
                }
            }
            echo "{$sql}. ";
            if ($db->query($sql) && $db->getAffected() > 0) {
                echo "Saved.";
            } else {
                echo $db->getError();
            }
        }
    }
}
开发者ID:quo123,项目名称:cdc.spumanila.edu.dev,代码行数:31,代码来源:save.php

示例2: intval

 } else {
     if (isset($_POST['deleval'])) {
         $id = intval($_POST['deleval']);
         $sql = "DELETE FROM evaluation WHERE id = {$id}";
         if ($db->query($sql)) {
             echo 'Record deleted.';
         } else {
             die('Error: ' . $db->getError());
         }
     } else {
         if (isset($_POST['delact'])) {
             $actid = intval($_POST['delact']);
             $type = $db->escape($_POST['type']);
             $id = strstr($type, 'campus', true);
             $sql = "DELETE FROM {$type} WHERE {$id}id = {$actid}";
             if ($db->query($sql) && $db->getAffected() > 0) {
                 echo "Record deleted!";
             } else {
                 die('Error: Record does not exist.');
             }
         } else {
             if (isset($_POST['delstud'])) {
                 $student = intval($_POST['delstud']);
                 $find = array('oncampus' => 'onid', 'offcampus' => 'offid');
                 foreach ($find as $key => &$value) {
                     $value = array($value);
                     $sql = "SELECT {$value['0']} FROM {$key} WHERE student = {$student}";
                     if (($result = $db->query($sql)) && $db->getAffected() > 0) {
                         while ($row = mysqli_fetch_assoc($result)) {
                             $value[] = $row[$value[0]];
                         }
开发者ID:quo123,项目名称:cdc.spumanila.edu.dev,代码行数:31,代码来源:activity.php


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