Ejemplo n.º 1
0
 function test_where_clause()
 {
     $this->assertEqual(where_clause('f1', 'v1'), "WHERE f1 = 'v1'");
     $this->assertEqual(where_clause('f1', 'v1', 'f2', 2), "WHERE f1 = 'v1' AND f2 = '2'");
     $this->assertEqual(where_clause('f1', 'v1', 'f2', 1.75, 'f3', 'v3'), "WHERE f1 = 'v1' AND f2 = '1.75' AND f3 = 'v3'");
     $this->assertEqual(where_clause('f1', NULL), "WHERE f1 IS NULL");
 }
Ejemplo n.º 2
0
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $CFG
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 */
function delete_records($table, $field1 = '', $value1 = '', $field2 = '', $value2 = '', $field3 = '', $value3 = '')
{
    global $db, $CFG;
    // Clear record_cache based on the parameters passed
    // (individual record or whole table)
    if ($CFG->rcache === true) {
        if ($field1 == 'id') {
            rcache_unset($table, $value1);
        } else {
            if ($field2 == 'id') {
                rcache_unset($table, $value2);
            } else {
                if ($field3 == 'id') {
                    rcache_unset($table, $value3);
                } else {
                    rcache_unset_table($table);
                }
            }
        }
    }
    if (defined('MDL_PERFDB')) {
        global $PERF;
        $PERF->dbqueries++;
    }
    $select = where_clause($field1, $value1, $field2, $value2, $field3, $value3);
    $sql = 'DELETE FROM ' . $CFG->prefix . $table . ' ' . $select;
    $rs = $db->Execute($sql);
    if (!$rs) {
        debugging($db->ErrorMsg() . '<br /><br />' . s($sql));
        if (!empty($CFG->dblogerror)) {
            $debug = array_shift(debug_backtrace());
            error_log("SQL " . $db->ErrorMsg() . " in {$debug['file']} on line {$debug['line']}. STATEMENT:  {$sql}");
        }
        return false;
    }
    return $rs;
}
Ejemplo n.º 3
0
/**
 * Delete the records from a table where all the given fields match the given values.
 *
 * @uses $CFG
 * @uses $db
 * @param string $table the table to delete from.
 * @param string $field1 the first field to check (optional).
 * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
 * @param string $field2 the second field to check (optional).
 * @param string $value2 the value field2 must have (requred if field2 is given, else optional).
 * @param string $field3 the third field to check (optional).
 * @param string $value3 the value field3 must have (requred if field3 is given, else optional).
 * @return mixed An ADODB RecordSet object with the results from the SQL call or false.
 */
function delete_records($table, $field1 = '', $value1 = '', $field2 = '', $value2 = '', $field3 = '', $value3 = '')
{
    global $db, $CFG;
    // Clear record_cache based on the parameters passed
    // (individual record or whole table)
    if ($CFG->rcache === true) {
        if ($field1 == 'id') {
            rcache_unset($table, $value1);
        } else {
            if ($field2 == 'id') {
                rcache_unset($table, $value2);
            } else {
                if ($field3 == 'id') {
                    rcache_unset($table, $value3);
                } else {
                    rcache_unset_table($table);
                }
            }
        }
    }
    if (defined('MDL_PERFDB')) {
        global $PERF;
        $PERF->dbqueries++;
    }
    $select = where_clause($field1, $value1, $field2, $value2, $field3, $value3);
    return $db->Execute('DELETE FROM ' . $CFG->prefix . $table . ' ' . $select);
}
Ejemplo n.º 4
0
     update_m_push($array_m_push_update, 'update');
     unset($array_m_push_update);
 }
 //DELETE RECORDS
 $delete_record_count = 0;
 lite_connect($_POST['sync_user']);
 $check_status_sql = "SELECT lite_patient_id, emr_patient_id, lite_specific_id, emr_specific_id, table_name, entry_date, sync_type FROM m_push_status WHERE push_flag ='Y' AND sync_type='D'";
 $delete_array = get_data_array($check_status_sql);
 //print_r($delete_array);
 if ($delete_array != NULL || $delete_array != '') {
     ehr_connect();
     $array_m_push_update = array();
     foreach ($delete_array as $del_array => $delete_value) {
         //print_r($delete_array);
         //echo "<br />";
         $delete_text = where_clause($delete_value);
         if ($delete_value[4] == 'm_patient_fp_method_service' || $delete_value[4] == 'm_patient_fp_obgyn' || $delete_value[4] == 'm_patient_fp_hx' || $delete_value[4] == 'm_consult_mc_postpartum' || $delete_value[4] == 'm_consult_mc_prenatal' || $delete_value[4] == 'm_consult_mc_services' || $delete_value[4] == 'm_consult_mc_vaccine' || $delete_value[4] == 'm_consult_ccdev_vaccine' || $delete_value[4] == 'm_consult_ccdev_services' || $delete_value[4] == 'm_consult_vaccine' || $delete_value[4] == 'm_consult_notes_complaint' || $delete_value[4] == 'm_consult_notes_dxclass') {
             $get_all_compare = mysql_query("SELECT * FROM {$delete_value['4']} WHERE {$delete_text}") or die("Error 200 : " . mysql_error());
             while ($get_all_result = mysql_fetch_array($get_all_compare)) {
                 switch ($delete_value[4]) {
                     case 'm_consult_mc_prenatal':
                         $spc_field = 'mc_id';
                         $field_to_find = 'visit_sequence';
                         $value_to_find = $get_all_result['visit_sequence'];
                         break;
                     case 'm_consult_mc_postpartum':
                         $spc_field = 'mc_id';
                         $field_to_find = 'visit_sequence';
                         $value_to_find = $get_all_result['visit_sequence'];
                         break;
                     case 'm_consult_ccdev_vaccine':
Ejemplo n.º 5
0
    }
    if ($operator == STARTSWITH) {
        $where_clause = "(" . $field . " LIKE '%" . $string . "')";
    }
    if ($operator == ISANYOF) {
    }
    if ($operator == ISALLOF) {
    }
    return $where_clause;
}
if ($HTTP_POST_VARS["hdn_search"]) {
    $where_clause = "";
    $and_flag = FALSE;
    if (strlen($HTTP_POST_VARS["txt_srch_doc_name"]) > 2) {
        $where_clause .= "(";
        $where_clause .= where_clause($HTTP_POST_VARS["slct_srch_doc_name"], $xoopsDB->prefix("dms_objects") . ".obj_name", $HTTP_POST_VARS["txt_srch_doc_name"]);
        $where_clause .= ")";
        $and_flag = TRUE;
    }
    if (strlen($HTTP_POST_VARS["txt_srch_doc_owner"]) > 2) {
        if ($and_flag == TRUE) {
            $where_clause .= " AND ";
        }
        $where_clause .= "(";
        $where_clause .= ")";
        $and_flag = TRUE;
    }
    if (strlen($HTTP_POST_VARS["txt_srch_descript"]) > 2) {
        if ($and_flag == TRUE) {
            $where_clause .= " AND ";
        }