/** * @covers ITE\mysql->update * @depends testInsert */ public function testUpdate($id) { $table = 'log'; $values = array("log = 'Tested!'"); $this->assertTrue($this->object->update($table, $values, $id)); $this->assertFalse($this->object->update($table, $values, '\'S')); }
function run() { global $_out; if (ap::isCurrentModule($this)) { ap::addMessage($this->getMessage()); switch ($action = param('action')) { case 'active': if ($row = $this->getRow()) { $mysql = new mysql(); $state = !(param('active') == 'on'); $res = $mysql->update($this->table, array('active' => $state ? '1' : '0'), '`id`=' . $row); if (!$res) { $state = !$state; } if (param('ajax')) { ap::ajaxResponse($state ? 'on' : 'off'); } else { $this->redirect('active_' . ($res ? 'ok' : 'fail')); } } break; case 'move': if (($row = $this->getRow()) && ($pos = param('pos')) && ($rl = $this->getList()) && $rl->moveRow($row, $pos)) { $this->redirect('move_ok'); } else { $this->redirect('move_fail'); } break; case 'delete': if ($this->onDelete($action)) { $this->redirect('delete_ok'); } else { $this->redirect('delete_fail'); } break; case 'update': case 'apply_update': if ($this->onUpdate($action)) { $this->redirect('update_ok'); } else { $this->redirect('update_fail'); } break; case 'add': case 'apply_add': if ($this->onAdd($action)) { $this->redirect('add_ok'); } else { $this->redirect('add_fail'); } break; case 'edit': if ($this->onEdit($action)) { $_out->addSectionContent($this->getForm($action)->getRootElement()); } break; case 'new': if ($this->onNew($action)) { $_out->addSectionContent($this->getForm($action)->getRootElement()); } break; default: if ($rl = $this->getList()) { $rl->build(); $_out->addSectionContent($rl->getRootElement()); } } } }
function update($values, $cond) { return parent::update($this->getTable(), $values, $cond); }
/** * Обновить данные таблицы из массива * @param array $data * @param string $where * @internal param string $table * @return bool|int <type> */ public function update($data, $where = null) { return $this->_db->update($this->table, $data, $where); }