[eluser]skunkbad[/eluser]
[quote author="d1a8lo24" date="1303640706"]Not sure what is wrong and everyone has their own way of coding or writing their sql syntax. but try the following it might work.
Code:
// One line
$query = $this->db->select('something')->where('some_name', $name)->limit(1)->get('some_table');
// Or call it in segments
$this->db->select('something');
$this->db->where('some_name', $name);
$this->db->limit(1);
$query = $this->db->get('some_table');
// then do your if statement
if ($query->num_rows() == 1)
{
// do something
}
Now on your code your calling the get query twice?
It should look like the following but then again like I said we all have our own way of coding.
Code:
public function get_field_from_other( $name )
{
// query database for readable name
$sql = 'SELECT `some-field`
FROM `some-table`
WHERE `other-field` = ?
LIMIT 1';
$query = $this->db->query( $sql, array( $name ) );
if ( $query->num_rows() == 1 )
{
$row = $query->row_array();
return $row['some-field'];
}
}
[/quote]
YOU'RE RIGHT!!! Thanks. I was calling ->query() twice...