function get_value_with_referenced() { $final_value = null; $this_type = get_class($this); $sql = "select ".str_replace("_prop","_val",strtolower($this_type))." from ". strtolower($this_type)." where prop_id = ".$this->my_prop_id." and ent_prop_id = ".$this->my_ent_prop_id; $result = mysql_query($sql); if (mysql_num_rows($result)==0) return ""; $value = mysql_result($result,0); if (ClientServerDataOps::has_lookup_table($this->my_prop_id) && !empty($value)) { $final_value = ClientServerDataOps::get_value_by_id($value,$this->my_prop_id); } else { $final_value = $value; } return $final_value; }
function search_and_gather_eids($ctns_prop_ids, $ctns_prop_vals, $ctns_prop_vals_exact_match, $ctns_prop_vals_inverse_match, $prop_ids, $prop_vals, $type_id, $sort_prop_ids, $prop_comps, $type_ids, $group_nums, $ctns_prop_types) { //print_r(func_get_args()); //$debug_time = ""; $fin_eids = array(); $filt_eids = null; $all_filts_any = true; //$debug_time .= microtime().'entering search_and_gather_eids<br>'; //filter by set //Currently assumes ORing of match properties, need to do as below for text search! for ($i = 0; $i < count($prop_ids); $i++) { //echo '-- $search_prop_id'.$prop_ids[$i]." searchpropval: ".$prop_vals[$i]." , typeid: ".$type_id; $search_prop_val = $prop_vals[$i]; $search_prop_id = $prop_ids[$i]; $search_prop_comp = $prop_comps[$i]; //note: if using comparison function, must include spc[] post variable for all prop_ids $group_num = $group_nums[$i]; if (count($type_ids) > 0) { $_type_id = $type_ids[$i]; } else { $_type_id = $type_id; } if ($search_prop_val == 0 && strlen($search_prop_comp) == 0) { //echo '<br>$search_prop_val:'.$search_prop_val; continue; } else { $all_filts_any = false; } // $eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $type_id); if (strlen($search_prop_val) == 0) { $eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $_type_id); } else { $eids = RecordsSys_EntityManagementSystems::get_eids($search_prop_val, $search_prop_id, $_type_id, $search_prop_comp); } $arr2 = array(); foreach ($eids as $eid) { array_push($arr2, $eid); } if ($group_num) { if (!isset($filt_eids)) { $filt_eids = $arr2; } else { $filt_eids = array_unique(array_merge($filt_eids, $arr2)); } } else { if (!isset($filt_eids)) { //echo "search_prop_val: ".$search_prop_val." -- search_prop_id: " . $search_prop_id." filt_eids: " . print_r($filt_eids,true).", arr2: " . print_r($arr2, true)."<br>"; $filt_eids = $arr2; } else { $filt_eids = array_intersect($filt_eids, $arr2); } } } //echo "<br>all filters any? ".$all_filts_any." or the filteids:". print_r($filt_eids,true); //intersect with Contains search //echo count($ctns_prop_ids)."yo".print_r($ctns_prop_ids,true); if (empty($ctns_prop_ids) or count($ctns_prop_ids) == 0) { // echo '<br>;starting contains search. $all_filts_any: '.$all_filts_any.', $ctns_prop_ids: '.print_r($ctns_prop_ids,true); // .'; count($cnts_prop_ids)'.count($ctns_prop_ids); $fin_eids = $filt_eids; // echo 'n4ello'.print_r($fin_eids,true); } else { //$debug_time .= microtime().' starting contains filter'.print_r($fin_eids,true)."<br>"; for ($i = 0; $i < count($ctns_prop_ids); $i++) { $search_prop_val = count($ctns_prop_vals) > 1 ? $ctns_prop_vals[$i] : $ctns_prop_vals[0]; $search_prop_val_exact_match = count($ctns_prop_vals_exact_match) > 1 ? $ctns_prop_vals_exact_match[$i] : $ctns_prop_vals_exact_match[0]; //not sure if this will work with more than one ctnse, need to test $search_prop_val_inverse_match = count($ctns_prop_vals_inverse_match) > 1 ? $ctns_prop_vals_inverse_match[$i] : $ctns_prop_vals_inverse_match[0]; //not sure if this will work with more than one ctnse, need to test //echo "heeeelo".$search_prop_val_exact_match."end"; $search_prop_val = trim($search_prop_val); $search_prop_id = $ctns_prop_ids[$i]; $ctns_prop_type = empty($ctns_prop_types[$i]) ? $type_id : $ctns_prop_types[$i]; //echo " <br>the ctns_prop_types[i]: ".$ctns_prop_types[$i]; //echo "<br>SEARCH COUNT for $search_prop_val :". count($eids)."<br>"; if ($search_prop_id == "by_eid") { $eids = empty($search_prop_val) ? array() : array($search_prop_val); } elseif ($search_prop_val_exact_match) { //echo "BLOWBLOWBLOWBLWO".$search_prop_val_exact_match; //$eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $type_id); $eids = RecordsSys_EntityManagementSystems::get_eids($search_prop_val, $search_prop_id, $_type_id, $search_prop_comp); } else { //echo "<br>IN CONTAINS SEARCH!!$search_prop_val, $search_prop_id, $ctns_prop_type<BR>".empty($search_prop_val)."yo"; $eids = RecordsSys_EntityManagementSystems::get_eids_by_prop_contains_search($search_prop_val, $search_prop_id, $ctns_prop_type); //echo "<BR>result eids: ".print_r($eids,true); } if ($search_prop_val_inverse_match) { $data_type = "varchar"; if ($ctns_prop_type == 3) { $type_category = "user"; } else { $type_category = "product"; } //echo $ctns_prop_type."type? ".$type_id; $all_product_eids = RecordsSys_EntityManagementSystems::get_all_eids_by_type_category_and_datatype($data_type, $type_category, $ctns_prop_type); $eids = array_diff($all_product_eids, $eids); } //echo "<br>HERE variables: eid: $eid, fin_eids: ".print_r($fin_eids,true).", filt_eids: ".print_r($filt_eids,true)." all_filts_any: $all_filts_any, "; foreach ($eids as $eid) { if (!in_array($eid, $fin_eids) && ($all_filts_any || in_array($eid, $filt_eids))) { //echo "<br>pusing eid: ".$eid; array_push($fin_eids, $eid); } } } } //echo "<BR>COUNT OF FINEIDS:".count($fin_eids)."<br>"; //$debug_time .= microtime().' starting sort'."<br>"; //Currently assumes only 1 property to sort by if ($sort_prop_ids[0] == 0) { $sort_prop_ids[0] = 1; //customer wants sort by name by default } if ($sort_prop_ids[0] != 0 && count($fin_eids) > 0) { //get prop values for final eid set; do asort $sorted_eids = array(); $desc = 0; //NOTE: sorting also takes place below for lookuptable values $eidsvalshash = RecordsSys_EntityManagementSystems::get_eids_values_hash($fin_eids, $sort_prop_ids[0], $type_id, $desc); //can't do page offset/limit filter here because there may be duplicate eids $prop_id = $sort_prop_ids[0]; if (ClientServerDataOps::has_lookup_table($prop_id)) { foreach ($eidsvalshash as $eid => $val) { $newval = ClientServerDataOps::get_value_by_id($val, $prop_id); $eidsvalshash[$eid] = $newval; } asort($eidsvalshash); } foreach ($eidsvalshash as $eid => $val) { if (!in_array($eid, $sorted_eids)) { array_push($sorted_eids, $eid); } } //any for which entity doesn't have set property, on which this function sorts -- means no match goes after all the matches foreach ($fin_eids as $eid) { if (!in_array($eid, $sorted_eids)) { array_push($sorted_eids, $eid); } } $fin_eids = $sorted_eids; } //$debug_time .= microtime().' end of search and gather eids'.print_r($fin_eids,true)."<br>"; //echo $debug_time; //echo 'hello'.print_r($fin_eids,true); return $fin_eids; }