本文整理汇总了PHP中lcm_query函数的典型用法代码示例。如果您正苦于以下问题:PHP lcm_query函数的具体用法?PHP lcm_query怎么用?PHP lcm_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lcm_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_groups
function create_groups($keyword_groups)
{
foreach ($keyword_groups as $skwg) {
// Insert keyword group data into database table
$q = "INSERT INTO lcm_keyword_group \n\t\t\t\t(name, title, description, type, policy, quantity, suggest, ac_admin, ac_author) \n\t\t\tVALUES (" . "'" . addslashes($skwg['name']) . "', " . "'" . addslashes($skwg['title']) . "', " . "'" . addslashes($skwg['description']) . "', " . "'" . addslashes($skwg['type']) . "', " . "'" . addslashes($skwg['policy']) . "', " . "'" . addslashes($skwg['quantity']) . "', " . "'" . addslashes($skwg['suggest']) . "', " . "'" . addslashes($skwg['ac_admin']) . "', " . "'" . addslashes($skwg['ac_author']) . "')";
$result = lcm_query($q, true);
// Ignore if keyword exists (has unique key)
// Findout under what ID is this group stored
// Note: Do this instead of lcm_insert_id() because the keyword might not have been
// inserted, so using lcm_insert_id() would re-create ALL keywords using the latest kwg id...
$q = "SELECT id_group,name FROM lcm_keyword_group WHERE name='" . addslashes($skwg['name']) . "'";
$result = lcm_query($q);
$row = lcm_fetch_array($result);
$kwg_id = $row['id_group'];
// If group is not successfully created or its ID is not found, report error
// [ML] Failed SQL insert generates lcm_panic(), so this becomes useless.
if ($kwg_id < 1) {
lcm_log("create_groups: creation of keyword group seems to have failed. Aborting.");
lcm_log("-> Query was: " . $q);
return;
}
// Insert keywords data into database table
foreach ($skwg['keywords'] as $k) {
if (!isset($k['hasvalue'])) {
$k['hasvalue'] = 'N';
}
$q = "INSERT INTO lcm_keyword\n\t\t\t\t\t(id_group, name, title, description, hasvalue, ac_author)\n\t\t\t\tVALUES (" . $kwg_id . ", " . "'" . addslashes($k['name']) . "', " . "'" . addslashes($k['title']) . "', " . "'" . addslashes($k['description']) . "', " . "'" . addslashes($k['hasvalue']) . "', " . "'" . addslashes($k['ac_author']) . "')";
$result = lcm_query($q, true);
// Ignore if keyword exists (has unique key)
}
}
}
示例2: read_author_data
function read_author_data($id_author)
{
$q = "SELECT * FROM lcm_author WHERE id_author=" . $id_author;
$result = lcm_query($q);
if (!($usr = lcm_fetch_array($result))) {
lcm_panic("The user #{$id_author} does not exist in the database.");
}
return $usr;
}
示例3: lcm_test_alter_table
function lcm_test_alter_table()
{
$log = "";
lcm_query("DROP TABLE lcm_test", true);
lcm_query("CREATE TABLE lcm_test (a INT)");
lcm_query("ALTER TABLE lcm_test ADD b INT");
lcm_query("INSERT INTO lcm_test (b) VALUES (1)");
$result = lcm_query("SELECT b FROM lcm_test");
lcm_query("ALTER TABLE lcm_test DROP b");
if (!$result) {
$log .= "User does not have the right to modify the database:";
if (lcm_sql_errno()) {
$log .= "<p>" . lcm_sql_error() . "</p>";
} else {
$log .= "<p>" . "No error message available." . "</p>";
}
}
lcm_query("DROP TABLE lcm_test", true);
return $log;
}
示例4: create_repfields
function create_repfields($rep_fields)
{
foreach ($rep_fields as $f) {
$q = "SELECT * \n\t\t\t\tFROM lcm_fields \n\t\t\t\tWHERE table_name = '" . $f['table_name'] . "'\n\t\t\t\t AND field_name = '" . $f['field_name'] . "'";
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
// check if update necessary
$needs_update = false;
foreach ($f as $key => $val) {
if ($row[$key] != $val) {
$needs_update = true;
}
}
if ($needs_update) {
$all_fields_tmp = array();
$all_fields = "";
foreach ($f as $key => $val) {
$all_fields_tmp[] = "{$key} = '{$val}'";
}
$all_fields = implode(", ", $all_fields_tmp);
$q2 = "UPDATE lcm_fields\n\t\t\t\t\t\tSET " . $all_fields . "\n\t\t\t\t\t\tWHERE table_name = '" . $f['table_name'] . "'\n\t\t\t\t\t\t AND field_name = '" . $f['field_name'] . "'";
lcm_query($q2);
}
} else {
// insert new field
$field_list = "";
$values_list = "";
foreach ($f as $key => $val) {
$field_list .= "{$key},";
$values_list .= "'{$val}',";
}
$field_list = preg_replace("/,\$/", "", $field_list);
$values_list = preg_replace("/,\$/", "", $values_list);
$q2 = "INSERT INTO lcm_fields ({$field_list})\n\t\t\t\t\t\tVALUES (" . $values_list . ")";
lcm_query($q2);
}
}
}
示例5: spip_query
function spip_query($query)
{
return lcm_query($query);
}
示例6: auth
function auth()
{
global $INSECURE, $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_COOKIE_VARS, $REMOTE_USER, $PHP_AUTH_USER, $PHP_AUTH_PW;
global $auth_can_disconnect;
global $connect_id_auteur, $connect_nom, $connect_bio, $connect_email;
global $connect_nom_site, $connect_url_site, $connect_login, $connect_pass;
global $connect_activer_imessage, $connect_activer_messagerie;
global $connect_status;
global $author_session, $prefs;
global $clean_link;
// This reloads $GLOBALS['db_ok'], just in case
include_config('inc_connect');
// If there is not SQL connection, quit.
if (!$GLOBALS['db_ok']) {
include_lcm('inc_presentation');
lcm_html_start("Technical problem", "install");
// annoy sql_errno()
echo "\n<!-- \n";
echo "\t* Flag connect: " . $GLOBALS['flag_connect'] . "\n\t";
lcm_query("SELECT count(*) from lcm_meta");
echo "\n-->\n\n";
echo "<div align='left' style='width: 600px;' class='box_error'>\n";
echo "\t<h3>" . _T('title_technical_problem') . "</h3>\n";
echo "\t<p>" . _T('info_technical_problem_database') . "</p>\n";
if (lcm_sql_errno()) {
echo "\t<p><tt>" . lcm_sql_errno() . " " . lcm_sql_error() . "</tt></p>\n";
} else {
echo "\t<p><tt>No error diagnostic was provided.</tt></p>\n";
}
echo "</div>\n";
lcm_html_end();
return false;
}
// Initialise variables (avoid URL hacks)
$auth_login = "";
$auth_pass = "";
$auth_pass_ok = false;
$auth_can_disconnect = false;
// Fetch identification data from authentication session
if (isset($_COOKIE['lcm_session'])) {
if (verifier_session($_COOKIE['lcm_session'])) {
if ($author_session['status'] == 'admin' or $author_session['status'] == 'normal') {
$auth_login = $author_session['username'];
$auth_pass_ok = true;
$auth_can_disconnect = true;
}
}
} else {
if ($_REQUEST['privet'] == 'yes') {
// Failed login attempt: cookie failed
$link = new Link("lcm_cookie.php?cookie_test_failed=yes");
$clean_link->delVar('privet');
$url = str_replace('/./', '/', $clean_link->getUrl());
$link->addVar('var_url', $url);
@header("Location: " . $link->getUrl());
exit;
}
}
// If not authenticated, ask for login / password
if (!$auth_login) {
$url = $clean_link->getUrl();
@header("Location: lcm_login.php?var_url=" . urlencode($url));
exit;
}
//
// Search for the login in the authors' table
//
$auth_login = addslashes($auth_login);
$query = "SELECT * FROM lcm_author WHERE username='{$auth_login}' AND status !='external' AND status !='6forum'";
$result = @lcm_query($query);
if ($row = lcm_fetch_array($result)) {
$connect_id_auteur = $row['id_author'];
$connect_nom = $row['name_first'];
$connect_login = $row['username'];
$connect_pass = $row['password'];
$connect_status = $row['status'];
$connect_activer_messagerie = "non";
//$row["messagerie"];
$connect_activer_imessage = "non ";
//$row["imessage"];
// Set the users' preferences
$prefs = unserialize(get_magic_quotes_runtime() ? stripslashes($row['prefs']) : $row['prefs']);
//
// Default values for some possibly unset preferences
//
if (!isset($prefs['page_rows']) || intval($prefs['page_rows']) < 1) {
$prefs['page_rows'] = 15;
}
if (!isset($prefs['theme']) || !$prefs['theme']) {
$prefs['theme'] = 'green';
}
if (!isset($prefs['screen']) || !$prefs['screen']) {
$prefs['screen'] = 'wide';
}
if (!isset($prefs['font_size']) || !$prefs['font_size']) {
$prefs['font_size'] = 'medium_font';
}
if (!isset($prefs['case_owner']) || !$prefs['case_owner']) {
$prefs['case_owner'] = 'my';
}
//.........这里部分代码省略.........
示例7: lcm_insert_id
function lcm_insert_id($table, $field)
{
// return mysql_insert_id();
$result = lcm_query("SELECT last_value FROM {$table}_{$field}_seq");
$seq_array = pg_fetch_row($result, 0);
return $seq_array[0];
}
示例8: erase_meta
function erase_meta($name)
{
lcm_query("DELETE FROM lcm_meta WHERE name='{$name}'");
}
示例9: show_report_filters
function show_report_filters($id_report, $is_runtime = false)
{
// Get general report info
$q = "SELECT * FROM lcm_report WHERE id_report = " . intval($id_report);
$res = lcm_query($q);
$rep_info = lcm_fetch_array($res);
if (!$rep_info) {
lcm_panic("Report does not exist: {$id_report}");
}
// List filters attached to this report
$query = "SELECT *\n\t\tFROM lcm_rep_filter as v, lcm_fields as f\n\t\tWHERE id_report = " . $id_report . "\n\t\tAND f.id_field = v.id_field";
// If generating the report (as opposed to editing), show filters
// who have a filter type (eq, neq, in, ..), but no value.
if ($is_runtime) {
$query .= " AND v.type != '' AND v.value = '' ";
}
$result = lcm_query($query);
if (lcm_num_rows($result)) {
if ($is_runtime) {
// submit all at once (else submit on a per-filter basis)
echo '<form action="run_rep.php" name="frm_filters" method="get">' . "\n";
echo '<input name="rep" value="' . $id_report . '" type="hidden" />' . "\n";
if (isset($_REQUEST['export'])) {
echo '<input name="export" value="' . $_REQUEST['export'] . '" type="hidden" />' . "\n";
}
}
echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
while ($filter = lcm_fetch_array($result)) {
if (!$is_runtime) {
echo "<form action='upd_rep_field.php' name='frm_line_additem' method='get'>\n";
echo "<input name='update' value='filter' type='hidden' />\n";
echo "<input name='rep' value='{$id_report}' type='hidden' />\n";
echo "<input name='id_filter' value='" . $filter['id_filter'] . "' type='hidden' />\n";
}
echo "<tr>\n";
echo "<td>" . _Th($filter['description']) . "</td>\n";
// Type of filter
echo "<td>";
$all_filters = array('number' => array('none', 'num_eq', 'num_neq', 'num_lt', 'num_le', 'num_gt', 'num_ge'), 'date' => array('none', 'date_eq', 'date_in', 'date_lt', 'date_le', 'date_gt', 'date_ge'), 'text' => array('none', 'text_eq', 'text_neq'));
if ($all_filters[$filter['filter']]) {
// At runtime, if a filter has been selected, do not allow select
if ($filter['type'] && $is_runtime) {
echo _T('rep_filter_' . $filter['type']);
} else {
echo "<select name='filter_type'>\n";
echo "<option value=''>...</option>\n";
foreach ($all_filters[$filter['filter']] as $f) {
$sel = $filter['type'] == $f ? ' selected="selected"' : '';
echo "<option value='" . $f . "'" . $sel . ">" . _T('rep_filter_' . $f) . "</option>\n";
}
echo "</select>\n";
}
} else {
// XXX Should happen only if a filter was removed in a future version, e.g. rarely
// or between development releases.
echo "Unknown filter";
}
echo "</td>\n";
// Value for filter
echo "<td>";
switch ($filter['type']) {
case 'num_eq':
case 'num_neq':
if ($filter['field_name'] == 'id_author') {
$name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
// XXX make this a function
$q = "SELECT * FROM lcm_author WHERE status IN ('admin', 'normal', 'external')";
$result_author = lcm_query($q);
echo "<select name='{$name}'>\n";
echo "<option value=''>...</option>\n";
// TRAD
while ($author = lcm_fetch_array($result_author)) {
// Check for already submitted value
$sel = $filter['value'] == $author['id_author'] || $_REQUEST['filter_val' . $filter['id_filter']] == $author['id_author'] ? ' selected="selected"' : '';
echo "<option value='" . $author['id_author'] . "'" . $sel . ">" . $author['id_author'] . " : " . get_person_name($author) . "</option>\n";
}
echo "</select>\n";
break;
}
case 'num_lt':
case 'num_gt':
$name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
echo '<input style="width: 99%;" type="text" name="' . $name . '" value="' . $filter['value'] . '" />';
break;
case 'date_eq':
case 'date_lt':
case 'date_le':
case 'date_gt':
case 'date_ge':
$name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
echo get_date_inputs($name, $filter['value']);
// FIXME
break;
case 'date_in':
// date_in has two values, stored ex: 2005-01-01 00:00:00;2006-02-02 00:00:00
$name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
$values = split(";", $filter['value']);
echo get_date_inputs($name . '_start', $values[0]);
echo "<br />\n";
echo get_date_inputs($name . '_end', $values[1]);
//.........这里部分代码省略.........
示例10: intval
}
$_SESSION['form_data']['id_org'] = intval(_session('id_org', 0));
$ref_upd_org = 'edit_org.php?org=' . _session('id_org');
if ($_SERVER['HTTP_REFERER']) {
$ref_upd_org = $_SERVER['HTTP_REFERER'];
}
//
// Update data
//
$obj_org = new LcmOrg(_session('id_org'));
$errs = $obj_org->save();
if (count($errs)) {
$_SESSION['errors'] = array_merge($_SESSION['errors'], $errs);
lcm_header("Location: " . $ref_upd_org);
exit;
}
//
// Attach to case
//
if (_session('attach_case')) {
lcm_query("INSERT INTO lcm_case_client_org\n\t\t\t\tSET id_case = " . _session('attach_case') . ",\n\t\t\t\t\tid_org = " . $obj_org->getDataInt('id_org'));
}
//
// Go to the 'view details' page of the organisation
//
// small reminder, if the client was created from the "add client to case" (Case details)
$attach = "";
if (_session('attach_case')) {
$attach = "&attach_case=" . _session('attach_case');
}
lcm_header('Location: org_det.php?org=' . $obj_org->getDataInt('id_org', '__ASSERT__') . $attach);
示例11: _request
$q2 .= ',' . $row['id_client'];
}
$q2 .= ')';
// Add search criteria if any
$find_client_string = _request('find_client_string');
if (strlen($find_client_string) > 1) {
$q2 .= " AND ((name_first LIKE '%{$find_client_string}%')" . " OR (name_middle LIKE '%{$find_client_string}%')" . " OR (name_last LIKE '%{$find_client_string}%'))";
}
$q2 .= ")";
// Sort client by name_first
$order_name = 'ASC';
if (_request('order_name') == 'ASC' || _request('order_name') == 'DESC') {
$order_name = _request('order_name');
}
$q2 .= " ORDER BY name_first " . $order_name;
$result = lcm_query($q2);
lcm_page_start(_T('title_case_add_client'));
show_context_start();
show_context_case_title($case);
show_context_case_involving($case);
show_context_end();
// Get the number of rows in the result
$number_of_rows = lcm_num_rows($result);
// Check for correct start position of the list
$list_pos = intval(_request('list_pos', 0));
if ($list_pos >= $number_of_rows) {
$list_pos = 0;
}
// Position to the page info start
if ($list_pos > 0) {
if (!lcm_data_seek($result, $list_pos)) {
示例12: show_all_errors
// Show the errors (if any)
echo show_all_errors();
if ($attach_client || $attach_org) {
show_context_start();
}
if ($attach_client) {
$query = "SELECT id_client, name_first, name_middle, name_last\n\t\t\t\tFROM lcm_client\n\t\t\t\tWHERE id_client = " . $attach_client;
$result = lcm_query($query);
while ($row = lcm_fetch_array($result)) {
// should be only once
echo '<li style="list-style-type: none;">' . _Ti('fu_input_involving_clients') . get_person_name($row) . "</li>\n";
}
}
if ($attach_org) {
$query = "SELECT id_org, name\n\t\t\t\tFROM lcm_org\n\t\t\t\tWHERE id_org = " . $attach_org;
$result = lcm_query($query);
while ($row = lcm_fetch_array($result)) {
// should be only once
echo '<li style="list-style-type: none;">' . _Ti('fu_input_involving_clients') . $row['name'] . "</li>\n";
}
}
if ($attach_client || $attach_org) {
show_context_end();
}
// Start edit case form
echo '<form action="upd_case.php" method="post">' . "\n";
if (!$id_case) {
if ($attach_org) {
show_page_subtitle(_Th('title_org_view'), 'clients_intro');
$org = new LcmOrgInfoUI($attach_org);
$org->printGeneral(false);
示例13: save
function save()
{
$errors = $this->validate();
if (count($errors)) {
return $errors;
}
//
// Update record in database
//
$cl = "name_first = '" . clean_input($this->getDataString('name_first')) . "',\n\t\t\t name_middle = '" . clean_input($this->getDataString('name_middle')) . "',\n\t\t\t name_last = '" . clean_input($this->getDataString('name_last')) . "',\n\t\t\t gender = '" . clean_input($this->getDataString('gender')) . "',\n\t\t\t notes = '" . clean_input($this->getDataString('notes')) . "'";
// ,
if ($this->getDataString('date_birth')) {
$cl .= ", date_birth = '" . $this->getDataString('date_birth') . "'";
}
$cl .= ", citizen_number = '" . clean_input($this->getDataString('citizen_number')) . "'";
$cl .= ", civil_status = '" . clean_input($this->getDataString('civil_status')) . "'";
$cl .= ", income = '" . clean_input($this->getDataString('income')) . "'";
if ($this->getDataInt('id_client') > 0) {
$q = "UPDATE lcm_client\n\t\t\t\tSET date_update = NOW(), \n\t\t\t\t\t{$cl} \n\t\t\t\tWHERE id_client = " . $this->getDataInt('id_client', '__ASSERT__');
lcm_query($q);
} else {
$q = "INSERT INTO lcm_client\n\t\t\t\t\tSET date_creation = NOW(),\n\t\t\t\t\t\tdate_update = NOW(),\n\t\t\t\t\t\t{$cl}";
$result = lcm_query($q);
$this->data['id_client'] = lcm_insert_id('lcm_client', 'id_client');
}
// Keywords
update_keywords_request('client', $this->getDataInt('id_client'));
if ($_SESSION['errors']) {
$errors = array_merge($_SESSION['errors'], $errors);
}
// Insert/update client contacts
include_lcm('inc_contacts');
update_contacts_request('client', $this->getDataInt('id_client'));
if ($_SESSION['errors']) {
$errors = array_merge($_SESSION['errors'], $errors);
}
return $errors;
}
示例14: get_fu_description
function get_fu_description($item, $make_short = true)
{
if (!is_array($item)) {
lcm_debug("get_fu_description: parameter is not an array.");
return '';
}
global $prefs;
global $fu_desc_len;
// configure via my_options.php with $GLOBALS['fu_desc_len'] = NNN;
$short_description = '';
// Set the length of short followup title (was: wide = 48, narrow = 115)
$title_length = isset($fu_desc_len) && $fu_desc_len > 0 ? $fu_desc_len : 256;
if ($item['type'] == 'assignment' && is_numeric($item['description'])) {
$res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
$author1 = lcm_fetch_array($res1);
$short_description = _T('case_info_author_assigned', array('name' => get_person_name($author1)));
} elseif ($item['type'] == 'unassignment' && is_numeric($item['description'])) {
$res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
$author1 = lcm_fetch_array($res1);
$short_description = _T('case_info_author_unassigned', array('name' => get_person_name($author1)));
} elseif ($item['type'] == 'stage_change' || is_status_change($item['type'])) {
$tmp = lcm_unserialize($item['description']);
// for backward compatibility, make it optional
if ($item['case_stage']) {
$short_description = _Tkw('stage', $item['case_stage']);
}
if ($tmp['description']) {
$short_description .= " / " . $tmp['description'];
}
if ($tmp['result'] || $tmp['conclusion']) {
$short_description .= "\n" . _Ti('fu_input_conclusion');
}
if ($tmp['result']) {
$short_description .= _Tkw('_crimresults', $tmp['result']) . "/";
}
if ($tmp['conclusion']) {
$short_description .= _Tkw('conclusion', $tmp['conclusion']);
}
if ($tmp['sentence']) {
$short_description .= "\n" . _Ti('fu_input_sentence') . _Tkw('sentence', $tmp['sentence'], array('currency' => read_meta('currency')));
}
if ($tmp['sentence_val']) {
$short_description .= ": " . $tmp['sentence_val'];
}
} else {
if ($item['description']) {
if (!$make_short || strlen(lcm_utf8_decode($item['description'])) < $title_length) {
$short_description = $item['description'];
} else {
$short_description = substr($item['description'], 0, $title_length) . '...';
}
$short_description = clean_output($short_description);
} else {
$short_description = _T('fu_info_emptydesc');
}
}
$short_description = nl2br($short_description);
if (empty($short_description)) {
$short_description = _T('info_not_available');
}
return $short_description;
}
示例15: is_existing_contact
function is_existing_contact($type_person, $id = 0, $type_contact, $value)
{
// XXX FIXME TODO very temporary untill we solved this issue..
if ($type_contact == 'email') {
// $type_contact = 1;
// [AG] I assume that 'email' means any e-mail contact type
// If not, $type_contact should be set here to what 'email' means
$type_contact = array('email_main', 'email_alternate');
}
// else
// echo "Wrong get_contact_author type ($type_contact)";
$id = intval($id);
// $type_contact = intval($type_contact);
$value = clean_input($value);
$query = "SELECT id_contact\n\t\t\t\tFROM lcm_contact\n\t\t\t\tWHERE ((value = '{$value}')";
if ($type_person) {
$query .= " AND (type_person = '{$type_person}')";
}
if ($id) {
$query .= " AND (id_of_person = {$id})";
}
if ($type_contact) {
// [AG] Let's try this - we accept for $type_contact integer, string or array of integers or strings
// Thus we can specify more flexible searches
switch (gettype($type_contact)) {
case "string":
if ($type_contact[0] != '+') {
$type_contact = '+' . $type_contact;
}
$type_contact = get_contact_type_id($type_contact);
case "integer":
$query .= " AND (type_contact = {$type_contact})";
break;
case "array":
$qs = '';
foreach ($type_contact as $tc) {
if (gettype($tc) == 'string') {
if ($tc[0] != '+') {
$tc = '+' . $tc;
}
$tc = get_contact_type_id($tc);
}
$tc = intval($tc);
$qs .= ($qs ? ',' : '') . $tc;
}
$query .= " AND (type_contact IN ({$qs})";
break;
default:
lcm_panic("Wrong is_existing_contact type_contact ({$type_contact})");
}
}
$query .= ")";
$result = lcm_query($query);
return lcm_num_rows($result) > 0;
}