Welcome Guest, Not a member yet? Register   Sign In
Problem with table
#1

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->start_cache();
                  
$player->select('p.name, p.job, p.level, pindex.empire, p.exp');
                  
$player->from('player AS p');
                  
$player->join('player_index AS pindex''p.account_id = pindex.id''INNER');
                  
$player->not_like('p.name','[');
                  
$player->order_by('p.level DESC, p.exp DESC'); 
                  
$player->stop_cache();
                  
$query $player->get();
                  
$query_ultimate $query->result_array();
                  return 
$query_ultimate;
        } 
Code:
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.
Reply
#2

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
Reply
#3

Hi,

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.
Reply
#4

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?
Reply
#5

(This post was last modified: 05-04-2015, 08:04 AM by StratoKyke.)

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;
Reply
#6

This is a guess, but the following does not match what you have in your PHP code:
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.
Reply
#7

(This post was last modified: 05-05-2015, 01:54 AM by StratoKyke.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB