本文整理汇总了PHP中Database::affected_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::affected_rows方法的具体用法?PHP Database::affected_rows怎么用?PHP Database::affected_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::affected_rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_class
/**
* Create a class
* @param string $name
*/
public static function create_class($name)
{
$table_class = Database::get_main_table(TABLE_MAIN_CLASS);
$sql = "INSERT INTO {$table_class} SET name='" . Database::escape_string($name) . "'";
Database::query($sql);
return Database::affected_rows() == 1;
}
示例2: isset
}
break;
case 'delete':
// Delete course from session.
$idChecked = isset($_GET['idChecked']) ? $_GET['idChecked'] : null;
if (is_array($idChecked)) {
$usersToDelete = array();
foreach ($idChecked as $courseCode) {
// forcing the escape_string
$courseInfo = api_get_course_info($courseCode);
SessionManager::unsubscribe_course_from_session($sessionId, $courseInfo['real_id']);
}
}
if (!empty($_GET['class'])) {
$result = Database::query("DELETE FROM {$tbl_session_rel_class}\n WHERE session_id='{$sessionId}' AND class_id=" . intval($_GET['class']));
$nbr_affected_rows = Database::affected_rows($result);
Database::query("UPDATE {$tbl_session} SET nbr_classes=nbr_classes-{$nbr_affected_rows} WHERE id='{$sessionId}'");
}
if (!empty($_GET['user'])) {
SessionManager::unsubscribe_user_from_session($sessionId, $_GET['user']);
}
break;
}
$sessionHeader = Display::page_header(Display::return_icon('session.png', get_lang('Session')) . ' ' . $sessionInfo['name'], null, 'h3');
$url = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "session_edit.php?page=resume_session.php&id={$sessionId}");
$sessionTitle = Display::page_subheader(get_lang('GeneralProperties') . $url);
$generalCoach = api_get_user_info($sessionInfo['id_coach']);
$sessionField = new ExtraField('session');
$extraFieldData = $sessionField->getDataAndFormattedValues($sessionId);
$multiple_url_is_on = api_get_multiple_access_url();
$urlList = [];
示例3: WSUnsuscribeCoursesFromSession
function WSUnsuscribeCoursesFromSession($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
// Initialisation
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$coursessessions_params = $params['coursessessions'];
$results = array();
$orig_course_id_value = array();
$orig_session_id_value = array();
foreach ($coursessessions_params as $coursesession_param) {
$original_session_id_value = $coursesession_param['original_session_id_value'];
$original_session_id_name = $coursesession_param['original_session_id_name'];
$original_course_id_name = $coursesession_param['original_course_id_name'];
$original_course_id_values = $coursesession_param['original_course_id_values'];
$orig_session_id_value[] = $original_session_id_value;
$id_session = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
if (empty($id_session)) {
$results[] = 0;
continue;
}
// Get courses list from row_original_course_id_values
$course_list = array();
$courseIdList = [];
foreach ($original_course_id_values as $row_original_course_list) {
$course_code = Database::escape_string($row_original_course_list['course_code']);
// Check whether exits $x_course_code into user_field_values table.
$courseInfo = CourseManager::getCourseInfoFromOriginalId($row_original_course_list['course_code'], $original_course_id_name);
if (empty($courseInfo) || isset($courseInfo) && $courseInfo['visibility'] == 0) {
continue;
// Course_code doesn't exist'
}
$course_list[] = $courseInfo['code'];
$courseIdList[] = $courseInfo['real_id'];
}
if (empty($course_list)) {
$results[] = 0;
continue;
}
$orig_course_id_value[] = implode(',', $course_list);
foreach ($courseIdList as $courseId) {
$courseId = intval($courseId);
Database::query("DELETE FROM {$tbl_session_rel_course}\n WHERE c_id ='{$courseId}' AND session_id='{$id_session}'");
$result = Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE c_id='{$courseId}' AND session_id = '{$id_session}'");
Event::addEvent(LOG_SESSION_DELETE_COURSE, LOG_COURSE_ID, $courseId, api_get_utc_datetime(), api_get_user_id(), $courseId, $id_session);
$return = Database::affected_rows($result);
}
$nbr_courses = 0;
$sql = "SELECT nbr_courses FROM {$tbl_session} WHERE id = '{$id_session}'";
$res_nbr_courses = Database::query($sql);
$row_nbr_courses = Database::fetch_row($res_nbr_courses);
if (Database::num_rows($res_nbr_courses) > 0) {
$nbr_users = $row_nbr_courses[0] - $return;
}
// Update number of users in the session.
$update_sql = "UPDATE {$tbl_session} SET nbr_courses= {$nbr_courses} WHERE id='{$id_session}' ";
Database::query($update_sql);
$results[] = 1;
continue;
}
$count_results = count($results);
$output = array();
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_course_id_values' => $orig_course_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
}
return $output;
}
示例4: delete_note
static function delete_note($notebook_id)
{
if (empty($notebook_id) or $notebook_id != strval(intval($notebook_id))) {
return false;
}
// Database table definition
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$course_id = api_get_course_int_id();
$sql = "DELETE FROM $t_notebook WHERE c_id = $course_id AND notebook_id='" . intval($notebook_id) . "' AND user_id = '" . api_get_user_id() . "'";
$result = Database::query($sql);
$affected_rows = Database::affected_rows();
if ($affected_rows != 1) {
return false;
}
//update item_property (delete)
api_item_property_update(api_get_course_info(), TOOL_NOTEBOOK, intval($notebook_id), 'delete', api_get_user_id());
return true;
}
示例5: delete_groups
/**
* deletes groups and their data.
* @author Christophe Gesche <christophe.gesche@claroline.net>
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @author Bart Mollet
* @param mixed $groupIdList - group(s) to delete. It can be a single id
* (int) or a list of id (array).
* @param string $course_code Default is current course
* @return integer - number of groups deleted.
*/
public static function delete_groups($group_ids, $course_code = null)
{
$course_info = api_get_course_info($course_code);
$course_id = $course_info['real_id'];
// Database table definitions
$group_table = Database::get_course_table(TABLE_GROUP);
$forum_table = Database::get_course_table(TABLE_FORUM);
$group_ids = is_array($group_ids) ? $group_ids : array($group_ids);
$group_ids = array_map('intval', $group_ids);
if (!api_is_platform_admin() && api_is_course_coach()) {
// A coach can only delete courses from his session
for ($i = 0; $i < count($group_ids); $i++) {
if (!api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])) {
array_splice($group_ids, $i, 1);
$i--;
}
}
if (count($group_ids) == 0) {
return 0;
}
}
// Unsubscribe all users
self::unsubscribe_all_users($group_ids);
$sql = "SELECT iid, secret_directory, session_id\n FROM {$group_table}\n WHERE c_id = {$course_id} AND iid IN (" . implode(' , ', $group_ids) . ")";
$db_result = Database::query($sql);
while ($group = Database::fetch_object($db_result)) {
// move group-documents to garbage
$source_directory = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . "/document" . $group->secret_directory;
//File to renamed
$destination_dir = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . "/document" . $group->secret_directory . '_DELETED_' . $group->iid;
if (!empty($group->secret_directory)) {
//Deleting from document tool
DocumentManager::delete_document($course_info, $group->secret_directory, $source_directory);
if (file_exists($source_directory)) {
if (api_get_setting('permanently_remove_deleted_files') == 'true') {
// Delete
my_delete($source_directory);
} else {
// Rename
rename($source_directory, $destination_dir);
}
}
}
}
// delete the groups
$sql = "DELETE FROM " . $group_table . " WHERE c_id = {$course_id} AND iid IN ('" . implode("' , '", $group_ids) . "')";
Database::query($sql);
$sql = "DELETE FROM " . $forum_table . " WHERE c_id = {$course_id} AND forum_of_group IN ('" . implode("' , '", $group_ids) . "')";
Database::query($sql);
return Database::affected_rows($result);
}
示例6: courseInfo
/**
* Extended information about the course (from the course table as well as
* the buy_course table)
* @param string $code The course code
* @return array Info about the course
*/
function courseInfo($code)
{
$tableBuyCourse = Database::get_main_table(TABLE_BUY_COURSE);
$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$currentUserId = api_get_user_id();
$code = Database::escape_string($code);
$sql = "SELECT a.course_id, a.visible, a.price, b.*\r\n FROM {$tableBuyCourse} a, course b\r\n WHERE\r\n a.course_id=b.id AND\r\n a.visible = 1 AND\r\n b.id = '" . $code . "'";
$res = Database::query($sql);
$row = Database::fetch_assoc($res);
// Check teacher
$sql = "SELECT lastname, firstname\r\n FROM {$tableCourseRelUser} a, {$tableUser} b\r\n WHERE\r\n a.c_id = '" . $row['id'] . "' AND\r\n a.status <> 6 AND\r\n a.user_id = b.user_id;";
$tmp = Database::query($sql);
$rowTmp = Database::fetch_assoc($tmp);
$row['teacher'] = $rowTmp['firstname'] . ' ' . $rowTmp['lastname'];
//Check if student is enrolled
if ($currentUserId > 0) {
$sql = "SELECT 1 FROM {$tableCourseRelUser}\r\n WHERE\r\n c_id ='" . $row['id'] . "' AND\r\n user_id='" . $currentUserId . "';";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
$row['enrolled'] = "YES";
} else {
$row['enrolled'] = "NO";
}
} else {
$row['enrolled'] = "NO";
}
//check img
if (file_exists("../../courses/" . $row['code'] . "/course-pic85x85.png")) {
$row['course_img'] = "courses/" . $row['code'] . "/course-pic85x85.png";
} else {
$row['course_img'] = "main/img/without_picture.png";
}
$row['price'] = number_format($row['price'], 2, '.', ' ');
return $row;
}
示例7: delete_course_in_session
/**
* @param $id_session
* @param $courseId
*/
static function delete_course_in_session($id_session, $courseId)
{
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$id_session = intval($id_session);
$courseId = Database::escape_string($courseId);
if (!empty($id_session) && !empty($courseId)) {
$result = Database::query("DELETE FROM {$tbl_session_rel_course} WHERE id_session='{$id_session}' AND c_id = '{$courseId}'");
$nbr_affected_rows = Database::affected_rows($result);
Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND c_id = '{$courseId}'");
Database::query("UPDATE {$tbl_session} SET nbr_courses=nbr_courses-{$nbr_affected_rows} WHERE id='{$id_session}'");
}
}
示例8: set_name
/**
* Sets the name of the current learnpath (and save)
* @param string Optional string giving the new name of this learnpath
* @return boolean True/False
*/
public function set_name($name = null)
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::set_name()', 0);
}
if (empty($name)) {
return false;
}
$this->name = Database::escape_string($name);
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
$course_id = api_get_course_int_id();
$sql = "UPDATE {$lp_table} SET name = '" . $this->name . "' WHERE c_id = " . $course_id . " AND id = '{$lp_id}'";
if ($this->debug > 2) {
error_log('New LP - lp updated with new name : ' . $this->name, 0);
}
$result = Database::query($sql);
// If the lp is visible on the homepage, change his name there.
if (Database::affected_rows($result)) {
$session_id = api_get_session_id();
$session_condition = api_get_session_condition($session_id);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id . '&id_session=' . $session_id;
$sql = "UPDATE {$tbl_tool} SET name = '{$this->name}'\n \t WHERE c_id = " . $course_id . " AND (link='{$link}' and image='scormbuilder.gif' {$session_condition})";
Database::query($sql);
return true;
} else {
return false;
}
}
示例9: store_dashboard_plugins
/**
* This function allows easy activating and inactivating
* of plugins and save them inside db
* @param array $plugin_paths dashboard plugin paths
* return int affected rows
*/
public static function store_dashboard_plugins($plugin_paths)
{
$tbl_block = Database::get_main_table(TABLE_MAIN_BLOCK);
$affected_rows = 0;
// get all plugins path inside plugin directory
$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH) . 'dashboard/';
$possibleplugins = self::get_posible_dashboard_plugins_path();
if (count($possibleplugins) > 0) {
$selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins);
$not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths));
// get blocks id from not selected path
$not_selected_blocks_id = array();
foreach ($not_selected_plugins as $plugin) {
$block_data = self::get_enabled_dashboard_blocks($plugin);
if (!empty($block_data[$plugin])) {
$not_selected_blocks_id[] = $block_data[$plugin]['id'];
}
}
/* clean not selected plugins for extra user data and block data */
// clean from extra user data
$field_variable = 'dashboard';
$extra_user_data = UserManager::get_extra_user_data_by_field_variable($field_variable);
foreach ($extra_user_data as $key => $user_data) {
$user_id = $key;
$user_block_data = self::get_user_block_data($user_id);
$user_block_id = array_keys($user_block_data);
// clean disabled block data
foreach ($user_block_id as $block_id) {
if (in_array($block_id, $not_selected_blocks_id)) {
unset($user_block_data[$block_id]);
}
}
// get columns and blocks id for updating extra user data
$columns = array();
$user_blocks_id = array();
foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column'];
}
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
}
// clean from block data
if (!empty($not_selected_blocks_id)) {
$sql_check = "SELECT id FROM {$tbl_block} WHERE id IN(" . implode(',', $not_selected_blocks_id) . ")";
$rs_check = Database::query($sql_check);
if (Database::num_rows($rs_check) > 0) {
$del = "DELETE FROM {$tbl_block} WHERE id IN(" . implode(',', $not_selected_blocks_id) . ")";
Database::query($del);
}
}
// store selected plugins
foreach ($selected_plugins as $testplugin) {
$selected_path = Database::escape_string($testplugin);
// check if the path already stored inside block table for updating or adding it
$sql = "SELECT path FROM {$tbl_block} WHERE path = '{$selected_path}'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
// update
$upd = "UPDATE {$tbl_block} SET active = 1 WHERE path = '{$selected_path}'";
$result = Database::query($upd);
$affected_rows = Database::affected_rows($result);
} else {
// insert
$plugin_info_file = $dashboard_pluginpath . $testplugin . "/{$testplugin}.info";
$plugin_info = array();
if (file_exists($plugin_info_file)) {
$plugin_info = parse_info_file($plugin_info_file);
}
// change keys to lower case
$plugin_info = array_change_key_case($plugin_info);
// setting variables
$plugin_name = $testplugin;
$plugin_description = '';
$plugin_controller = '';
$plugin_path = $testplugin;
if (isset($plugin_info['name'])) {
$plugin_name = Database::escape_string($plugin_info['name']);
}
if (isset($plugin_info['description'])) {
$plugin_description = Database::escape_string($plugin_info['description']);
}
if (isset($plugin_info['controller'])) {
$plugin_controller = Database::escape_string($plugin_info['controller']);
}
$ins = "INSERT INTO {$tbl_block}(name, description, path, controller)\n\t\t\t\t\t\t\tVALUES ('{$plugin_name}', '{$plugin_description}', '{$plugin_path}', '{$plugin_controller}')";
$result = Database::query($ins);
$affected_rows = Database::affected_rows($result);
}
}
}
return $affected_rows;
}
示例10: header
if (!(list($session_name) = Database::fetch_row($result))) {
header('Location: session_list.php');
exit;
}
if ($action == 'delete') {
$idChecked = $_REQUEST['idChecked'];
if (is_array($idChecked) && count($idChecked) > 0) {
$my_temp = array();
foreach ($idChecked as $id) {
$my_temp[] = Database::escape_string($id);
// forcing the escape_string
}
$idChecked = $my_temp;
$idChecked = "'" . implode("','", $idChecked) . "'";
Database::query("DELETE FROM {$tbl_session_rel_course} WHERE id_session='{$id_session}' AND course_code IN({$idChecked})");
$nbr_affected_rows = Database::affected_rows();
Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND course_code IN({$idChecked})");
Database::query("UPDATE {$tbl_session} SET nbr_courses=nbr_courses-{$nbr_affected_rows} WHERE id='{$id_session}'");
}
header('Location: ' . api_get_self() . '?id_session=' . $id_session . '&sort=' . $sort);
exit;
}
$limit = 20;
$from = $page * $limit;
$sql = "SELECT code, title, nbr_users FROM {$tbl_session_rel_course}, {$tbl_course} WHERE course_code=code AND id_session='{$id_session}' ORDER BY {$sort} LIMIT {$from}," . ($limit + 1);
$result = Database::query($sql);
$Courses = Database::store_result($result);
$tool_name = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession');
$interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => "session_list.php", "name" => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=" . Security::remove_XSS($_REQUEST['id_session']), "name" => get_lang('SessionOverview'));
示例11: editAttachedFile
/**
* Update forum attachment data, used to update comment and post ID.
* @param $array Array (field => value) to update forum attachment row.
* @param $id Attach ID to find row to update.
* @param null $courseId Course ID to find row to update.
* @return int Number of affected rows.
*/
function editAttachedFile($array, $id, $courseId = null)
{
// Init variables
$setString = '';
$id = intval($id);
$courseId = intval($courseId);
if (empty($courseId)) {
// $courseId can be null, use api method
$courseId = api_get_course_int_id();
}
/*
* Check if Attachment ID and Course ID are greater than zero
* and array of field values is not empty
*/
if ($id > 0 && $courseId > 0 && !empty($array) && is_array($array)) {
foreach ($array as $key => &$item) {
$item = Database::escape_string($item);
$setString .= $key . ' = "' . $item . '", ';
}
// Delete last comma
$setString = substr($setString, 0, strlen($setString) - 2);
$forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$sql = "UPDATE {$forumAttachmentTable} SET {$setString} WHERE c_id = {$courseId} AND id = {$id}";
$result = Database::query($sql);
if ($result !== false) {
$affectedRows = Database::affected_rows($result);
if ($affectedRows > 0) {
/*
* If exist in $_SESSION variable, then delete them from it
* because they would be deprecated
*/
if (!empty($_SESSION['forum']['upload_file'][$courseId][$id])) {
unset($_SESSION['forum']['upload_file'][$courseId][$id]);
}
}
return $affectedRows;
}
}
return 0;
}
示例12: api_track_item_property_update
/**
* Inserts a record in the track_e_item_property table (No update)
* @param string $tool
* @param int $ref
* @param string $title
* @param string $content
* @param int $progress
* @return bool|int
*/
function api_track_item_property_update($tool, $ref, $title, $content, $progress)
{
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
$course_id = api_get_real_course_id();
//numeric
$course_code = api_get_course_id();
//alphanumeric
$item_property_id = api_get_item_property_id($course_code, $tool, $ref);
if (!empty($item_property_id)) {
$sql = "INSERT IGNORE INTO {$tbl_stats_item_property} SET\n course_id = '{$course_id}',\n item_property_id = '{$item_property_id}',\n title = '" . Database::escape_string($title) . "',\n content = '" . Database::escape_string($content) . "',\n progress = '" . intval($progress) . "',\n lastedit_date = '" . api_get_utc_datetime() . "',\n lastedit_user_id = '" . api_get_user_id() . "',\n session_id = '" . api_get_session_id() . "'";
$result = Database::query($sql);
$affected_rows = Database::affected_rows($result);
return $affected_rows;
}
return false;
}
示例13: attendance_calendar_delete
/**
* delete a datetime from attendance calendar table
* @param int attendance calendar id
* @param int attendance id
* @param bool true for removing all calendar inside current attendance, false for removing by calendar id
* @return int affected rows
*/
public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false)
{
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
$session_id = api_get_session_id();
$attendance_id = intval($attendance_id);
// get all registered users inside current course
$users = $this->get_users_rel_course();
$user_ids = array_keys($users);
$course_id = api_get_course_int_id();
if ($all_delete) {
$attendance_calendar = $this->get_attendance_calendar($attendance_id);
$calendar_ids = array();
// get all dates from calendar by current attendance
if (!empty($attendance_calendar)) {
foreach ($attendance_calendar as $cal) {
// delete all data from attendance sheet
$sql = "DELETE FROM {$tbl_attendance_sheet} WHERE c_id = {$course_id} AND attendance_calendar_id = '" . intval($cal['id']) . "'";
Database::query($sql);
// delete data from attendance calendar
$sql = "DELETE FROM {$tbl_attendance_calendar} WHERE c_id = {$course_id} AND id = '" . intval($cal['id']) . "'";
$result = Database::query($sql);
}
}
} else {
// delete just one row from attendance sheet by the calendar id
$sql = "DELETE FROM {$tbl_attendance_sheet} WHERE c_id = {$course_id} AND attendance_calendar_id = '" . intval($calendar_id) . "'";
Database::query($sql);
// delete data from attendance calendar
$sql = "DELETE FROM {$tbl_attendance_calendar} WHERE c_id = {$course_id} AND id = '" . intval($calendar_id) . "'";
$result = Database::query($sql);
}
$affected_rows = Database::affected_rows($result);
// update users' results
$this->update_users_results($user_ids, $attendance_id);
return $affected_rows;
}
示例14: update_ticket_status
/**
* @param $status_id
* @param $ticket_id
* @param $user_id
* @return bool
*/
public static function update_ticket_status(
$status_id,
$ticket_id,
$user_id
) {
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$ticket_id = intval($ticket_id);
$status_id = intval($status_id);
$user_id = intval($user_id);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_tickets . " SET
status_id = '$status_id',
sys_lastedit_user_id ='$user_id',
sys_lastedit_datetime ='" . $now . "'
WHERE ticket_id ='$ticket_id'";
Database::query($sql);
if (Database::affected_rows() > 0) {
return true;
} else {
return false;
}
}
示例15: delete_user_fields
/**
* Delete a user field (and also the options and values entered by the users)
*
* @param integer $field_id the id of the field that has to be deleted
* @return boolean true if the field has been deleted, false if the field could not be deleted (for whatever reason)
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version July 2008
* @since Dokeos 1.8.6
*/
function delete_user_fields($field_id)
{
// Database table definitions
$table_user_field = Database::get_main_table(TABLE_MAIN_USER_FIELD);
$table_user_field_options = Database::get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
// delete the fields
$sql = "DELETE FROM {$table_user_field} WHERE id = '" . Database::escape_string($field_id) . "'";
$result = Database::query($sql);
if (Database::affected_rows($result) == 1) {
// delete the field options
$sql = "DELETE FROM {$table_user_field_options} WHERE field_id = '" . Database::escape_string($field_id) . "'";
$result = Database::query($sql);
// delete the field values
$sql = "DELETE FROM {$table_user_field_values} WHERE field_id = '" . Database::escape_string($field_id) . "'";
$result = Database::query($sql);
// recalculate the field_order because the value is used to show/hide the up/down icon
// and the field_order value cannot be bigger than the number of fields
$sql = "SELECT * FROM {$table_user_field} ORDER BY field_order ASC";
$result = Database::query($sql);
$i = 1;
while ($row = Database::fetch_array($result)) {
$sql_reorder = "UPDATE {$table_user_field} SET field_order = '" . Database::escape_string($i) . "' WHERE id = '" . Database::escape_string($row['id']) . "'";
$result_reorder = Database::query($sql_reorder);
$i++;
}
// field was deleted so we return true
return true;
} else {
// the field was not deleted so we return false
return false;
}
}