2017-03-29 3 views
0

Codeigniter Code:Mysql, wenn der Wert gleich Bedingung

if(Property.Property_for == 1) 
$this->db->join('Property_sell','Property_sell.Property_id = Property.ID','left'); 
else 
$this->db->join('Property_rent','Property_rent.Property_id = Property.ID','left'); 

Wie kann ich Abfrage wie gegebenen Beispiel zu machen?

+1

Was möchten Sie tun? – Callombert

Antwort

0

Es sieht so aus, als ob Sie versuchen, die Join-Tabelle und die Spalte umzuschalten.

$table = 'rent'; 
if(Property.Property_for == 1) { 
    $table = 'sell'; 
} 
$tableColumn = sprintf('Property_%s', $table); 
$this->db->join($tableColumn, $tableColumn . '.Property_id = Property.ID','left'); 

Wenn dies nicht das ist, was Sie versuchen zu erreichen, bitte erweitern Sie Ihre Frage.