【问题标题】:Laravel Postgre invalid text representationLaravel Postgre 无效的文本表示
【发布时间】:2017-06-20 01:19:27
【问题描述】:

我的 Laravel 应用出现错误

无效的文本表示:7 错误:布尔类型的无效输入语法:“2”(SQL:select * from “tasks” where extract(day from “due_date”) = 20 and “status”!= 2)

我在 Laravel Controller 上的查询如下:

$datav['dueTasks'] = Task::whereDay('due_date', date('d'))->where('status','!=','2')->get();

这是从 mysql 数据库迁移,所以问题可能是状态不等于 2 语法。

有人知道如何解决这个问题吗? 谢谢!

【问题讨论】:

    标签: php mysql postgresql laravel-5


    【解决方案1】:

    原来是迁移表。

    我的“tasks”.“status”是一个布尔数据类型,在mysql中变成了TINYINT。

    在 postgre 中,我将数据类型更改为 smallInt 并运行。

    public function up()
    {
      Schema::create('tasks', function (Blueprint $table) {
          $table->increments('id');
          $table->string('name');
          $table->date('start_date');
          $table->date('due_date');
          $table->**smallInteger**('status')->default(1);
          $table->smallInteger('priority')->default(8);
          $table->text('description');
          $table->timestamps();
      });
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-26
      • 1970-01-01
      • 2021-09-21
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      • 2013-07-22
      • 1970-01-01
      相关资源
      最近更新 更多