Database operation of Yii framework version 2.0 in PHP (addition, deletion, modification and query)
1. The Yii framework has its own CSRF defense; you can add a line of code in the class to turn off the CSRF defense defence: //Close CSRF defense public $enableCsrfValidation = false; Second, sql statement method for database operation; db ->createCommand(“select * from table name”) ->queryAll(); #Revise Yii::$app->db ->createCommand()->update(‘table name’,[‘field name’=>value to be modified],’condition’) ->execute(); #delete Yii::$app->db ->createCommand() ->delete(‘table name’,’condition’) ->execute(); #Add to Yii::$app->db ->createCommand() ->insert(‘table name’,[‘field name’=>value to be added],’condition’) ->execute(); } } Three, function mode operation database the 1. Query 1.1 Some simple query functions one(): Return the first record of the query according to the query result. all(): Return all records according to the query result. count(): Returns the number of records. sum(): Returns the sum of the specified column. average(): Returns the average value of the specified column. min(): Returns the minimum value of the specified column. max(): Returns the maximum value of the specified column. scalar(): Returns the value of the first column in the first row of the query result. column(): Returns the value of the first column in the query result. exists(): Returns a value indicating whether there is data in the query result. where(): add query conditions with(): A list of…
Encapsulation of common methods such as php addition, deletion, modification and query
php Database function mysql char select insert key join Write your review! Let’s make a fuss, see everything Member Login | User Registration recommended reading python MySql command example summary [MySQL] Database | mysql tutorial MySql command database-mysql tutorial This article summarizes various operation commands commonly used in MySQL. Share it with everyone for your reference, as follows: The latest imitation hacker website source code, users after ubuntu update, use … [detailed] Crayon Shinchan 2023-09-02 09:00:00 python Sqlserverxml type operation The most basic rule: the data of the xml type and between the xml type and other data types cannot be compared, that is to say, the data of the xml type cannot appear on either side of the equal sign. For our database, this… [detailed] Crayon Shinchan 2023-09-02 07:20:35
018November 20th PHP Section 8 MySQL database addition, deletion, modification and query
1. Database addition, deletion, checking and modification (handwriting) Due to the following error, At the beginning, you need to set sql_mode,The content of the table comes from the self-built table in the second question. show variables like “sql_mode”; set sql_mode=”; setsql_mode=’NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES’; INSERT INTO `member`(`name`, `gender`,`age`,`country`,`hometown`, `married`)VALUES(‘Wang Erhu’,’male’,’29’, ‘China’,’Peking’,’Yes’) UPDATE `member` SET `name`=’Mari’,`gender`=’female’ WHERE `id`=1 //id plus` has no effect DELETE FROM `member` WHERE id=6 SELECT `name`,`hometown`,`id` FROM `member` WHERE id =2 2. Create a data table, each table has 10 fields (screenshot)
Additive|that is_a simple library management system based on php, login, registration, logout, database addition, deletion, modification and query, establishment of session, establishment of mysql database.
This article is organized by Programming Notes# for you. It mainly introduces a simple book management system based on php, login, registration, logout, database addition, deletion, modification and query, establishment of session, and establishment of mysql database. Relevant knowledge, hope to have certain reference value for you. Directory 1. Establish MySQL database 2. Link database file& #xff08;conn.php) 3. Front-end login page (log.php) 4. Login implementation page (log_ok.php& #xff09; 5. Front-end registration page (register.php) 6. Registration implementation interface (register_ok.php) Seven. The main page (index1.php) add, delete, modify, check 8. Add books(index_ok.php) add, delete, change, check Add 9. Modify and delete pages (index-select.php) 10. Modify books (update.php) Eleven. Modify the successful page (update_ok.php) Twelve. Delete the page (delete.php) Ten 3. Exit the system(back.php) 1. Create mysql database 1. I am using xampp, enter http://localhost//phpmyadmin in the browser address bar Attention : The default port number is 80 port, that is http://localhost:80//phpmyadmin, if you change your port number, pay attention to change 2. Click to create a new database (The name of the database is itcast52)The two indicate ,book52(Addition, deletion, modification and query )user52(Login and registration ) The following is the file of the database , Create a Notepad , Paste the code…
How to make php operate mysql_php how to operate mysql addition, deletion, modification and query
How to add, delete, modify and query mysql in php Release time :2020-07-14 16:20:21 Source : Yisuyun Read :99 Author :Leah How does php operate the addition, deletion, modification and query of mysql ?Many novices are not very familiar with this Clearly & # xff0c; In order to help you solve this problem & # xff0c; the following editor will explain in detail & # xff0c; those who have this need can come to learn & # xff0c; I hope you can gain something. Add, delete, modify and query method of php operating mysql : 1. Insert statement [insert into data table name (field 1, field 2,….) values(“value 1”, “value 2”,..)] ;2. Delete statement [delete from indicates where field & # 61; & # 39; condition & # 39; ]. How to add, delete, modify and query php to operate mysql : 1, the first step : go to the www folder directory in wamp , create a test folder , and then create a message folder in the test folder , to store each file that is added, deleted, modified, and checked. (Specific picture) 2. The second step : remember to open wamp, and then create a conn. The…
Addition, deletion, modification and query of MySQL table_some words of mysql addition, deletion, modification and query
class=”markdown_views prism-github-gist”> Addition, deletion, modification and query of MySQL tables CRUD is an acronym for the four words Create, Retrieve, Update, and Delete. The operation of the table is based on a set of records; Addition and deletion can only take one record as the basic unit. 1. Add (Create / Insert) Single quotes, double quotes ====” are used in strings, date and time in data records; Backquotes ====” used in the structure of the library name, table name, field name; You can omit backticks at all as long as you are careful to avoid using keywords as library names, surfaces, field names. 1.1 Insert – create table –Build Table–“Student Table Just use the interface CREATE TABLE `db_11_20`.`students` ( `id` INT NOT NULL AUTO_INCREMENT, `sn` INT NOT NULL COMMENT ‘student number’, `name` VARCHAR(45) NOT NULL, `email` VARCHAR(200) NULL, PRIMARY KEY (`id`), UNIQUE INDEX `sn_UNIQUE` (`sn` ASC)); 1.2 Single row data + full column insert Insert one row at a time, and the inserted data contains the data of all fields; Since all fields are inserted, the field part can be omitted in SQL; The order of the values inserted later must be the same as the order in the table…
ssm framework integration (simple addition, deletion, modification and query)
class=”markdown_views prism-atom-one-dark”> 1. Environmental requirements myEclipse+jdk1.8+tomcat7+ssm framework requires jar https://pan.baidu.com/s/1eNn658Hkncm4z28yQtEqxg Extraction code: 18fd Second, project structure screenshot: Third, detailed configuration of the configuration file: 1. web. xml configuration file: springMVC org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:applicationContext.xml 1 springMVC / charcterEncoding org.springframework.web.filter.CharacterEncodingFilter encoding utf-8 charcterEncoding /* org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml 2. mybatis.xml file: 3, applicationContext.xml file configuration q_lastModify=#{q_lastModify}, where q_id = #{q_id} 6. Service layer and its implementation class: Answer //AnswerService.java public interface AnswerService { // To answer the question, just add answer int addAnswer(Answer answer); // Query the answer below the question List selAllAnswer(@Param(“q_Id”) int q_Id); // query the last record Answer selAnswerByLastId(); } //AnswerServiceImpl.java @Service(“answerServiceImpl”) public class AnswerServiceImpl implements AnswerService{ @Resource private AnswerMapper answerMapper; @Resource private QuestionMapper questionMapper; /** * To answer a question, just add an answer * @param answer * @return */ @Override public int addAnswer(Answer answer) { answer.setA_date(MyUtil.getDate()); int addAnswerIndex = answerMapper. addAnswer(answer); Question selQuestionById = questionMapper. selQuestionById(answer. getA_q_id()); selQuestionById.setQ_answerCount(selQuestionById.getQ_answerCount()+1); int updateQuestionIndex = questionMapper. updateQuestion(selQuestionById); return addAnswerIndex+updateQuestionIndex; } /** * Look up the answer below the question * @param q_Id question number */ @Override public List selAllAnswer(int q_Id) { List selAllAnswer = answerMapper. selAllAnswer(q_Id); return selAllAnswer; } @Override public Answer selAnswerByLastId() { Answer selAnswerByLastId = answerMapper. selAnswerByLastId(); return selAnswerByLastId; }…
What is the basic statement of database addition, deletion, modification and query?
Basic statements for addition, deletion, modification and query in the database: “INSERT INTO table name field list VALUES (value list)”, “DELETE FROM table name WHERE clause”, “UPDATE table name SET column=value WHERE clause” , “SELECT * FROM tablename”. (Recommended tutorial: mysql video tutorial) Database Add, delete, modify and check basic statements Increase data in the database In MySQL, you can use the INSERT INTO statement to add data to the existing database Insert one or more rows of tuple data into the table. Grammar format: INSERT INTO table name (column name 1, column name 2,…column name N) VALUES (value 1, value 2,…value N); If the data is a character type, you must use single or double quotes, such as: “value”. Table name: Specify the name of the table being operated. Column name: Specify the column name that needs to insert data. If you want to insert data into all columns in the table, all column names can be omitted, just use INSERT VALUES(…) directly. VALUE clause: This clause contains a list of data to be inserted. The order of the data in the data list should correspond to the order of the columns. Example: Insert a new record in the…