"Unable to resolve column" inspection error in WordPress project

Hello,

I had this error `Unable to resolve column` from the inspection tool. I found this post on how to map my project to the correct schema.  So I have a SQL query like the one below where I get the error on all the columns `user_id` and `post_id`.

"SELECT user_id FROM {$wpdb->prefix}pp_completed_activity  WHERE user_id = $user_id AND post_id = $post_id"

`$wpdb->prefix` is a prefix for each SQL table. It is something quite common in WordPress and it is the recommended way to make SQL queries. The mapping is working because If i change the name of the table from `{$wpdb->prefix}pp_completed_activity` to the full table name `wp_pp_completed_activity` (where $wpdb->prefix is actually 'wp_'), the error is removed. So the problems seems to be that the inspector could not get the correct name of the database table.

Is there any way to solve this?

PS: (I run PhpStorm 2019.3)

Thank you.

0

Unfortunately, no way to solve that currently. Please vote: https://youtrack.jetbrains.com/issue/WI-20802

1

Thank you Eugene, I have added my vote to this. It will really make a difference in our coding experience with PHPStorm.

Cheers.

0

Hi

 

I also voted for this (came across this problem too).

0

请先登录再写评论。