public function updateData($dataTable, $dataValues, $dataCondition) { $this->q = "UPDATE " . $dataTable . " SET " . implode_with_key($dataValues, '=') . "WHERE " . implode_with_key($dataCondition, "", ""); }
/** * Get activities data to display * @param int $from * @param int $numberOfItems * @param int $column * @param string $direction * @return array */ public static function getActivitiesData($from, $numberOfItems, $column, $direction) { $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); $table_user = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); $column = intval($column); $from = intval($from); $numberOfItems = intval($numberOfItems); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'DESC'; } if (api_is_multiple_url_enabled()) { $sql = "SELECT\n default_event_type as col0,\n default_value_type as col1,\n default_value as col2,\n c_id as col3,\n session_id as col4,\n user.username as col5,\n user.user_id as col6,\n default_date as col7\n FROM {$track_e_default} as track_default, {$table_user} as user, {$access_url_rel_user_table} as url\n WHERE\n track_default.default_user_id = user.user_id AND\n url.user_id = user.user_id AND\n access_url_id='" . $current_url_id . "'"; } else { $sql = "SELECT\n default_event_type as col0,\n default_value_type as col1,\n default_value as col2,\n c_id as col3,\n session_id as col4,\n user.username as col5,\n user.user_id as col6,\n default_date as col7\n FROM {$track_e_default} track_default, {$table_user} user\n WHERE track_default.default_user_id = user.user_id "; } if (isset($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (user.username LIKE '%" . $keyword . "%' OR\n default_event_type LIKE '%" . $keyword . "%' OR\n default_value_type LIKE '%" . $keyword . "%' OR\n default_value LIKE '%" . $keyword . "%') "; } if (!empty($column) && !empty($direction)) { $sql .= " ORDER BY col{$column} {$direction}"; } else { $sql .= " ORDER BY col5 DESC "; } $sql .= " LIMIT {$from},{$numberOfItems} "; $res = Database::query($sql); $activities = array(); while ($row = Database::fetch_row($res)) { if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) { $row[2] = $row[2]; } else { if (!empty($row[2])) { $originalData = str_replace('\\', '', $row[2]); $row[2] = unserialize($originalData); if (is_array($row[2]) && !empty($row[2])) { $row[2] = implode_with_key(', ', $row[2]); } else { $row[2] = $originalData; } } } if (!empty($row['default_date']) && $row['default_date'] != '0000-00-00 00:00:00') { $row['default_date'] = api_get_local_time($row['default_date']); } else { $row['default_date'] = '-'; } if (!empty($row[5])) { //course if (!empty($row[3])) { $row[3] = Display::url($row[3], api_get_path(WEB_CODE_PATH) . 'admin/course_edit.php?id=' . $row[3]); } else { $row[3] = '-'; } // session if (!empty($row[4])) { $row[4] = Display::url($row[4], api_get_path(WEB_CODE_PATH) . 'session/resume_session.php?id_session=' . $row[4]); } else { $row[4] = '-'; } // User id. $row[5] = Display::url($row[5], api_get_path(WEB_CODE_PATH) . 'admin/user_information.php?user_id=' . $row[6], array('title' => get_lang('UserInfo'))); $row[6] = TrackingUserLog::get_ip_from_user_event($row[6], $row[7], true); if (empty($row[6])) { $row[6] = get_lang('Unknown'); } } $activities[] = $row; } return $activities; }
<?php require 'function.php'; require 'database.php'; require 'class.user.php'; // $db = new Database(); // $db->getDb(); $arrayData = array("hello" => "foo", "hi" => "bar", "ciao" => "qux"); $dataVal = ""; /*foreach($arrayData as $key => $value) { $dataVal .= $key . " = " . $value; } */ // $dataVal = implode("", array_keys($arrayData)); // echo implode(implode("=", array_keys($arrayData)) . ",", array_values($arrayData)); // echo implode_with_key($arrayData); echo implode_with_key($arrayData, " = ", ", ");