简体   繁体   English

SQLSTATE [23000]:违反完整性约束:1048列'page_id'不能为空laravel 5

[英]SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'page_id' cannot be null laravel 5

i am using laravel 5.2 and jquery ajax 我正在使用laravel 5.2和jquery ajax

I working on a application on which i am passing a larger data of post through ajax. 我正在处理一个应用程序,在该应用程序上我将通过ajax传递较大的post数据。 but for larger data i am getting this error 但是对于更大的数据,我得到这个错误

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'page_id' cannot be null laravel 5

here are my php.ini settings which i have tried 这是我尝试过的php.ini设置

max_input_vars = 9000
post_max_size=30M

here is my code of jquery ajax 这是我的jQuery Ajax代码

$.ajax({
      url : url+'/ajax-saveall-Collectionpost',
      type : 'POST',
      data : {'posts_data':posts_data,'page_id':page_id,'page_name':page_name,'collection_id':collection_id},
      dataType : 'JSON',
      beforeSend: function(data) {
            $("#loading").show()
      },
      success : function(data) {
             $("#loading").hide()},
      error : function(xhr, status, error) {
            console.log(xhr.responseText);
      }
     });

Here is my laravel controller function 这是我的laravel控制器功能

public function saveall_Collectionpost(){
    $posts_data = Input::get('posts_data');
    $page_id = Input::get('page_id');
    $page_name = Input::get('page_name');
    $collection_id = Input::get('collection_id');

    if($this->user_id !== false){
        foreach ($posts_data as $key => $value) {

            $this->save_fav_post($page_id,$page_name,$posts_data[$key]['id'],$collection_id,$value);    
        }
        $return['error'] = false;
    }else{
        $return['error'] = 'login';
    }

the problem which i am facing here is this that i am losting the data for larager data in php controller function 我在这里面临的问题是我丢失了PHP控制器函数中larager数据的数据

when i print_r the data of $posts_data array then it gives me only 66 index of array however if i got my chrome network tab and check the form data which is being passed from jquery ajax request then that data has 115 index of array also the page_id value is being passed in the form data to from jquery ajax request but if i echo the $page_id then i see no value . 当我print_r the data of $posts_data array它只给我66个数组的索引,但是,如果我得到了chrome网络标签并检查从jquery ajax请求传递的表单数据,则该数据具有数组的115个索引,也为page_id值是从表单数据传递到jquery ajax请求中,但是如果我echo the $page_id then i see no value

then it means values are being passed but they are getting lost in laravel controller function when i tries them to get using like this 那么这意味着值正在传递,但是当我尝试使用这样的值时,它们在laravel控制器函数中丢失了

$posts_data = Input::get('posts_data');
$page_id = Input::get('page_id');

Remove dataType : 'JSON', from ajax post code. 从ajax邮政编码中删除dataType : 'JSON', cause you are sending json string to function which is not considered as separate variable. 因为您正在将json字符串发送给不被视为单独变量的函数。 so remove this, or parse your json in function first then set it to vars. 因此,请删除它,或先在函数中解析json,然后将其设置为vars。 Also make sure your page_id is not blank. 还要确保您的page_id不为空。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 6 - SQLSTATE [23000]:违反完整性约束:1048 列不能是 null - Laravel 6 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column cannot be null SQLSTATE [23000]:违反完整性约束:1048列“ ID”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ID' cannot be null SQLSTATE[23000]:违反完整性约束:1048 列“property_id”在 Laravel 5.2 中不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'property_id' cannot be null in Laravel 5.2 SQLSTATE [23000]:完整性约束违规:1048 列 'user_id' 不能是 laravel 中的 null - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null in laravel SQLSTATE [23000]:违反完整性约束:1048列“ teamName”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'teamName' cannot be null “ SQLSTATE [23000]:违反完整性约束:1048列'description'不能为空 - "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'description' cannot be null SQLSTATE[23000]:违反完整性约束:1048 列“名称”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null SQLSTATE [23000]:违反完整性约束:1048列“ post”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'post' cannot be null SQLSTATE[23000]:违反完整性约束:1048 列“状态”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status' cannot be null SQLSTATE [23000]:违反完整性约束:1048列“ message”不能为空 - SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'message' cannot be null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM