How to relationship and where condition with table in views_query_alter

[Dru]

Below code is perfect to add relationship and where condition

$join = new views_join(); $join->table = 'users_roles'; $join->field = 'uid'; $join->left_table = 'node'; $join->left_field = 'uid'; $join->type = 'left'; $query->add_relationship('users_roles', $join, 'node'); $query->add_where(1,'users_roles.rid','4' ,'=');

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: