How to resolve "Unknown column 'description' in 'field list'" in CodeIgniter? - codeigniter

I am trying to add single field from many fields to a table:
Error Number: 1054
Unknown column 'description' in 'field list'
Code:
INSERT INTO `eys_questions` (`question`, `description`, `answer1`,
`checkbox1`, `answer2`, `answer3`, `answer4`, `answer5`, `answer6`,
`answer7`, `answer8`, `answer9`, `answer10`, `image`)
VALUES ('This is the question ', 'This is the description', 'This is the answer', '1',
'', '', '', '', '', '', '', '', '', '')
Filename: C:/xampp/htdocs/eys/system/database/DB_driver.php
Line Number: 691

It looks like your db table don't have any column with name description. Check out the spelling of the column name description.

You need to verify the columns on the eys_questions table. The error is pretty clear: that table doesn't have a description column. You can check the columns on a table with the desc (describe) sql command.
In your case desc eys_questions. This will show you table information such as column names and types.
Once you've verified column names, you can modify your insert statement accordingly.

Related

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

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

Deal with Radio Buttons in Laravel

Problem: I have a table categories on my database which contains the cat_id as primary key of type int and cat_name as name of the category. But I collect info from the under via radio.
Question: How can I convert the 'on' and 'off' from the user to integers?
Error Given:
Illuminate\Database\QueryException SQLSTATE[HY000]: General error:
1366 Incorrect integer value: 'on' for column 'type' at row 1 (SQL:
insert into users (user_name, name, type, email, password,
updated_at, created_at) values (malico, John Doe, on,
john.doe#gmail.com,
$2y$10$yyf4Vt01ukTNPFxGa1PIheJZvmcPbozGjdz8zo84vkK325Qk6rfna,
2018-05-19 12:56:01, 2018-05-19 12:56:01))
just do something like this on your request :
$request->merge(['type'=>$request->get('type') == 'on' ? 1 : 0]);
this will change "on" to 1 in your request

Partitions are still showing in hive even though they are dropped for an external table

I have an external table in hive partitioned by year, month, day. So I dropped one partition but I still see it in show partitions.
>use test_raw_tables;
>show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24]
> alter table test1_raw drop partition (year=2016, month=01, day=01);
> refresh test1_raw;
> show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24] ---Still see the dropped partition here----
> msck repair table test1_raw;
> show partitions test1_raw;
[year=2016/month=01/day=01]
[year=2017/month=03/day=24] ---Still see the dropped partition here----
Running from impala with hive as engine.
describe test1_raw
col_name,data_type,comment ('amount_hold', 'int', '') ('id', 'int', '') ('transaction_id', 'string', '') ('recipient_id', 'string', '') ('year', 'string', '') ('month', 'string', '') ('day', 'string', '') ('', None, None) ('# Partition Information', None, None) ('# col_name ', 'data_type ', 'comment ') ('', None, None) ('year', 'string', '') ('month', 'string', '') ('day', 'string', '')
location 'hdfs://localhost/sys/datalake/testing/test1_raw'
What is the problem here?
The data in hdfs is deleted for that partition after dropping it. Cannot figure out the issue.
In your Table defination Column Year, Month and Day are in String format.
Pls try with '2016', '01' and '01'.
I used below code and it works.
alter table test1_raw drop partition (year='2016', month='01', day='01');
Not that it matters anymore but you changed a definition of a table. You didn't change the data. Hive is unique in that it will let you define schema on read, altering the definition is just altering the definition it's not changing the data only the table definition. You can have multiple tables sit on top of the same data without issues, it doesn't mean a table definition change in one affects the other. (Well I'm talking about On READ anyways...)

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'

activerecord adding NULL as 'id' field?

I am creating a user via:
user = User.create attrs
Basically, it screws up by adding a 'id' field with value NULL which I am guessing evaluates as 0. So after the first user, I get an error that id must be unique. I can confirm that the attrs hash does not contain an 'id' field.
This is the generated SQL:
INSERT INTO `users` (`birthday`, `created_at`, `device_token`, `device_type`, `email`, `fb_id`, `first_name`, `gender`, `last_name`, `location`, `rstatus`, `updated_at`) VALUES ('1992-02-28 00:00:00', '2012-12-06 17:43:43', NULL, 'x86_64', 'adfas023#gmail.com', '12593646569', 'Test', 'male', 'Once', Test, 'Single', '2012-12-06 17:43:43')
What's going on?
Thanks
Your id column should be auto-incrementing, and your migrations would normally ensure this is so. If you can't/aren't using migrations, then fix it manually.

Resources