vendor/laravel/framework/src/Illuminate/Database/Connection.php:678 - laravel

SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into product_catagories (catagory_name, updated_at, created_at) values (Electronics, 2021-04-25 14:32:59, 2021-04-25 14:32:59))
How Can I solved this problem on a live server

Check your 'id' structure on your sql.
You got an error because 'id' field' doesn't have default value.
Also Make sure AUTO_INCREMENT checked

Related

Laravel import/export. The csv file I am importing does not work

SQLSTATE[HY000]: General error: 1364 Field 'password' doesn't have a default value (SQL: insert into users (name, email, updated_at, created_at) values (?, ?, 2021-06-03 12:25:18, 2021-06-03 12:25:18))
it's looks like you dont fill the password field, however it's mandatory

duplicate key value violates unique constraint Laravel and Postgresql

I try to add a new value to db, but I got this error.
SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value
violates unique constraint "lkp_locations_pkey"↵DETAIL: Key
(id)=(1) already exists. (SQL: insert into "lkp_locations" ("tex...
If I Replay the XHR ,the ID is increased, until I have an ID available ,and then the value is stored. From what I read is something about Postgres, but I am not sure what to change. Link:
$lkp_abode->fill([
'text' => $request->lkp_abode_text,
])->save();

sql 42S22 error in Laravel (choosing a column I didn't mention)

I am doing a basic project in Laravel, when trying to delete an entry, it generates this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `employees` where `id` = 6 limit 1)
and it is true I don't have a column named 'id', instead I have employee_id, but why is it choosing id instead of employee_id?
Please explain from where did it bring this id column?
In your Employee model (Employee.php), add
protected $primaryKey = 'employee_id';
This will tell Laravel to use employee_id as the primary key for Empolyee objects.

Laravel 5.2 exists validation cannot find column

I have wierd trouble during validating request in controller. I use exists validation rule. User is supposed to submit integer. This integer should exist as id in a single row of user_courses table. This row also should have column user_id equal to 158 - docs.
My validation rule:
'course_id' => 'integer|exists: user_courses, id, user_id, 158'
What I got instead:
PDOException in Connection.php line 333: SQLSTATE[42S22]: Column not
found: 1054 Unknown column ' id' in 'where clause'
My Table:
id, user_id, created_at, updated_at
Problem was in the spaces:
'course_id' => 'integer|exists: user_courses, id, user_id, 158' // incorrect
'course_id' => 'integer|exists:user_courses,id,user_id,158' // correct
Original code would confuse laravel to search for column names like this:
' user_courses'

laravel framework webservice error

I am just doing web service for laravel framework, so below error is displayed, I don't know which type of error
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'city' in where clause is ambiguous (SQL: SELECT MIN(room_prize)MIN,MAX(room_prize)MAX from `abserve_hotel_rooms` as `ar` JOIN `abserve_hotels` as `h` ON `ar`.`hotel_id` = `h`.`hotel_id` WHERE 1 AND `city` ="madurai" AND `country` ="india")
You forgot table alias to the fields city and country

Resources