[eluser]jppi_Stu[/eluser]
I'm trying to understand something...
I have a tinyint column in a MySQL table, I'll refer to it as "is_something" for the code shown below. I'm using Active Record in a model to select from that table:
Code:
function item_detail ($item_id)
{
$query = $this->db->get_where('items',array('item_id' => $item_id));
return ($query->result());
}
This is being called by a controller and being passed to a view:
Code:
$query = $this->Item_model->item_detail($item_id);
$data['this_item'] = $query[0];
$this->load->view('item_edit_v.php', $data);
In the view, I want to do some basic customization of what the user will see based on the is_something field. The field will either be a 0 or a 1. I want to generate some HTML if it is 0. However, despite it coming from a tinyint column, I have to compare it against a string. For example:
Code:
$some_html = ($this_item->is_something === 0) ? 'is zero' : 'is not zero';
# $some_html will be set to 'is not zero'
$other_html = ($this_item->is_something === '0') ? 'is character zero' : 'is not character zero';
# $other_html will be set to 'is character zero'
This is probably something obvious, and possibly not specific to CI, but I'm not getting it. Why does the tinyint value become a string value?