I am trying query
$result = GroupList::where([
['messagesV2.id', '>=', 'lastseen'],
['group_lists.user_id', $userID,],
])
->join('conversationsV2', 'group_lists.conversationsV2_id', '=', 'conversationsV2.id')
->join('messagesV2', 'conversationsV2.id', '=', 'messagesV2.conversationsV2_id')
->get();
it gives 3 rows
but when i run this on phpmyadmin it gives 1 row (which is correct)
select * from `group_lists` inner join `conversationsV2` on
`group_lists`.`conversationsV2_id` = `conversationsV2`.`id` inner join
`messagesV2` on `conversationsV2`.`id` =
`messagesV2`.`conversationsV2_id` where (`messagesV2`.`id` >= lastseen
and `group_lists`.`user_id` = 9)
Conversationv2 class
class Conversationv2 extends Model
{
protected $table = 'conversationsV2';
protected $fillable = ['id','type','name','image'];
}
MessageV2 class
class MessageV2 extends Model
{
protected $table = 'messagesV2';
protected $fillable = ['id','user_id','message','conversationsV2_id'];
}
GroupList class
class GroupList extends Model
{
protected $fillable = ['id','user_id','conversationsV2_id','status','lastseen'];
}
conversationsV2 Table
1 id int(10) UNSIGNED No None
2 type int(10) UNSIGNED No None Change
3 name varchar(50) utf8_unicode_ci No None
4 image varchar(255) utf8_unicode_ci No None
5 created_at timestamp Yes NULL Change
6 updated_at timestamp Yes NULL Change
group_lists Table
1 id int(10) UNSIGNED No None
2 user_id int(10) UNSIGNED No None
3 conversationsV2_id int(10) UNSIGNED No None
4 status int(10) UNSIGNED No None
5 lastseen int(10) UNSIGNED No None
6 created_at timestamp Yes NULL
7 updated_at timestamp Yes NULL
messagesV2
1 id int(10) UNSIGNED No None
2 message varchar(255) utf8_unicode_ci No None
3 image varchar(255) utf8_unicode_ci No None
4 conversationsV2_id int(10) UNSIGNED No None
5 user_idIndex int(10) UNSIGNED No None
6 created_at timestamp Yes NULL
7 updated_at timestamp Yes NULL
I don't what is wrong why i am getting 3 rows in laravel but only 1 row with sql (which is correct)
LOG
[
{
"query": "select * from `group_lists` inner join `conversationsV2` on `group_lists`.`conversationsV2_id` = `conversationsV2`.`id` inner join `messagesV2` on `conversationsV2`.`id` = `messagesV2`.`conversationsV2_id` where (`messagesV2`.`id` >= ? and `group_lists`.`user_id` = ?)",
"bindings": [
"lastseen",
9
],
"time": 0.43
}
]
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2o0zdow
via IFTTT
Aucun commentaire:
Enregistrer un commentaire