CodeIgniter Forums

Full Version: Problem with table
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm here to ask you some questions.

1. I created a small "classification" and the query is as follows.
PHP Code:
public function players() {
$player $this->load->database('player'TRUE);
$player->select(', p.job, p.level, pindex.empire, p.exp');
$player->from('player AS p');
$player->join('player_index AS pindex''p.account_id =''INNER');
$player->order_by('p.level DESC, p.exp DESC'); 
$query $player->get();
$query_ultimate $query->result_array();
SELECT `p`.`name`, `p`.`job`, `p`.`level`, `pindex`.`empire`, `p`.`exp` FROM `player` AS `p` INNER JOIN `player_index` AS `pindex` ON `p`.`account_id` = `pindex`.`id` WHERE `p`.`name` NOT LIKE '%[%' ESCAPE '!' ORDER BY `p`.`level` DESC, `p`.`exp` DESC
The problem is that the result of this table and the result of the same query over phpmyadmin gives me different results. It states that there are many users with the same level and same exp.
I am sure that the ranking that I ripota phpmyadmin is right.
How can I fix?

2. If I wanted to make sure that they print the line number of the table? How can I do? my intent is to have them printed and once you use a search field to me is given the line on the field sought by the position relative to the ranking.

Thanks for the support.
I'm trying understand your problem

1. Your query using active record doesn't show right data what you want, my suggest just use db->query ("put your query here");

and the second problem i didn't get your point, CMIIW

For your first problem. In your code you are using database caching. Did you try to clear the cache before you compared the CI results with the results of the same query in phpmyadmin? If the player table is rapidly changing, maybe for the sake of debugging it's best to turn of caching for a bit. 

Second problem need some more explaining, I don't quite understand what you want to achieve.
1. It is sure cache of query? Smile I try to delete the part of query caching but It does not work. This afternoon I try to clear cache.
2. I can insert the autoincrement number in the table, It is possible using the pagination class?
1. I turned off the cache and I clean. But the result is always different from what I phpmyadmin. I also tried to change the values in the database table and codeigniter respects the logic of the query that launch. But not the exact results of phpmyadmin.

EDIT: I tried to change method and utilize freddy's method but the result is the same. In essence. If I have different values to the table it responds properly. If I have all values equal the result of phpmyadmin it is different from that of codeigniter.

EDIT2: If i remove the order by both in phpmyadmin that in CI the result is equal. As I said, the problem is only with the database entries that have the same parameters of order by. What can be the reason?

EDIT3: I fix the problem with pagination class. it was enough to implement the layout of the table is the problem is solved.

For the second point, I implemented the layout easily. But I would understand if there is an internal function that allows for example to show 25 new results on each page. Or should I use the operations for create a method for the offset?

EDIT4: Fix problem pagination which this operation: $offset = (($offset-1) * $config["per_page"])+1;
This is a guess, but the following does not match what you have in your PHP code:
WHERE `p`.`name` NOT LIKE '%[%' ESCAPE '!'

The escape clause isn't supported by query builder, so you're going to have to use $this->db->query() if the escape clause is required to get the right results.
The escape comes generated from codeigniter. Smile I do not I might add that in the query launch of phpmyadmin.

EDIT: I fix the problem yesterday Smile Thanks for the support.