How does the UNSIGNED data type in PHP prevent negative values in a database?

The UNSIGNED data type in PHP prevents negative values in a database by specifying that the column can only store non-negative integers. This means that any attempt to insert a negative value into a column with the UNSIGNED data type will result in an error. By using the UNSIGNED data type, you can ensure that only positive values are stored in the database column.

CREATE TABLE example_table (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    quantity INT UNSIGNED
);