1dbf0001e40d729cb4bd

The 22nd day of my php learning – MySQL add, delete, modify, check basic operations

1. MySQL client, steps to operate MySQL Step 1: Connect to the MySQL database server mysql –uroot -root The second step: select the database to be operated (current database) use db_name The third step: set the character set set names gbk Step 4: Execute SQL statements: add, delete, modify, check Add: INSERT INTO table_name(title,author,addate) VALUES(‘title’,’admin’,now()) Delete: DELETE FROM table_name WHERE conditional expression Modify: UPDATE table_name SET title=”New title” WHERE conditional expression Query: SELECT * FROM table_name WHERE condition ORDER BY LIMIT 2. Steps for PHP to operate MySQL (MySQL function) Step 1: Connect MySQL Database Server mysql_connect() Meaning: connect to My sql database server Format: resource mysql_connect (host address, user name, user password) Return value: If the connection is successful, return the resource identifier, if the connection fails, return false Example: $link = mysql_connect(“ localhost “,”root”,”root”); exit() Meaning: After outputting information, the interrupt script continues to run downward Format: void exit([$string]) Note: The $string parameter is optional, if there is no parameter, it will be interrupted directly; if there is a parameter, it will be output first and then interrupted Example: exit(“ Connection to MySQL failed”); header() Meaning: Send some information to the browser client through the header() function, such…

PHP file and folder operations (create, delete, move, copy)

PHP file and folder operations (create, delete, move, copy)

