Welcome Guest, Not a member yet? Register   Sign In
Cannot test if a field is empty or not
#4

[eluser]toopay[/eluser]
I assume, that you are trying to find a single row of data, with specific keywords.

First, on your Model change to this
Code:
function recherche($critere)
{
this->db->select('COTE, TITRE, EDITEURS, RESUME, DESCRIPTEURS, MOTSCLES, DIVERS');
$this->db->from ('catalogue_dvd');
this->db->like ('TITRE',$critere);
$this->db->or_like ('EDITEURS',$critere);
$this->db->or_like ('RESUME',$critere);
$this->db->or_like ('DESCRIPTEURS',$critere);
this->db->or_like ('MOTSCLES',$critere);
$this->db->or_like ('DIVERS',$critere);
$result = $query->result_array();
//if there are a match result, bring first row. Else, Null
return (count($result) > 0 ? $result[0] : NULL);
}
Now, you can test if a field is empty or not, on your Controller like this
Code:
//I assume, in this stage, that your model class have properly loaded
$resultats = $this->catalogue_model->recherche($critere);

if(is_null($resultats))
{
//if there are no result, give a warning
echo "No result for'" . $critere . "'. Try another criteria!" ;
}
else
{
//if there are 1 result, test it
  $data=array();
  $data['resultats']=$resultats['DIVERS'];
    if ($data['resultats']=='')
        {
            echo "Divers empty<br />";
    }else{
            echo "Divers not empty<br />";
    }
}
}

Let me know, if it work for you...
Btw, i think maybe next time you should post your question at proper forum, because this is Bug Report section i believe.


Messages In This Thread
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 04:59 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 05:49 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 07:55 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 09:03 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 09:06 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 02:47 PM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:09 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:14 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:17 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:21 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:37 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:52 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 05:00 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB