Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started SQL class. Started SQLi class for table installs. Added place…
…holders for some of the table generation. Wrote bash script to generate SHA1 checksums for SQL queries to reduce risk of inserting bad data into table.
- Loading branch information
Showing
15 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
<?php | ||
|
||
class MySQLQueries { | ||
|
||
// List of all eras | ||
private const $getEras = | ||
"SELECT * FROM ?eras ORDER BY name ASC"; | ||
|
||
// Count number of first names | ||
private const $getFirstNameCount = | ||
"SELECT COUNT(*) FROM ?names " + | ||
"WHERE isfirstname_sw = true " + | ||
"AND deleted_dt IS NOT NULL"; | ||
|
||
// Count number of last names | ||
private const $getLastNameCount = | ||
"SELECT COUNT(*) FROM ?names " + | ||
"WHERE isfirstname_sw = false " + | ||
"AND deleted_dt IS NOT NULL"; | ||
|
||
// Retrieve first and last name from a random index | ||
private const $getFullName = | ||
"SELECT name FROM ?names " + | ||
"WHERE isfirstname_sw = true " + | ||
"LIMIT ?, 1 " + | ||
"UNION SELECT name FROM ?names " + | ||
"WHERE isfirstname_sw = false " + | ||
"LIMIT ?, 1 " | ||
} | ||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* SQLi Class | ||
* Handles all database interactions for installation | ||
* | ||
* @package src/install | ||
* @author Brian Turchyn | ||
*/ | ||
|
||
class SQLiInstall extends mysqli { | ||
private $handle; | ||
|
||
public function __construct($host, $user, $pass, $database) { | ||
parent::__construct($host, $user, $pass, $database); | ||
// Check for errors | ||
if($this->connect_error()) { | ||
die("Connection error (" . $this->connect_errno() . ") " . $this->connect_error()); | ||
} | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE IF NOT EXISTS ?eras | ||
( era_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
era_name VARCHAR(128) NOT NULL, | ||
deleted_dt TIMESTAMP NULL DEFAULT NULL ) | ||
ENGINE=MyISAM | ||
DEFAULT CHARACTER SET = utf8; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
75b37d9a300ffdb392dd4701a4b92cff7e7169cd |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
da39a3ee5e6b4b0d3255bfef95601890afd80709 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
da39a3ee5e6b4b0d3255bfef95601890afd80709 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
da39a3ee5e6b4b0d3255bfef95601890afd80709 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
da39a3ee5e6b4b0d3255bfef95601890afd80709 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
da39a3ee5e6b4b0d3255bfef95601890afd80709 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
###################################################################### | ||
# SHA1 Checksum Generator | ||
# Using this will re-generate all checksums for all SQL queries. | ||
# | ||
# @package src/install | ||
# @author Brian Turchyn | ||
###################################################################### | ||
|
||
shopt -s nullglob | ||
|
||
clear | ||
|
||
echo '====================================================================' | ||
echo '= =' | ||
echo '= !!! WARNING !!! =' | ||
echo '= =' | ||
echo '= This will re-generate all SHA1 checksums for your SQL install =' | ||
echo '= queries. Doing this will defeat the purpose of the checksums =' | ||
echo '= being in place. =' | ||
echo '= =' | ||
echo '= Only use this if you know what you are doing! =' | ||
echo '= =' | ||
echo '====================================================================' | ||
echo | ||
echo | ||
echo "Press Ctrl+C NOW if you want to back out of this." | ||
|
||
read -n 1 -s | ||
|
||
echo | ||
echo | ||
|
||
for f in *.sql | ||
do | ||
echo "Generating SHA1 checksum for $f..." | ||
sha1 -q $f > $f.sha1 | ||
done | ||
|
||
echo | ||
echo 'Done!' |