Quickly Manage SQL Functions in PHP
- executeQuery
- fetchData
- fetchList
- isSQLDataExist
- isSQLListEmpty
- countRows
- countRowsInTable
- isTableEmpty
- createTable
- insertNewColumn
- editColumn
- deleteColumn
- deleteTable
- emptyTable
- insertRow
- updateRow
- sqlPrimaryKey
- sqlUniqueKey
- setPHPErrors
- isTablePresent
- uploadFile
executeQuery("DELETE FROM TESTDB WHERE id = 1");
fetchData("SELECT * FROM TESTDB");
fetchData("SELECT * FROM TESTDB", false); // may cause errors due to incorrect sql statement, which returns multiple rows
fetchList("SELECT * FROM TESTDB");
isSQLDataExist("SELECT * FROM TESTDB");
isSQLListEmpty("SELECT * FROM TESTDB");
countRows("SELECT * FROM TESTDB");
countRowsInTable("tableName");
isTableEmpty("tableName");
$createVariable = new createTable("tableName");
$createVariable->createColumn($columnName, $dataType, $size = 0, $defaultValue = "", $canBeNull = true, $isPrimaryKey = false, $autoIncrement = false);
$createVariable->createColumnWithSql("CREATE TABLE SQL"); //optional
$createVariable->createTable(); // returns boolean
insertNewColumn($tableName, $newColumnName, $dataType, $size = 0, $defaultValue = "", $canBeNull = true, $isPrimaryKey = false, $autoIncrement = false, $insertAfter = "LAST");
editColumn($tableName, $columnName, $newColumnName = "", $dataType, $size = 0, $defaultValue = "", $canBeNull = true, $isPrimaryKey = false, $autoIncrement = false, $insertAfter = "LAST");
deleteColumn($tableName, $columnName);
deleteTable($tableName);
emptyTable($tableName);
$insertVariable = new insertRow("tableName");
$insertVariable->addColumnData($columnName, $value);
$insertVariable->insertRow();
$updateVariable = new updateRow("tableName");
$updateVariable->addColumnData($columnName, $value);
$updateVariable->updateRow($condition);
$sqlPrimaryKey = new sqlPrimaryKey("tableName");
$sqlPrimaryKey->addPrimaryKey($columnName);
$sqlPrimaryKey->setKeys();
$sqlUniqueKey = new sqlUniqueKey("tableName");
$sqlUniqueKey->addUniqueKey($columnName);
$sqlUniqueKey->setKeys();
setPHPErrors(false); //hide all errors & warnings
isTablePresent($tableName); //Returns true if the Table exists in the database. Otherwise returns false.
$uploadImage = new uploadFile();
$uploadImage->setDirectory("uploads/"); //set directory where the file should be uploaded.
$uploadImage->setMaxSize(10); //Set Maximum Size of the File to be uploaded (in MB). Set 0 for unlimited size.
$uploadImage->setFileFormats(array("jpg", "png", "jpeg", "gif")); //List of file formats to be accepted for Upload. Set Empty array for all File formats.
$uploadImage->setReplaceFile(true); //Set True to replace the existing file. Otherwise set False. Default is false.
$uploadImage->setFileName("myimage2.".$uploadImage->getFileExtension($_FILES['imgfile'])); //set a custom file name.
$uploadImage->setReplaceFile(true); //Replace the existing file with same name.
$uploadImage->compressImage(true, $compression_quality, $keep_original); // (optional) Compress the image.
/*
Compression Quality should be Minimum 0 (Lowest compression quality) and Maximum 100 (highest compression quality).
If Keep Original is set to true, only one file gets saved. Otherwise Both original and compressed files are saved.
*/
echo $uploadImage->setCompressedImageDirectory("uploads/compressed/"); //(optional) The Relative File Directory where the Compressed Image is stored.
echo $uploadImage->uploadFile($_FILES['imgfile'], true); //Upload the file
echo $uploadImage->getFileLink(); //Get the Relative file Link of the uploaded file.
echo $uploadImage->getCompressedImageLink(); //Get the Relative file Link of the compressed Image.