PHP PDO – exec (INSERT, UPDATE, DELETE) MySQL #exec, #pdo #exec, #insert, #update, #delete


#

PHP PDO – exec (INSERT, UPDATE, DELETE) MySQL

PHP-MySQL

After the connection to database is successfully created and the PDO object instance is set, the object can be used to perform SQL queries.
The SQL queries with PDO can be made in two ways:
– directly using ” exec() “, and ” query() ” methods,
– or with the prepare(). execute() statement.
The first variant is more simple, in this lesson it’s presented the exec method.

The queries that modify rows in the table, but not return a result set with rows and columns (INSERT, UPDATE, and DELETE), are send with exec(). this method returns the number of affected rows, or FALSE on error.

$count = $conn- exec(“SQL Query”);

Queries that select rows (SELECT) and return a result set with rows and columns are sent with the query() method. In case of error, returns FALSE.

$res = $conn- query(“SQL Query”);

To work with databases in PHP, you must know the specific SQL queries as: CREATE TABLE, INSERT, SELECT, UPDATE, etc.
These queries are send as a string to the MySQL server.

Create MySQL table

To create a table in a MySQL database, use the ” CREATE TABLE `table_name` ” query, and the exec() method:

– All these instructions are added after the PDO object is created, containing the connection to MySQL database.

In the next example it is created in a database named “tests” a table named “sites”, with 4 colummns: “id”, “name”, “category”, and “link”. – If the table is created, the code above will display:

The sites table is created

– The instruction: ” exec(“SET CHARACTER SET utf8″) ” sets the transfer of data between PHP and MySQL to be made with UTF-8 encoding. It is advisable to add this instruction especialy when working with data containing diacritics or special characters, but the PHP script should also contain this header: header(‘Content-type: text/html; charset=utf-8’); .

INSERT

Once the MySQL table is created, you can add rows with data. To add data into a table, use an INSERT command, in the exec() method.
Sintax:

$objPDO- exec(“INSERT INTO `table_name` (`column1`, `column2`. ) VALUES (‘value1’, ‘value2’. )”);

Example: – This code adds 3 rows in the “sites” table. The $count variable stores the number of affected rows (added).
This script will display:

Number of rows added: 3

The “sites” table will contain these data:
To get the last auto-inserted “id” (in a AUTO_INCREMENT PRIMARY KEY column), use the lastInsertId() method.
– When you add multiple rows in the same INSERT query, this method will return the ID of the first added row.

UPDATE. and DELETE are SQL instructions that changes data in a table, but not return a result set with rows and columns. They can be executed in the same way as INSERT, with the exec() method.

UPDATE

The data in the rows of a MySQL table can be modified with the SQL command INSERT .
Syntax:

$objPDO- exec(“UPDATE `table_name` SET `column1`=’value1′, `column2`=’value2′ WHERE condition “);

The next example changes data in the columns “name” and “link”, where “id” is 3; in the “sites” table (created with the code above). – Result:

Affected rows. 1

Sometimes an UPDATE query not affect any row (if the condition not matches), and will return 0. So, it is indicated to use this statement to check the result: if($count !== false) .
– Not: if(!$count)

DELETE

The DELETE instruction deletes rows in a table.
Syntax:

The next example deletes all the rows in the “sites” table where the value in “category” column is ” education ” or ” programming “. – Result:

AAffected rows: 2

– In the next lesson you can learn how to select and get data stored in a MySQL table, using the PDO query() method.

M E N U


How to Add a Digital Signature into PDF Document #software, #function, #pdf, #document, #pdf #file, #pdf #document, #adobe, #acrobat #reader, #adobe #acrobat, #document #management, #new, #blank, #page, #merge, #merger, #combine, #insert, #split, #splitter, #extract, #split, #reorder, #renumber, #extract, #replace, #delete, #rotate, #rotation, #crop, #margin, #action, #bookmark, #xml, #import, #export, #header, #footer, #watermark, #stamp, #stamper, #style, #text, #image, #bmp, #jpg, #gif, #png, #tiff, #attach, #attachment, #javascript, #js, #digital #signature


