How to switch from MySQL to ADODB

Source: Internet
Author: User

Advanced Materials


Insert and Update

Suppose you want to insert the following data into the database.


ID = 3
TheDate = mktime (2001,)/* 31st August */
Note = sugar why don't we call it off

When you use another database, your insert operation may not be successful.

The first problem is that each database has a different default date format. The default MySQL format is YYYY-MM-DD, but other databases have different default formats. ADODB has a DBDate () function that converts a date to a correct format.

The next question is that the don't In the Note field value should be used as a citation. In MySQL, don't is used to solve this problem, but don't is used in some other databases (Sybase, Access, MicrosoftSQL Server. Qstr () solves this problem.

How can we use this function? As shown below:

$ SQL = "INSERT INTO table (id, thedate, note) values (". $ ID. ','. $ db-> DBDate ($ TheDate ). ','. $ db-> qstr ($ Note ). ")"; $ db-> Execute ($ SQL); ADODB also supports $ connection-> Affected_Rows () (returns the number of rows affected by the last update or delete operation) and $ recordset-> Insert_ID () (returns the last auto-increment number generated by the insert Statement ). But it should be noted that all databases support these two functions.

Policypes

You can find

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.