示例#1
0
 private function encryptValue($key, $value)
 {
     if (isset($this->exemptKeys[$key])) {
         return $value;
     } else {
         return Cryptography::en($value);
     }
 }
示例#2
0
 protected function applyChanges()
 {
     $grid = Request::get($this->gridTag);
     $updateCnt = 0;
     $deleteCnt = 0;
     foreach (Request::get($this->updTag, []) as $idx => $id) {
         $sql = 'UPDATE ' . $this->tableName . ' SET ';
         $params = [];
         foreach ($grid[$idx] as $colName => $value) {
             if ($colName == $this->primaryKey) {
                 continue;
             }
             if (count($params) > 0) {
                 $sql .= ', ';
             }
             $sql .= $colName . '=?';
             switch ($this->getColumnType($colName)) {
                 case self::ENCTEXT:
                     $params[] = Cryptography::en($value);
                     break;
                 case self::TIMESTAMP:
                     $params[] = strtotime((int) $value);
                     break;
                 default:
                     if ($this->nullsEmpty && empty($value)) {
                         $value = null;
                     }
                     $params[] = $value;
                     break;
             }
         }
         $sql .= ' WHERE ' . $this->primaryKey . '=?';
         $params[] = $id;
         $updateCnt += $this->exec($sql, $params);
     }
     foreach (Request::get($this->delTag, []) as $idx => $id) {
         $sql = 'DELETE FROM ' . $this->tableName . ' WHERE ' . $this->primaryKey . '=?';
         $deleteCnt += $this->exec($sql, $id);
     }
     if ($deleteCnt > 0) {
         $this->paginator->setRows($this->getRowCount());
     }
     return 'Updated ' . $updateCnt . ', Deleted ' . $deleteCnt . ' rows' . Tag::br();
 }