Welcome Guest, Not a member yet? Register   Sign In
Fields not returned to Active Record query()
#1

[eluser]peredurabefrog[/eluser]
Hi,

I'm presenting a query to my database (MySQL) as follows, using Active Record in CI 2.0:

Code:
$query = $this->db->query(
"select numid,
        TRIM(alphaid) AS alphaid,
        TRIM(text_en) AS text_en,
        TRIM(text_cy) AS text_cy,
        repealed,
        applies_to_wales
from    lawcontents
where   idlaws = '$the_law'
and     `type` = '$fragment_type'
and     parent_type IS NULL
order by numid, alphaid"
);

In my test case, the value for $the_law = '656' and the value for $fragment_type is 'part'.

If I run the query with these values against the database directly I get 4 rows returned each of which has NULL for the 'alphaid' field, 0 for the 'repealed' field and 1 for the 'applies_to_wales' field.

When I run the query using Active Record in CI, the field 'alphaid' is not returned in the result object, and the values for 'repealed and 'applies_to_wales' are always NULL.

I've stared at this for ages trying to see what I'm doing wrong, but with no luck. Is there anyone out there who can put me out of my misery?

Cheers


Peredur
#2

[eluser]peredurabefrog[/eluser]
SOLVED!

The fields in question were bit fields (indicating TRUE/FALSE). I changed them to be INT fields and all was well.

Is this the correct behaviour (that bit field values appear to be returned as empty)?

Cheers


Peredur




Theme © iAndrew 2016 - Forum software by © MyBB