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

[eluser]Matalina[/eluser]
Code:
$query = $this-db->select('*')->from('planets')->group_by('player')->get();
$results = $query->num_rows();

You forgot get in your code.
#12

[eluser]weboap[/eluser]
sorry mat, but it cant be that 1000's of people are using AR with no prob. with larger and more complex databases than yours (...) and you alone can't get it right cuz the user guide.
do some more reading, google, read posts, write your queries manually and use ( $this->db->query() ) 1st, before to translate it to AR, then post your table structure, some dummy data , some code from your models and we will try and help.
we are not mind readers.

good luck
#13

[eluser]MattHirschfelt[/eluser]
I'm getting it all worked out. It's just frustrating for me since I've done the site in the flat file format already and it works well, but I want to try and learn this and I just don't seem to get the results I expect when I input things.

My next question is, can anyone tell me why it doesn't seem that UTF-8 characters are being displayed correct? For example Cpt.John.Sheridan ✫✫✫ is being displayed as Cpt.John.Sheridan ✫✫✫.

I double checked all the database.php settings to make sure they are set to UTF-8 and the collation is correct. I also checked in config.php to make sure it lists UTF-8 as the charset. Is there somewhere else I should be looking to make sure it is set correctly?
#14

[eluser]Matalina[/eluser]
is your database itself set to take utf-8 chars?
#15

[eluser]MattHirschfelt[/eluser]
Yes. The flat file version of the site pulling from the same database has no issues with the characters displaying correctly.
#16

[eluser]Matalina[/eluser]
Your html page set to utf-8?
#17

[eluser]MattHirschfelt[/eluser]
In the head of every page I have:
Code:
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">

In config.php I have:
Code:
$config['language'] = 'english';
$config['charset'] = 'UTF-8';

In database.php:
Code:
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_unicode_ci';

#18

[eluser]Aken[/eluser]
Remember you're not required to use active record if you don't need it.

And your HTML charset is wrong.

Code:
// HTML 4:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

// HTML 5:
<meta charset="utf-8">
#19

[eluser]MattHirschfelt[/eluser]
If I don't try to learn active record, I'll never learn it. It seems to be cooperating more now.

However, changing the charset declaration in the head doesn't seem to make a difference. Could it be CI's sanitation of the data versus my flat file version just printing the data from the database?

Page in question can be found at http://sde.openparser.info/.
#20

[eluser]Aken[/eluser]
Up to you. Active record can be handy, but isn't necessary and it has limitations.

What version of CI are you using? The DB class shouldn't do anything to UTF-8 characters to alter them. Are you modifying your database data in any way prior to outputting?




Theme © iAndrew 2016 - Forum software by © MyBB