#

PDF Document Management 14: Add a Digital Signature into PDF Document

A digital signature (ID). like a conventional handwritten signature, identifies the person signing a document. Unlike a handwritten signature, a digital signature is difficult to forge because it contains encrypted information that is unique to the signer and easily verified. It is usually password protected and can be stored on your computer in PKCS #12 file format (Personal Information Exchange File, PFX).

When you buy a new digital signature, you get .spc file that contains the certificate and .pvk file that contains your private keys. U se Microsoft command-line tool Pvk2Pfx to convert them into a PFX file. See detail here.

The following command generates the .pfx file Mypfxfile.pfx from Mypvkfile.pvk and Myspcfile.spc. The command supplies the password mypassword for the .pvk file, which becomes the password for the .pfx file Mypfxfile.pfx:

pvk2pfx -pvk mypvkfile.pvk -pi mypassword -spc myspcfile.spc -pfx mypfxfile.pfx

This function can create document-level Digital Signature that apply to the entire document.

Here are the steps on how to Add Digital Signature into PDF Document.

2. Select a PFX file with digital signature.

3. The Create Digital Signature to Document dialog box comes up:

  • Select a File. Select a PFX file with digital signature.
  • Enter Password. The password for the digital ID.
  • Allow Multiple Signatures. If checked, the signature and all the other content will be added as a new revision thus not invalidating existing signatures.
  • Keystore Type. The specified keystore type. pkcs12 is the most common type.
  • Keystore Provider. Sets the Cryptographic Service Provider that will sign the document. Leave it empty for pkcs12 type.
  • Signed Type. The mode can be Self signed (Adobe.PPKLite). VeriSign plug-in (VeriSign.PPKVS) and Windows Certificate Security (Adobe.PPKMS).
  • Certification Level. The certification level can be NOT_CERTIFIED. CERTIFIED_NO_CHANGES_ALLOWED. CERTIFIED_FORM_FILLING and CERTIFIED_FORM_FILLING_AND_ANNOTATIONS .
  • Reason. Sets the signing reason.
  • Location. Sets the signing location.
  • Contact. Sets the signing contact.
  • Appearance.
    • Visible. Sets the signature to be visible on the Position of the selected Page.
    • Page Number. Select the page number for the digital signature.
    • Appearance: There are 4 Options: Description Only, Signer Name and Description, Signature Image and Description, and Signature Image only.
    • Let/Right/Top/Bottom. The position for the digital signature.
    • Use Signature Image. Set the signature image if the Appearance option is Signature Image and Description
    • Use Background Image. Set the background image. Leave it blank if no background image.
    • Background Image Scale. Set the scaling to be applied to the background image.

4. Click Close to finish.

Question 1: The Validity of digital signature is displayed as UNKNOWN inside Adobe Reader, how to make Signature Valid ?

Answer:
1. Click inside the signature with Validity Unknown ;
2. The dialog of Signature Validity Status will show up. Click Signature Properties ;
3. From Dialog Signature Properties . click Show Signer’s Certificate ;
4. From Dialog Certificate Viewer , click Trust Tab and then click Add to Trusted Certificates ;
5. Import Contact Settings will come up, click OK.
6. Close Adobe Reader and open your PDF again. You will see the Signature Valid .

Question 2: How to remove the imported digital signature from my computer?

Answer:
1. Open Adobe Reader= Edit Menu= Preferences= Signatures= Identities Trusted Certificates= More;
2. Dialog Digital ID and Trusted Certificate Settings comes up, click Trusted Certificates . Select the Certificate to remove.
3. From Internet Explorer = Tools Menu = Internet Options= Contents= Certificates= Select the Certificate to remove.

PDFill Copyright � 2002-2017 by PlotSoft L.L.C. All rights reserved.