php – laravel在本地机器上返回json字符串,但在弹性beanstalk实
我对aws,mysql,laravel和angular有一个奇怪的问题.
我有一个在我的应用程序和数据库上运行的本地运行的vagrant实例. 我在前端使用角度,因此当加载视图时,angular会请求接收用户输入的所有“目标”的列表.目标中的一个领域是goalStatus.这是在mysql表中作为整数存储的0或1. 角度检查该值是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 dev工具中,当我查看此请求的响应结果时,我看到goalStatus正如此返回 "goalStatus":"0" 并且角度if语句按预期工作. 然而,当我将这个应用程序推送到弹性beanstalk中的开发环境时,它连接到具有相同迁移和种子运行的mysql rds实例,dev工具显示goalStatus,因为这个 "goalStatus":0 并且不满足角度if条件,因此不显示任何一个元素 因此,似乎在弹性beanstalk实例上它以整数形式返回,但在本地机器上它将作为字符串返回.我不知道天气问题会出现在mysql,laravel或其他地方. 有任何想法吗?为了以防万一,我已经在下表中包含了laravel迁移和种子类 移民 use IlluminateDatabaseMigrationsMigration; use IlluminateDatabaseSchemaBlueprint; 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','strengthGoalId' => 1,'distanceGoalId' => null,'title' => 'body goal title','goalDesc' => 'This should describe my body goal in text form','bodyGoalId' => 1,'updated_at' => $now) ); // Uncomment the below to run the seeder DB::table('goals')->insert($goals); } } 解决方法
所以这似乎是一个问题,php mysql驱动程序将所有字段作为字符串返回,无论类型如何.
source
我的aws弹性beanstalk实例似乎被设置为解释这个因此它返回字符串和字符串和整数作为整数,而我的流浪汉设置需要更改为使用php5_mysqlnd驱动程序而不是它有一个解决问题 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |