How to insert raw data in mysql database in laravel

0 votes

I am new in laravel development. I use the mysql database, and want to insert the raw data in the database. I add the column with $table->binary(). And how can I insert the data to the column.

Schema::table('users', function($table)
{
    $table->binary('raw');
});
Dec 7, 2020 in Laravel by kartik
• 37,520 points
1,116 views

1 answer to this question.

0 votes

Try this:

Suppose you have the following tables (called 'users')

id|user|fname|lname|email|etc..
-------------------------
1|niroj|niroj|nirojdey@example.com|blah....

DB::table('users')->insert(
    array('user' => 'niroj',
          'fname' => 'niroj',
          'lname' => 'dey',
          'email' => 'niroj dey@example.com')
);

The insert() accepts multiple array (which in turns can be mapped to individual columns in your table).

answered Dec 7, 2020 by Niroj
• 82,880 points

Related Questions In Laravel

0 votes
1 answer

What is database migration and how to create database migration in Laravel?

Hii, Migrations are like version control for your database, ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,315 views
0 votes
1 answer

How to get data from Laravel backend and display in Vue/Nuxt frontend

Hello, You have to use the package dotenv. Then ...READ MORE

answered Apr 8, 2020 in Laravel by Niroj
• 82,880 points
3,191 views
0 votes
1 answer

How to pass data to mail View in laravel Mail send?

Hello @kartik, Send data like this. $data = [ ...READ MORE

answered Jul 30, 2020 in Laravel by Niroj
• 82,880 points
7,872 views
0 votes
1 answer

How to populating a database in a Laravel migration file?

Hello @kartik, Don't put the DB::insert() inside of ...READ MORE

answered Aug 4, 2020 in Laravel by Niroj
• 82,880 points
3,080 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
22,960 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
2,969 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,900 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
44,401 views
0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
11,877 views
0 votes
1 answer

Explain validations in laravel and How to validate my application incoming data?

Hey @kartik, In Programming validations are a handy ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
1,415 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP