Welcome Guest, Not a member yet? Register   Sign In
Incorrect SQL Query Result with Active Record
#21

[eluser]MattHirschfelt[/eluser]
I'm using CI 2.1.0.

I'm stripslashing the output, but that's it.

This is the flow of data:

Model:
Code:
function list_hephs()
{
  return $query = $this->db->from('planets')->like('slot', 'h')->order_by('timeupdated', 'desc')->limit(25)->get();
}

Controller:
Code:
$data['list_hephs']= $this->Index_model->list_hephs();
$this->load->view('uni_index', $data);

View:
Code:
<?php foreach($list_hephs->result() as $hephs):?>
<?=stripslashes($hephs->player)?>
<?php endforeach ?>

#22

[eluser]Aken[/eluser]
That shouldn't affect it either. I'm not sure then. There might've been a bug that has been fixed in the development repository already, or something else is changing your charset along the lines.
#23

[eluser]weboap[/eluser]
if you are using phpMyAdmin or similar check that the table where the data is is "utf8_unicode_ci" then after your config, and i guess you followed http://philsturgeon.co.uk/blog/2009/08/u...odeigniter
reenter a record or 2 and re-run your query and check your eg : Cpt.John.Sheridan ✫✫✫
as@Aken said the AR don't affect the content of your db, it will escape them in the entry insert/update but that's it not output.
#24

[eluser]MattHirschfelt[/eluser]
I've confirmed that all of my tables are set correctly, that all of my CI settings are correct, and yet I still have an issue displaying UTF-8 characters through CI, but not when accessing the database through other methods.
#25

[eluser]Aken[/eluser]
When something isn't working properly, start with the bare minimum and go from there. Try creating a page that has a blank HTML page with the proper charset, and pass it some of the database items with UTF-8 characters in it. If it works, then you know it's elsewhere in your code. If not, then it might be a bug that was fixed in CodeIgniter (kinda doubtful since UTF-8 is really important - it would've been addressed quickly a while ago).

Remember, things like autoloading, template systems, and more can affect output. Again, start REALLY SIMPLE.
#26

[eluser]InsiteFX[/eluser]
phpMyAdmin

You can not just check the table for utf8, you also need to make sure the database collation is set
to utf8_unicode_ci

1) phpMyAdmin, click on your database
2) Click on the operations tab and it should show you the database collation which is different from
the table collation!

If it is set correct then you can try this!
Code:
$this->db->query("SET NAMES utf8");

NOTE: If you change the collation if it is wrong it could corrupt your table and you would need to re-create it!




Theme © iAndrew 2016 - Forum software by © MyBB