NJC Tattoo is a small-scale growing tattoo business based in Mandaue City, Cebu, Philippines. It is run and owned by Mr. Noel John Cabahug, a freelance tattoo artist with a passion for art.
The primary objective of this project is to develop an online Information System for NJC Tattoo using the database approach. The system will largely automate the process of managing and organizing the client's business and provide them greater freedom and control over their operations, as well as enable tattoo inclined individuals to easily avail themselves of the services offered by NJC Tattoo with convenience.
- Run Apache and MySQL server on XAMPP
- Import
njctattoo_db.sql
to phpMyAdmin - Access app on http://localhost/NJCTattoo/client/index.php
Admin View
Client View
General Use Functions
Santizes the given data. Returns the sanitized data. Example of integer sanitization, do
$data = $api->sanitize_data("1Lorem2ipsum3dolor4sit5amet", "int");
// $data = 12345;
Example of float sanitization, do
$data = $api->sanitize_data("1Lorem2ipsum3dolor4sit5amet.67", "float");
// $data = 12345.67;
Example of email sanitization, do
$data = $api->sanitize_data("john.doe@test.com", "email");
// $data = 'john.doe@test.com';
Example of string (default case) sanitization, do
$data = $api->sanitize_data(" <script>console.log('This is an attack.')</script> ", "string");
// $data = 'console.log('This is an attack');';
Validate the given data. Returns true if the data is valid, else, false. Integer validation valid case
$data = $api->validate_data(12345, "int");
// $data = true;
Integer validation invalid case
$data = $api->validate_data("1Lorem2ipsum3dolor4sit5amet", "int");
// $data = false;
Float validation valid case
$data = $api->validate_data(12345.67, "float");
// $data = true;
Float validation invalid case
$data = $api->validate_data("1Lorem2ipsum3dolor4sit5amet.67", "float");
// $data = false;
Email validation valid case
$data = $api->sanitize_data("john.doe@test.com", "email");
// $data = true;
Email validation invalid case
$data = $api->sanitize_data("invalid-email#test+com", "email");
// $data = 'false';
Date validation valid case
$data = $api->validate_data("010-17-2000", "date");
// $data = true;
Date validation invalid case - Invalid date
$data = $api->validate_data("02-31-2000", "date");
// $data = false;
Date validation invalid case - Past date
// today = '05-05-2001'
$data = $api->validate_data("05-03-2000", "date");
// $data = false;
Time validation valid case
$data = $api->validate_data("05:30:00", "time");
// $data = true;
Time validation invalid case
$data = $api->validate_data("13:72:00", "time");
// $data = false;
String (default case) valid case
$data = $api->sanitize_data("Hello world!", "string");
// $data = 'true';
MySQLi Functions
Clause Helpers
Returns the given query string with the specified tables. To specify a single table, do
$query = $api->table($query, $table);
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
// $query = 'SELECT * FROM table';
To specify multiple tables, do
$query = $api->table($query, array($arg1, $arg2, ..., $argN));
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, array('table1', 'table2'));
// $query = 'SELECT * FROM table1, table2';
Returns a join clause string with the specified join type.
To construct a default JOIN (INNER), do
$join_clause = $api->join('', 'tableLeft', 'tableRight', 'tableLeft.column', 'tableRight.column');
// $join_clause = '(tableLeft JOIN tableRight ON tableLeft.column=tableRight.column)';
To construct a LEFT JOIN, do
$join_clause = $api->join('left', 'tableLeft', 'tableRight', 'tableLeft.column', 'tableRight.column');
// $join_clause = '(tableLeft LEFT JOIN tableRight ON tableLeft.column=tableRight.column)';
To construct a RIGHT JOIN, do
$join_clause = $api->join('right', 'tableLeft', 'tableRight', 'tableLeft.column', 'tableRight.column');
// $join_clause = '(tableLeft RIGHT JOIN tableRight ON tableLeft.column=tableRight.column)';
To construct a nested JOIN, do
$nested_join= $api->join('', 'table1', 'table2', 'table1.column', 'table2.column');
$join_clause = $api->join('', $nested_join, 'table3', 'table2.column', 'table3.column');
// $join_clause = '((table1 JOIN table2 ON table1.column=table2.column) JOIN table3 ON table2.column=table3.column)';
Returns the given query string with the specified SQL WHERE clause. To specify a single condition, do
$query = $api->where($query, $column, $param);
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, 'column', 1);
// $query = 'SELECT * FROM table WHERE column=1';
Another example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, array('table1', 'table2'));
$query = $api->where($query, 'table1.column', 'table2.column');
// $query = 'SELECT * FROM table1, table2 WHERE table1.column=table2.column';
To specify multiple conditions, do
$query = $api->order($query, array($arg1, $arg2, ..., $argN), array($arg1, $arg2, ..., $argN));
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->order($query, array('column1', 'column2'), array('value1', 'value2'));
// $query = 'SELECT * FROM table WHERE column1=value1 AND column2=value2;
Returns the given query string with the specified limit.
$query = $api->limit($query, $int);
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->limit($query, 2);
// $query = 'SELECT * FROM table LIMIT 2';
Returns the given query string with the specified order. To specify ordering by a single column, do
$query = $api->order($query, $column, $type);
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->order($query, 'column', 'ASC');
// $query = 'SELECT * FROM table ORDER BY column ASC';
To specify ordering by multiple columns, do
$query = $api->order($query, array($arg1, $arg2, ..., $argN), array($arg1, $arg2, ..., $argN));
Example:
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->order($query, array('column1', 'column2'), array('ASC', 'DESC'));
// $query = 'SELECT * FROM table ORDER BY column1 ASC, column2 DESC';
Select Functions
Returns SQL SELECT to the calling string.
$query = $api->select();
// $query = 'SELECT ';
Returns the given query string with its defined parameters. To specify a single parameter, do
$query = $api->params($query, '*');
// $query = 'SELECT * ';
To specify multiple parameters, do
$query = $api->params($query, array($arg1, $arg2, ..., $argN));
Example:
$query = $api->select();
$query = $api->params($query, array('column1', 'column2', 'column3'));
// $query = 'SELECT column1, column2, column3 ';
Returns the given query string with SQL FROM.
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
// $query = 'SELECT * FROM ';
To construct a select query, do
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
// $query = 'SELECT * FROM table';
Insert Functions
Returns SQL INSERT to the calling string.
$query = $api->insert();
// $query = 'INSERT INTO ';
Returns the given query string with the specified columns to insert values at.
$query = $api->columns($query, array($arg1, $arg2, ..., $argN));
Example:
$query = $api->insert();
$query = $api->table($query, 'table');
$query = $api->columns($query, array('column1', 'column2', 'column3'));
// $query = 'INSERT INTO table (column1, column2, column3) ';
Returns the given query string with SQL VALUES.
$query = $api->insert();
$query = $api->table($query, 'table');
$query = $api->columns($query, array('column1', 'column2'));
$query = $api->values($query);
// $query = 'INSERT INTO table (column1, column2) VALUES ';
To construct an insert query, do
$query = $api->insert();
$query = $api->table($query, 'table');
$query = $api->columns($query, array('column1', 'column2', 'column3'));
$query = $api->values($query);
$query = $api->columns($query, array('value1', 'value2', 'value3'));
// $query = 'INSERT INTO table (column1, column2, column3) VALUES (value1, value2, value3)';
Update Functions
Returns SQL UPDATE to the calling string.
$query = $api->update();
// $query = 'UPDATE ';
Returns the given query string with the specified column-value pairs. To specify a single column-value pair, do
$query = $api->set($query, $column, $value);
To specify multiple column-value pairs, do
$query = $api->set($query, array($col1, $col2, ..., $colN), array($value1, $value2, ..., $valueN));
Example:
$query = $api->update();
$query = $api->table($query, 'table');
$query = $api->set($query, array('column1', 'column2', 'column3'), array('value1', 'value2', 'value3'));
// $query = 'UPDATE table SET column1=value1, column2=value2, column3=value3 ';
To construct an update query, do
$query = $api->update();
$query = $api->table($query, 'table');
$query = $api->set($query, array('column1', 'column2', 'column3'), array('value1', 'value2', 'value3'));
$query = $api->where($query, 'column', 'value');
// $query = 'UPDATE table SET column1=value1, column2=value2, column3=value3 WHERE column=value';
Delete Function
Returns SQL DELETE to the calling string.
$query = $api->delete();
// $query = 'DELETE ';
To construct a delete query, do
$query = $api->delete();
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, 'column', 'value');
// $query = 'DELETE FROM table WHERE column=value';
Prepared Statement Functions
Prepares the given SQL query string for execution. Returns a statement object on success, false on failure.
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$statement = $api->prepare($query);
Binds variables to the given prepared statement. Returns true on success, false on failure. To bind a single variable, do
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, 'column', '?');
$statement = $api->prepare($query);
$boolean = $api->bind_params($statement, "i", 1);
To bind multiple variables, do
$query = $api->select();
$query = $api->params($query, '*');
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, array('column1', 'column2', 'column3'), array('?', '?', '?'));
$statement = $api->prepare($query);
$boolean = $api->bind_params($statement, "sis", array('param1', 2, 'param3'));
Binds variables to the given prepared statement. Returns an array of all the bound variables on success, false on failure.
$query = $api->select();
$query = $api->params($query, array('column1', 'column2', 'column3'));
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, 'column', '?');
$statement = $api->prepare($query);
$api->bind_params($statement, "s", $value);
$api->execute($statement);
$api->store_result($statement);
$boolean = $api->bind_result($statement, array($key1, $key2, $key3));
Sets the value of $param to $bound_result. api->get_bound_result() is used to get the values from the array returned by api->bind_result().
$query = $api->select();
$query = $api->params($query, array('column1', 'column2', 'column3'));
$query = $api->from($query);
$query = $api->table($query, 'table');
$query = $api->where($query, 'column', '?');
$statement = $api->prepare($query);
$api->bind_params($statement, "s", $value);
$api->execute($statement);
$api->store_result($statement);
$boolean = $api->bind_result($statement, array($key1, $key2, $key3));
Executes the given prepared statement. Returns true on success, false on failure.
$query = $api->select();
...
$statement = $api->prepare($query);
$boolean = $api->execute($statement);
Stores the result set of a successfully executed statement in an internal buffer. Returns true on success, false on failure.
$query = $api->select();
...
$api->execute($statement);
$boolean = $api->store_result($statement);
Gets the result set of a prepared statement. If the prepared statement was successfully executed, $api->get_result() returns it's result set, else, it returns false.
$query = $api->select();
...
$api->execute($statement);
$res = $api->get_result($statement);
Returns the number of rows in a given result set. If no rows are found, $api->num_rows() returns 0.
$query = $api->select();
...
$res = $api->get_result($statement);
$count = $api->num_rows($res);
Fetches a single row from a given result set. $api->fetch_assoc() returns an associative array representing the fetched row, null if there are no more rows in the result set, or false on failure.
$query = $api->select();
...
$res = $api->get_result($statement);
$row = $api->fetch_assoc($res);
Frees the memory associated with a result.
$query = $api->select();
...
$statement = $api->prepare($query);
...
$api->free_result($statement);
Closes the given prepared statement. Returns true on success, false on failure.
$query = $api->select();
...
$statement = $api->prepare($query);
...
$api->free($statement);
$boolean = $api->close($statement);
CIS 2104 - Information Management 2 Group 8
- Lenel John Baring
- Jan Ann Ebon
- Jan Michael Garot
- Dustin Adrianne Zanoria
✅ Complete - July 21, 2022