Database listing delays

时间:2019-04-16 23:22:24

标签: php mysql sql phpmyadmin

I am having issues with below code which display the news added in the database after few hours, the news is added straight away in the database once created and not sure if i need to make any changes in below code so it fetches the updated

    $query="SELECT *
                FROM
                    (
                    SELECT id,ext,database_id
                    FROM images
                    WHERE database_name='news' AND database_id IN(" . implode(',',array_keys($news)) . ")
                    ORDER BY role
                    ) AS images
                GROUP BY database_id";

2 个答案:

答案 0 :(得分:0)

I don't see anything wrong with the script. However, there are few things you might want to consider:

  1. Short tags are not recommended. Are PHP short tags acceptable to use?

  2. Using @ suppresses the warnings. You can disable error reporting instead of suppressing the warnings.

  3. Using mysql isn't recommended. Please use mysqli instead. When should I use MySQLi instead of MySQL?

答案 1 :(得分:0)

This query makes no sense:

SELECT i.*
FROM (SELECT id, ext, database_id
      FROM images
      WHERE database_name = 'news' AND
            database_id IN (" . implode(',',array_keys($news)) . ")
      ORDER BY role
     ) i
GROUP BY i.database_id;

You are aggregating by database_id, but using select *. MySQL is hopefully returning an error related to the group by.

So, you should provide sample data, desired results, and an explanation of what you want to accomplish.