Welcome Guest, Not a member yet? Register   Sign In
humble search through tables
#1

[eluser]CI&AI[/eluser]
I am piercing my brain in agony trying to figure out the following. I have a set of 4 tables bound to 1 reference id - and need to search/filter out the requests for a realestate agent.

My code below:
/*
*
* column fields
* //property
* | pr_refno
* | pr_no
* | pr_category
* | pr_type
* | pr_status
* | pr_no_rooms
* | pr_no_bedrooms
* //country
* | pr_country
* | pr_city
* //price
* | pr_price
* | sell_currency
* | pr_rent_price
* | rent_currency
* | pr_refno, pr_no, pr_category, pr_type, pr_status, pr_rooms, pr_bedrooms
* form names
* | location
* | min
* | max
* | SetCurr
* | type
* | rooms
* | bedrooms
*
*/
$pt = $this->input->post('ptype');
$t = $this->input->post('type');
$r = $this->input->post('rooms');
$b = $this->input->post('bedrooms');
$l = $this->input->post('location');
$mn = $this->input->post('min');
$mx = $this->input->post('max');

if($mn < 1 || $mn == NULL)
{
$mn = 0;
}
if($mx < 1 || $mx == NULL)
{
$mx = 12000000;
}

if($r < 1 || $r == NULL)
{
$r = 1;
}
if($b < 1 || $b == NULL)
{
$b = 1;
}

$this->db->select('*');
$this->db->from('property');
$this->db->where('pr_category',$pt );
$this->db->where('pr_type', $t);
$this->db->where('pr_status', 'a');
$this->db->having('pr_no_rooms >', $r);
$this->db->having('pr_no_bedrooms >', $b);

$this->db->join('property_features', 'property_features.pr_no = property.pr_no', 'left');
$this->db->join('property_financial', 'property_financial.pr_no = property.pr_no', 'left');
$this->db->join('property_location', 'property_location.pr_no = property.pr_no', 'left');

$this->db->like('pr_country', $l );

if ($this->input->post('type')=='r'):
$this->db->or_where('property_financial.pr_rent_price BETWEEN '.$mx.' AND '.$mn);
else:
$this->db->or_where('property_financial.pr_price BETWEEN '.$mx.' AND '.$mn);
endif;

$result = $this->db->get();
$c = $this->db->count_all('property');

if($result->num_rows > 0 && $result->num_rows < $c)
{
foreach( $result->result() as $row )
{
$this->found .= $row->pr_no.',';
}
}
return $this->found;
}

function indexer($num, $offset)
{
$this->multitable();
$this->db->join('property_financial', 'property_financial.pr_no = property.pr_no');
$this->db->join('property_location','property_location.pr_no = property_financial.pr_no');
$this->db->where_in('property.pr_no',$this->found);
return $this->db->get('property', $num, $offset);
}


This is build in a model called AxionSearch.php. I am using CI2.02 and active record but this ghost script has been tormenting me the last few weeks...if any one has an idea how to get results from the db returning the selected data requested in function indexer...I am ALL ears and eyes.

Thank you...
#2

[eluser]CI&AI[/eluser]
Admin could you move this post to the correct forum section. I posted on the wrong section....




Theme © iAndrew 2016 - Forum software by © MyBB