【发布时间】:2014-03-24 14:05:45
【问题描述】:
我在使用 aws、mysql、laravel 和 angular 时遇到了一个奇怪的问题。
我有一个 vagrant 实例在本地运行,我的应用程序和数据库都在它上面运行。
我在前端使用 angular,因此当加载视图时,angular 会请求接收用户输入的所有“目标”列表。目标中的字段之一是goalStatus。这是 0 或 1 作为整数存储在 mysql 表中。
角度检查该值是 0 还是 1,并根据结果显示不同的表格单元格
<th ng-if="goal.goalStatus === '0'"><p class="text-danger">In Progress</p></th>
<th ng-if="goal.goalStatus === '1'"><p class="text-success">Achieved</p></th>
在 chrome 开发工具中,当我查看此请求的响应结果时,我看到 targetStatus 像这样返回
"goalStatus":"0"
角度 if 语句按预期工作。
但是,当我将此应用程序推送到弹性 beantalk 中的开发环境时,该环境连接到具有相同迁移和播种运行的 mysql rds 实例,开发工具显示goalStatus 如此
"goalStatus":0
如果条件不满足则角度,因此任何一个元素都不显示
因此,在弹性 beanstalk 实例上,它似乎以整数形式返回,但在本地机器上,它似乎以字符串形式返回。我不知道问题出在 mysql、laravel 还是其他地方。
有什么想法吗?为了以防万一,我在下表中包含了 laravel 迁移和种子类
迁移
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateGoalsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('goals', function(Blueprint $table) {
$table->increments('id');
$table->integer('userId');
$table->string('title');
$table->string('goalDesc');
$table->integer('goalStatus')->nullable();
$table->integer('bodyGoalId')->nullable();
$table->integer('strengthGoalId')->nullable();
$table->integer('distanceGoalId')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('goals');
}
}
播种机
<?php
class GoalsTableSeeder extends Seeder
{
public function run()
{
// Uncomment the below to wipe the table clean before populating
DB::table('goals')->truncate();
$now = date('Y-m-d H:i:s');
$goals = array(array(
'userId' => 1,
'title' => 'first goal title',
'goalDesc' => 'This should describe my goal in text form',
'goalStatus' => 0,
'bodyGoalId' => null,
'strengthGoalId' => null,
'distanceGoalId' => 1,
'created_at' => $now,
'updated_at' => $now),
array(
'userId' => 1,
'title' => 'strength goal title',
'goalDesc' => 'This should describe my strngth goal in text form',
'goalStatus' => 0,
'bodyGoalId' => null,
'strengthGoalId' => 1,
'distanceGoalId' => null,
'created_at' => $now,
'updated_at' => $now),
array(
'userId' => 1,
'title' => 'body goal title',
'goalDesc' => 'This should describe my body goal in text form',
'goalStatus' => 0,
'bodyGoalId' => 1,
'strengthGoalId' => null,
'distanceGoalId' => null,
'created_at' => $now,
'updated_at' => $now)
);
// Uncomment the below to run the seeder
DB::table('goals')->insert($goals);
}
}
【问题讨论】:
-
在aws mysql上运行
SELECT @@GLOBAL.sql_mode;在本地运行同样的命令看看是否不一致。 -
感谢回复,本地返回空rds retuns NO_ENGINE_SUBSTITUTION
-
任何关于如何解决这个问题的建议都会很棒
标签: php mysql json angularjs laravel-4