Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

详情展示关联数据出现查询错误 #3090

Closed
Chen-Zhitong opened this issue Mar 15, 2019 · 4 comments
Closed

详情展示关联数据出现查询错误 #3090

Chen-Zhitong opened this issue Mar 15, 2019 · 4 comments

Comments

@Chen-Zhitong
Copy link

  • Laravel Version: 5.8
  • PHP Version: PHP 7.2
  • Laravel-admin: 1.6.10

Description:

详情展示关联数据出现查询错误,其他地方使用一对多查询没错

  public class student{
      public function registerInfos()
      {
          return $this->hasMany('\App\RegisterInfomation');
      }
  }

StudentController.php @ show

        $show->registerInfos('注册信息', function ($registerInfo) {
            $registerInfo->resource('/admin/register-infomations');
        });
 QueryException In Connection.php line 664 :
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from `register_infomations` where `register_infomations`.`student_id` = ? and `r' at line 1 (SQL: select from `register_infomations` where `register_infomations`.`student_id` = 1901442792 and `register_infomations`.`student_id` is not null limit 20 offset 0)

如果使用
$show->registerInfos('注册信息');
输出正确:
输出:
[{"id":19,"admin_id":1,"school_id":1,"student_id":"1901442792","training_program_id":1,"payment_status":"non_payment","payee":"11111","charging_channel":"\u54c6\u5566\u5b9d","tuition":11111,"payment_date":"2019-03-15","receipt":true,"remark":null,"created_at":"2019-03-15 10:59:39","updated_at":"2019-03-15 10:59:39"}]

Steps To Reproduce:

@Chen-Zhitong
Copy link
Author

数据库查询错误在于
select from register_infomationswhereregister_infomations.student_id= 1901442792 andregister_infomations.student_id is not null limit 20 offset 0
中应该是 select * from xxxxx
是什么原因呢?

@Chen-Zhitong
Copy link
Author

不只在这个类中,其他Admin控制器details方法中使用

$show->teachers('老师信息',function(){

        });

也会有相同的错误
而使用:
$show->teachers('老师信息');
则正确运行

@Hlavacek323
Copy link

Hi i had same problem. I resolved it now downgrade laravel version back on 5.7

@Chen-Zhitong
Copy link
Author

Hi i had same problem. I resolved it now downgrade laravel version back on 5.7

Thank you, it seems to be this problem, no error occurred on my project using Laravel 5.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants