duan198123 2017-10-10 19:36
浏览 70
已采纳

Laravel Query在IPv4 Vs上的表现不同。 IPv6环境

I have a weird situation here that I never seen before while using Laravel. I have the same code base on different set up, 1 in IPv4 VM, 1 in IPv6 VM.

This is the data in the database.

enter image description here

This is how I normally query it.

// $ap = '102030405067';
$gw = Gateway::where('cpe_mac','=',$ap)->first();
dd($gw);

In my IPv4 Set up, I got :

{#541 ▼
  +"id": 1
  +"account_id": "50"
  +"cpe_mac": "102030405067"
  +"gw_id": "1956692524588882"
  +"gw_secret": "zUIyaQfCntob2thL6uR4uQfBvmlCei-5q_oVSJnyeSc"
  +"fb_wifi_enable": "1"
  +"created_at": "2017-10-10 14:41:17"
  +"updated_at": "2017-10-10 14:41:17"
}

In my IPv6 Set up, I got :

null


Try #2

dd(Gateway::all());.

Result

In IPv4, I got all the records returned.

enter image description here

In IPv6, I got this empty collection

Collection {#542 \u25bc #items: [] }

enter image description here


The most confusing part is, other tables seems to work fine, this gateways seems to be the only one that causing the problem.

I triple checked my Gateway model name, and table name. They spelled correclty.


  • Have you guys seen something like this before ?

  • How would one go about and debug this issue further ?

  • What else should I try ?

  • 写回答

1条回答 默认 最新

  • dongpei2835 2017-10-10 19:40
    关注

    To be honest - I don't think it's possible.

    Make sure that in both cases $ap contains exact same value. You can use trim($ap) just in case to be double-sure it doesn't contain extra special characters.

    Also make sure on both VMs you have same data in database. Now it seems in one VM you have data in database and in second you don't.

    EDIT

    It's not possible there is direct problem in Laravel, so:

    • make sure in both VMs you have data in your databases - on both VMs run SELECT * FROM gateways to verify on both you have any records (you haven't mentioned that both VMs are using same database so I assume they are different)
    • make sure in both VMs you have valid database set in your .env file
    • on both VMS run php artisan config:clear just to make sure you don't have cached invalid database connection
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?