topplayer
Forum Replies Created
-
Forum: Plugins
In reply to: [Football Pool] Ranking blankThank you for your response
you gave me an idea whit your aswer about how mysql treats empty values (‘ ‘ ) in the DATETIME columns and I remembered that mysql allows to switch beetwen models to be permisive for certain things like empty values o zero divicion.
So, first check the current mode with this query:
SELECT @@sql_mode;
in my case I got:
sql_mode – ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIONFor my purpose I had to allow empty values on the date, so I had to disable the restrictions:
NO_ZERO_IN_DATE
NO_ZERO_DATEto deactivate them you only need to run(root user) the query and remove them:
SET GLOBAL sql_mode = ‘ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;Now, mysql acepts zero but no empty ”;
so fill whit zero date in the parts of the plugin you need, in my case just modify this function:public function get_ranking_from_score_history(
$league,
$ranking_id = FOOTBALLPOOL_RANKING_DEFAULT,
$score_date = ‘0000-00-00 00:00:00’ ) {
global $wpdb;
$prefix = FOOTBALLPOOL_DB_PREFIX;$date_switch = ( $score_date == ‘0000-00-00 00:00:00’ ) ? ‘1 = 1 OR ‘ : ”;
$league_switch = ( $league <= FOOTBALLPOOL_LEAGUE_ALL ) ? ‘1 = 1 OR’ : ” ;Thats it.
I hope it helps for those who have the same problem.
I have MySQL version: 8.0.18 – MySQL Community Server – GPL.
recomend check the oficcial Documentation
https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-settingThanks for amazing code dear @antoineh
Forum: Plugins
In reply to: [Football Pool] Change layouthi friends
I got this error for my ranking page (debug on)Incorrect DATETIME value: ”
and the query
SELECT s.ranking, u.ID AS user_id, u.display_name AS user_name, u.user_email AS email , s.total_score AS points, s.score AS last_score , lu.league_id FROM pool_wp_scorehistory_s1_t1 AS s JOIN ( SELECT user_id, MAX( score_order ) AS last_row FROM pool_wp_scorehistory_s1_t1 WHERE ranking_id = 1 AND ( 1 = 1 OR score_date <= ” ) GROUP BY user_id ) AS s2 ON ( s2.user_id = s.user_id AND s2.last_row = s.score_order ) JOIN wp_users u ON ( u.ID = s.user_id )INNER JOIN pool_wp_league_users lu ON ( u.ID = lu.user_id AND ( 1 = 1 OR lu.league_id = 0 ) ) INNER JOIN pool_wp_leagues l ON ( lu.league_id = l.id ) WHERE s.ranking_id = 1 AND ( 1 = 1 OR score_date <= ” ) ORDER BY s.ranking ASC
whats is wrong whit me time o field?