Create the FileUtil.php file, the content and calling method are as follows: <?php /** * Manipulate file class * * example: * FileUtil::createDir(‘a/1/2/3’); Test to create a folder Create a folder a/1/2/3 * FileUtil::createFile(‘b/1/2/3’); Test to create a file Create a 3 file under the b/1/2/ folder * FileUtil::createFile(‘b/1/2/3.exe’); Test to create a file Create a 3.exe file under the b/1/2/ folder * FileUtil::copyDir(‘b’,’d/e’); Test copy folder Create a d/e folder and copy the contents of the b folder into it * FileUtil::copyFile(‘b/1/2/3.exe’,’b/b/3.exe’); Test to copy files to create a b/b folder and put it in the b/1/2 folder Copy the 3.exe file into * FileUtil::moveDir(‘a/’,’b/c’); Test moving folder Create a b/c folder, move the contents of a folder into it, and delete a folder * FileUtil::moveFile(‘b/1/2/3.exe’,’b/d/3.exe’); Test to move files Create a b/d folder and put 3 in b/1/2 .exe moved in * FileUtil::unlinkFile(‘b/d/3.exe’); Test delete file Delete b/d/3.exe file * FileUtil::unlinkDir(‘d’); Test delete folder Delete d folder */ class FileUtil { /** * create folder * * @param string $aimUrl * @return viod */ function createDir($aimUrl) { $aimUrl = str_replace(‘‘, ‘/‘, $aimUrl); $aimDir = ”; $arr = explode(‘/’, $aimUrl); $result = true; foreach ($arr as $str) { $aimDir…

Add, delete, modify and check sql statements in php, add, delete, modify and check syntax of SQL database

Add, delete, modify and check sql statements in php, add, delete, modify and check syntax of SQL database

SQL SELECT syntax SELECT column_name,column_name FROM table_name; With SELECT * FROM table_name; SQL INSERT INTO syntax INSERT INTO statement can have two writing forms. The first form does not need to specify the column name to insert data, just provide the value to be inserted: INSERT INTO table_name VALUES (value1,value2,value3,&# 8230;); The second form needs to specify the column name and the value to be inserted: INSERT INTO table_name (column1,column2,column3,…) VALUES (value1 ,value2,value3,…); SQL UPDATE syntax UPDATE table_name SET column1=value1,column2=value2,… WHERE some_column=some_value; SQL DELETE syntax DELETE FROM table_name WHERE some_column=some_value; Recommended tutorial: sql tutorial

Dev Notes: Add, Delete, Update using AJAX, MySQL and PHP [duplicate]

Introduction: This article is compiled by the editor of Programming Notes# for you. It mainly introduces the use of AJAX, MySQL and PHP to add, delete, and update [repeat] related knowledge. I hope it will have certain reference value for you. This question already has an answer here: Why shouldn’t I use mysql_* functions in PHP? 15 answers I I have some Ajax and mysql issues in my application. My application is sort of like a user manager. I have MySQL database with ID, USERNAME, PASSWORD, FIRST_NAME, LAST_NAME and EMAIL fields. I have a list of 10 records per page user paginated. Now I’m trying to provide functionality for adding new users, editing existing users, and deleting users one by one. I have the next code: config.phpfile <?php$mysql_hostname = “localhost”; $mysql_user = “root”; $mysql_password = “password”; $mysql_database = “mybase”; $con = mysql_connect($mysql_hostname, $mysql_user, $ mysql_password) or die(“Opps error! occurred”);mysql_select_db($mysql_database, $con) or die(“Opps error! occurred”);?> This is the database connection ** index.php ** <?phpinclude(‘config.php’);$per_page = 3; //getting number of rows and calculating no of pages$sql = “select count(*) from users”;$result = mysql_query($sql);$count = mysql_fetch_row($result);$pages = ceil($count[0]/$per_page);?> html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> Javascript” src=”https://img.php1.cn/3cd4a/1eebe/cd5/60405fda58cd0acd.webp’%20/>”);…

891ea1e7dab975064c6bfd22796603ae.gif

php online browsing pictures, photomngPHP picture management system, can create albums, online browsing, delete, etc. WEB (ASP, PHP,…) 2.38 million source code download www.pudn.com…

File name: photomngDownload Favorite √ [ 5 4 3 2 1 ] Development tools: PHP File size: 5419 KB Upload time: 2014-07-31 Download times: 1 Details:PHP image management system , can create photo albums, online browsing , delete , management, etc. -PHP photo management system, you can create photo albums, online browsing, deleting, and management File list (click to judge whether the file you need, if it is garbage, please comment and complain below): piwigo ……\category.php ……\action.php ……\random.php ……\_data ……\…..\dummy.txt ……\upgrade.php …. .\upload ……\profile.php ……\identification.php …… \about.php ……\picture.php ……\notification.php ….. .\admin.php ……\search.php ……\qsearch.php …. ..\i.php ……\register.php ……\tools …. .\…..\replace_language_keys.pl ……\…..\convert_template_to_2.1.pl ……\ …..\metadata.php ……\…..\fill_history.pl ……\…. .\translation_analysis.php ……\…..\triggers_list.php ……\…..\convert_language_to_2. 1.pl ……\…\..\missing_keys.pl ……\…..\index.php ……\…..\replace.php ……\…..\piwigo_remote.pl ……\…..\replace_language_values.pl ……\…..\release_creation.readme .. ……\key2value.php ……\…..\pwg_rel_create.sh …… \…..\config.inc.php ……\…..\ws.htm ……\. ….\language ……\…\…\…\translation_validated.inc.php … …\galleries ……\…\index.php ……\upgrade_feed.php ……\install ……\…….\obsolete.list …. ..\…….\config.sql ……\…….\upgrade_1.6.0.php .. ….\……\upgrade_2.0.0.php ……..\…….\php5_apache_configuration.php ……\…….\upgrade_1.4.0.php ……\…….\upgrade_2.1.0.php ……\…….\db ……\…….\..\114-database.php ……\……\..\65-database.php ……\… .\..\99-database.php ……\……..\..\68-database.php … …\……….\..\74-database.php ……\…….\..\64-database.php ……\……\..\131-database.php ……\… .\..\108-database.php ……\……..\..\133-database.php … …\…….\..\86-database.php ……\…….\..\128-database.php ……\……\..\132-database.php ……\… .\..\102-database.php ……\…..\..\67-database.php … …\…….\..\97-database.php ……\…….\..\81-database.php ……\……\..\80-database.php ……\… .\..\98-database.php ……\……..\..\130-database.php … …\…….\..\79-database.php ……\…….\..\84-database.php ……\……\..\73-database.php ……\… .\..\123-database.php ……\…….\..\118-database.php … …\…….\..\75-database.php ……\…….\..\90-database.php ……\……\..\112-database.php ……\… .\..\129-database.php ……\…….\..\83-database.php … …\……….\..\105-database.php ……\…….\..\110-database.php ……\……\..\95-database.php ……\… .\..\107-database.php ……\…….\..\70-database.php … …\…….\..\89-database.php ……\…….\..\88-database.php ……\……\..\117-database.php ……\…… .\..\115-database.php ……\…….\..\66-database.php … …\…….\..\77-database.php ……\…….\..\113-database.php ……\……\..\125-database.php ……\… .\..\71-database.php ……\……..\..\87-database.php ……

CRUD of Java and MongoDB database (add, delete, modify and check)

1. Preparation 1. Create a maven project and add the required dependencies junit junit 4.10 test org.mongodb mongo-java-driver 2.11.3 Of course you can also build java project, download the mongoDB driver package for Java support, and then copy the jar file to lib 2. Start the mongo service and create a test class for testing 2. The complete source code is as follows: package com.shxt.mongo; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import org.bson.types.ObjectId; import org.junit.After; import org.junit.Before; import org.junit.Test; import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mongodb.Mongo; import com.mongodb.MongoClient; import com.mongodb.util.JSON; /** * CRUD of MongDB * @author Fan Xiaodong * @ClassName: TestMongo * @Version 1.0 * @ModifiedBy * @Copyright shxt * @date 2013-9-27 pm 08:21:49 * @description */ public class TestMongo { private Mongo mg = null; private DB db; private DBCollection users; @Before public void setUp() throws UnknownHostException { // Create a MongoDB database connection object mg=new MongoClient(“localhost”, 27017); //Authentication mode login (if no authentication module is set, you can log in directly) //If you want the login verification module to take effect, you need to enter 1->mongo 2->use admin 3->db.addUser(“root”,”root123″); 4->db.auth(“root” ,”root123″); DB admin=mg.getDB(“admin”); boolean bool =admin.authenticate(“root”, “root123”.toCharArray()); If (bool){ //login success //Get…

Add, delete, modify and query array elements and embedded documents in the MongoDB database

For example, I have a user class, which contains a label attribute. This label is an array, and the elements in the array are embedded documents in the following format: { “_id” : “195861”, “tags” : [ { “tagId” : NumberLong(766), “optDate” : ISODate(“2013-08-12T15:21:02.930Z”), “enable” : true }, { “tagId” : NumberLong(778), “optDate” : ISODate(“2013-08-12T15:21:02.930Z”), “enable” : true } ] } Next, add, delete, and query the tags in this document. Spring mongodb is used here Inside the MongoTemplate class. Here I abstract the embedded documents in tags into Tag class. Code deletion and modification itself contains query methods, so no query methods are written /** * * @author zhangdonghao * */ @Component(“UserTagServiceImpl”) public class UserrTagServiceImpl implements UserrTagService { /** * Mongo DB Spring Template */ @Resource protected MongoTemplate mOngoTemplate = null; public UserTagServiceImpl() { } /** **Add an element to the tags array */ @Override public Response addTag(String id, Long tagId) { try { Tag tag = new Tag(tagId); tag.setOptDate(new Date()); tag.setEnable(true); Query query = Query.query(Criteria.where(“_id”).is(id)); Update update = new Update(); update.addToSet(“tags”, tag);   mongoTemplate.upsert(query, update, User.class); } catch (Exception e) { return new Response(0); } return new Response(1); } /** **Modify the value of an element specified in…

MongoDB eight-day course: add, delete, check and modify in detail on the second day

MongoDB eight-day course: add, delete, check and modify in detail on the second day

  After reading the previous article, I believe everyone will know how to open mongodb. This article will elaborate on the additions, deletions, checks and changes. First, when we open mongodb, I was suddenly dumbfounded, wiped, it couldn’t be opened, carefully observed the information in the “lined area”, and found that there was a similar “lock” under the db folder file” prevents the opening of mongodb. The next thing we need to do is to kill it. After that, the opening is successful. The management method of mongodb will be shared in the follow-up article. One: Insert operation the As mentioned in the previous article, documents are stored in the “K-V” format. If you are familiar with JSON, I believe that learning mongodb is easy. We know that Value in JSON may be a “string” or an “array”. There may also be an embedded JSON object, the same way is also suitable for BSON. Common insert operations also exist in two forms: “single insert” and “batch insert”. ① Single Insert As I said earlier, the mongo command opens a Javascript shell. So the syntax of js works here, doesn’t it look awesome. ② Batch Insert   I believe everyone should…

How does mysql add, delete, modify and check table data?

In mysql, you can use SELECT statement to query table data, use INSERT statement to add table data, use UPDATE statement to modify table data, and use DELETE statement to delete table data. mysq table data query In MySQL, you can use the SELECT statement to query data. Querying data refers to using different query methods to obtain different data from the database according to requirements, which is the most frequently used and most important operation. The syntax of SELECT is as follows: SELECT {* | } [ FROM , … [WHERE [GROUP BY [HAVING [{ }…]] [ORDER BY ] [LIMIT[,] ] ] Among them, the meaning of each clause is as follows: {*| } A field list containing asterisk wildcards, indicating the name of the field to be queried. , …, Table 1 and Table 2 indicate the source of query data, which can be single or multiple. WHERE is optional, if you select this item, the query data must meet the query condition. GROUP BY, this clause tells MySQL how to display the queried data and group it by the specified field. [ORDER BY], this clause tells MySQL in what order to display the queried data, and the…

How to add, delete, modify and check mysql index?

In mysql, you can use the “CREATE INDEX” statement to add an index; use the “SHOW INDEX” statement to view the index; use the “DROP INDEX” statement to delete the index; and modify the index by deleting the original index, Then create an index with the same name as needed to realize the operation of modifying the index. (Recommended tutorial: mysql video tutorial) mysql Index Creation Creating an index refers to creating an index on one or more columns of a table, which can improve the access speed to the table. Creating indexes is very important for the efficient operation of MySQL database. Basic Syntax MySQL provides three ways to create indexes: 1) Use the CREATE INDEX statement You can use the CREATE INDEX statement specially used to create an index to create an index on an existing table, but this statement cannot create a primary key. Grammar format: CREATE ON ( [] [ ASC | DESC]) The syntax is as follows: : Specify the index name. A table can create multiple indexes, but the name of each index in the table is unique. : Specify the name of the table to create the index. : Specify the column name…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索