Google Login
LINGOKET
(Member No:) LOGOUT
Speak study

코드이그나이터4 Create news items 해석 댓글 부탁드립니다.

[United States->Korean] comment 0 Search 60 Vote 0 비추천 0 2021-02-18 15:06:34
Listen, Speak only works with apps and chrome browsers.
You now know how you can read data from a database using CodeIgniter, but you haven’t written any information to the database yet.
What does the sentence above mean?
0
In this section, you’ll expand your news controller and model created earlier to include this functionality.
What does the sentence above mean?
0
Create a form
What does the sentence above mean?
0
To input data into the database, you need to create a form where you can input the information to be stored.
What does the sentence above mean?
0
This means you’ll be needing a form with two fields, one for the title and one for the text.
What does the sentence above mean?
0
You’ll derive the slug from our title in the model.
What does the sentence above mean?
0
Create a new view at app/Views/news/create.php.
What does the sentence above mean?
0
There are probably only two things here that look unfamiliar.
What does the sentence above mean?
0
The \Config\Services::validation()->listErrors() function is used to report errors related to form validation.
What does the sentence above mean?
0
The csrf_field() function creates a hidden input with a CSRF token that helps protect against some common attacks.
What does the sentence above mean?
0
Go back to your News controller.
What does the sentence above mean?
0
You’re going to do two things here, check whether the form was submitted and whether the submitted data passed the validation rules.
What does the sentence above mean?
0
You’ll use the form validation library to do this.
What does the sentence above mean?
0
The code above adds a lot of functionality.
What does the sentence above mean?
0
First we load the NewsModel.
What does the sentence above mean?
0
After that, we check if we deal with the POST request and then the Controller-provided helper function is used to validate the $_POST fields.
What does the sentence above mean?
0
In this case, the title and text fields are required.
What does the sentence above mean?
0
CodeIgniter has a powerful validation library as demonstrated above.
What does the sentence above mean?
0
You can read more about this library here.
What does the sentence above mean?
0
Continuing down, you can see a condition that checks whether the form validation ran successfully.
What does the sentence above mean?
0
If it did not, the form is displayed;
What does the sentence above mean?
0
if it was submitted and passed all the rules, the model is called.
What does the sentence above mean?
0
This takes care of passing the news item into the model.
What does the sentence above mean?
0
This contains a new function url_title().
What does the sentence above mean?
0
This function - provided by the URL helper - strips down the string you pass it, replacing all spaces by dashes (-) and makes sure everything is in lowercase characters.
What does the sentence above mean?
0
This leaves you with a nice slug, perfect for creating URIs.
What does the sentence above mean?
0
After this, a view is loaded to display a success message.
What does the sentence above mean?
0
Create a view at app/Views/news/success.php and write a success message.
What does the sentence above mean?
0
This could be as simple as:
What does the sentence above mean?
0
News item created successfully.
What does the sentence above mean?
0
Model Updating
What does the sentence above mean?
0
The only thing that remains is ensuring that your model is set up to allow data to be saved properly.
What does the sentence above mean?
0
The save() method that was used will determine whether the information should be inserted or if the row already exists and should be updated, based on the presence of a primary key.
What does the sentence above mean?
0
In this case, there is no id field passed to it, so it will insert a new row into it’s table, news.
What does the sentence above mean?
0
However, by default the insert and update methods in the model will not actually save any data because it doesn’t know what fields are safe to be updated.
What does the sentence above mean?
0
Edit the model to provide it a list of updatable fields in the $allowedFields property.
What does the sentence above mean?
0
This new property now contains the fields that we allow to be saved to the database.
What does the sentence above mean?
0
Notice that we leave out the id?
What does the sentence above mean?
0
That’s because you will almost never need to do that, since it is an auto-incrementing field in the database.
What does the sentence above mean?
0
This helps protect against Mass Assignment Vulnerabilities.
What does the sentence above mean?
0
If your model is handling your timestamps, you would also leave those out.
What does the sentence above mean?
0
Routing
What does the sentence above mean?
0
Before you can start adding news items into your CodeIgniter application you have to add an extra rule to app/Config/Routes.php file.
What does the sentence above mean?
0
Make sure your file contains the following.
What does the sentence above mean?
0
This makes sure CodeIgniter sees create as a method instead of a news item’s slug. You can read more about different routing types here.
What does the sentence above mean?
0
Now point your browser to your local development environment where you installed CodeIgniter and add /news/create to the URL.
What does the sentence above mean?
0
Add some news and check out the different pages you made.
What does the sentence above mean?
0
Congratulations
What does the sentence above mean?
0
You just completed your first CodeIgniter4 application!
What does the sentence above mean?
0
The image underneath shows your project’s app folder, with all of the files that you created in green.
What does the sentence above mean?
0
The two modified configuration files (Database & Routes) are not shown.
What does the sentence above mean?
0
Listen, Speak only works with apps and chrome browsers.

 

Z Area
Recommender list

Introduction

A site that shares translations of everyday people around the world.
It is a site where you can repeat speaking, listening and practicing foreign language sentences.

QUICK MENU

  • How to upload articles

App

  • Google Play
  • App Store
상호:KRUZFACTORY|대표:이수민|호스팅제공자:KRUZFACTORY|개인정보책임자:이수민(croozfactory@gmail.com) COPYRIGHT (c)2017-2019 KRUZFACTORY CORP. ALL RIGHT RESERVED