$fileOutputMode
$fileOutputMode :
PDOCrud - Advance PHP CRUD application generator using PDO File: PDOCrud.php Author: Pritesh Gupta Version: 4.8.1 Release Date: 21-Aug-2016 Last Update : 25-Oct-2020
Copyright (c) 2020 Pritesh Gupta. All Rights Reserved.
PDOCrud is an advance PHP based CRUD(Create, Read, Update and Delete) generator application. It supports Mysql, Pgsql, MSSQL and Sqlite database. By writing just 2-3 lines of code only, you can perform insert/update/delete and select operation. You just to need to create object and call for render function for that table and everything will be generated automatically. PDO Crud supports all types of database fields. Fields will be generated based on the data type. You can remove fields, change type of fields and can do various types of customization.
__construct(string $multi = false, string $template = "", string $skin = "", array $settings = array())
Constructor
string | $multi | If multiple instance of form used on the same page, then set this true to avoid loading multiple js/css |
string | $template | Set template directly |
string | $skin | Set skin/template directly |
array | $settings | Set default setting at the time of initialization |
joinTable(string $joinTableName, string $joinCondition, string $joinType = "INNER JOIN") : object
Add join between tables, supported join condition are "INNER JOIN" & "LEFT JOIN"
string | $joinTableName | name of table to be joined |
string | $joinCondition | join condition e.g. |
string | $joinType | type of join (Inner or left join)-default is inner join |
Object of class
crudAddAction(string $actionName, string $colName, array $displayVal = array(), array $applyVal = array()) : object
Add a custom action button in crud
string | $actionName | name of action |
string | $colName | column name to be action applied |
array | $displayVal | display value of button based on the column value |
array | $applyVal | On click, apply value to the column |
Object of class
crudColTooltip(string $colName, string $tooltip, string $tooltipIcon = "<i class='glyphicon glyphicon-info-sign'></i>") : object
Tooltip for the column
string | $colName | Name of columns for which tooltip needs to be added |
string | $tooltip | Tooltip to be shown |
string | $tooltipIcon | Icon for the tooltip |
Object of class
formTag(string $formHeading = "", string $formType = "", array $class = array(), array $attr = array()) : object
Set form related parameters e.g. formHeading, formType="horizontal/inline", form class and attribute etc.
string | $formHeading | Heading of form (fieldset) |
string | $formType | Type of form (normal, horizontal or inline) for bootstrap |
array | $class | CSS Class for form |
array | $attr | Various data attributes for form |
Object of class
formSendEmail(string $from, string $to, string $subject, string $message, boolean $saveDb = false) : object
Set email related settings if form sends email instead of insert/update operation
string | $from | From email |
string | $to | To email |
string | $subject | Subject of email |
string | $message | Message of the email |
boolean | $saveDb | whether to save msg in database or not |
Object of class
formDisplayInPopup(string $buttonContent = "", string $headerContent = "", string $directCall = false) : object
Display form in popup on click on some button
string | $buttonContent | Text for the button |
string | $headerContent | Header text for the popup |
string | $directCall | Set this true to use it for form directly |
Object of class
fieldFormula(string $field, string $formatType, array $paramaters) : object
Set field formula to change the value of field dynamically during insert/update operation
string | $field | Field to be modified |
string | $formatType | Type of formula, e.g. string or formula(math forumula) |
array | $paramaters | parameters to be used for formula |
Object of class
formStaticFields(string $fieldName, string $fieldType, string $fieldValue = "", string $extra = "static", string $dbField = "") : object
Add static fields to the form
string | $fieldName | name of static field |
string | $fieldType | type of field, e.g. radio, checkbox etc |
string | $fieldValue | Value of the field |
string | $extra | Whether it is static field or database field |
string | $dbField | Database field name if it is database field type |
Object of class
fieldAttributes(string $fieldName, array $attr = array()) : object
Sets the data attribute of field
string | $fieldName | field name for attribute needs to set |
array | $attr | Array of data attributes with key as attribute name and value as attribute value |
Object of class
fieldValidationType(string $fieldName, string $validation, string $param = "true", string $errorMsg = "", string $fieldType = "table") : object
Sets the validation require for the field
string | $fieldName | field name for validation needs to be set |
string | $validation | validation like required, email etc |
string | $param | value of validation, default is true |
string | $errorMsg | error message to be displayed |
string | $fieldType | field type |
Object of class
fieldDependent(string $dependent, string $dependOn, string $colName) : object
Sets the dependent field to be loaded on change of depend on field
string | $dependent | field name to be changed on onchange operation of dependOn field |
string | $dependOn | field that change will cause trigger change |
string | $colName | name of col, needs to be retrived to change the field value |
Object of class
fieldDataBinding(string $fieldName, mixed $dataSource, string $key, mixed $val, string $bind = "db", string $separator = " ", string $where = array(), string $orderby = array()) : object
Sets data binding of the field i.e. load the field data from some datasource
string | $fieldName | field name to be bind |
mixed | $dataSource | data source either tablename or array of data |
string | $key | name of col, that will serve as data key |
mixed | $val | name of col as string or array of columns, that will serve as field value |
string | $bind | whether datasource is db table or array or sql, default is db table |
string | $separator | Separator string in case of $val is an array of columns. Default value is " " |
string | $where | Where condition for the datasource |
string | $orderby | Order by clause for the datasource |
Object of class
fieldAddOnInfo(string $fieldName, string $position, string $addOnText) : object
Sets input addon information for the bootstrap
string | $fieldName | field name for input addon needs to be added |
string | $position | position of addon text, whether before or after input it needs to be added |
string | $addOnText | add on content that will be added in html format |
Object of class
fieldBlockClass(string $fieldName, string $class) : object
Sets the class of complete input block inside a bootstrap form-group class
string | $fieldName | field name for which block class needs to be added |
string | $class | class name like col-sm-8 etc. |
Object of class
fieldGroups(string $groupName, array $fields = array()) : object
Group fields together like first_name and last_name under Full name group
string | $groupName | Any unuique name of group e.g. full_name |
array | $fields | array of fields like array(first_name, last_name) |
Object of class
FormSteps(array $fields, string $stepName, string $stepType = "stepy", string $attr = array()) : object
Divide form fields into various steps/tabs
array | $fields | Array of fields that will be in same tab |
string | $stepName | Name of step(Tab) |
string | $stepType | Step type either stepy or tabs |
string | $attr | Attributes of the step |
Object of class
fieldTooltip(string $fieldName, string $tooltip, string $tooltipIcon = "<i class='glyphicon glyphicon-info-sign'></i>") : object
Tooltip for the field
string | $fieldName | Name of field for which tooltip needs to be added |
string | $tooltip | Tooltip to be shown |
string | $tooltipIcon | Icon for the tooltip |
Object of class
formFieldValue(string $fieldName, string $value, boolean $fieldHidden = false, string $tablename = "") : object
Set a value of field
string | $fieldName | field name to renamed |
string | $value | value of the field |
boolean | $fieldHidden | Wheter that field is hidden or not |
string | $tablename | Tablename = Required only when using join table field name |
Object of class
formRedirection(string $redirectionURL, boolean $reset = false) : object
Redirects to some other url after form submission
string | $redirectionURL | url to be redirected |
boolean | $reset | whether to reset it to empty string when no data present. |
Object of class
fieldConditionalLogic(string $fieldname, string $condition, string $op = "=", string $field, string $task) : object
Add conditional logic to the form fields like
string | $fieldname | field name which trigger event |
string | $condition | Conditional logic to be checked |
string | $op | Operator to b used |
string | $field | field names to be affected |
string | $task | Operation(task) to be applied |
Object of class
addFieldDesc(string $elementName, string $desc, string $type = "field") : object
Add field description
string | $elementName | element for which tooltip needs to be added |
string | $desc | description of the field |
string | $type | type of element whether element or column |
Object of class
thumbnailImage(integer $width, integer|null $height = null, string $focal = 'center') : object
Trim the image and resize to exactly This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified. Useful for generating thumbnails.
integer | $width | |
integer|null | $height | If omitted - assumed equal to $width |
string | $focal |
Object of class
imageText(string $text, string $font_file, float|integer $font_size = 12, string|array $color = '#000000', string $position = 'center', integer $x_offset, integer $y_offset, string|array $stroke_color = null, string $stroke_size = null, string $alignment = null, integer $letter_spacing) : object
Add text to an image
string | $text | |
string | $font_file | |
float|integer | $font_size | |
string|array | $color | |
string | $position | |
integer | $x_offset | |
integer | $y_offset | |
string|array | $stroke_color | |
string | $stroke_size | |
string | $alignment | |
integer | $letter_spacing |
Object of clas
watermark(string $overlay, string $position = 'center', float|integer $opacity = 1, integer $xOffset, integer $yOffset)
Set the overlay image (Watermark) Overlay an image on top of another, works with 24-bit PNG alpha-transparency
string | $overlay | An image filename or a SimpleImage object |
string | $position | center|top|left|bottom|right|top left|top right|bottom left|bottom right |
float|integer | $opacity | Overlay opacity 0-1 |
integer | $xOffset | Horizontal offset in pixels |
integer | $yOffset | Vertical offset in pixels return object Object of class |
bulkCrudUpdate(string $colName, string $fieldType, array $attr = array(), array $fieldData = array()) : object
Bulk crud table update function to update multiple rows of data simultanously
string | $colName | Column name to be formatted |
string | $fieldType | type of field |
array | $attr | Attributes of field |
array | $fieldData | Data for the field |
Object of class
tableColFormatting(string $colName, string $formatType, array $paramaters = array()) : object
Format the particular columns of table
string | $colName | Column name to be formatted |
string | $formatType | type of format |
array | $paramaters | parameters based on the formatting type |
Object of class
viewColFormatting(string $colName, string $formatType, array $paramaters = array()) : object
Format the particular columns of view form
string | $colName | Column name to be formatted |
string | $formatType | type of format |
array | $paramaters | parameters based on the formatting type |
Object of class
tableDataFormatting(string $applyOn, string $formatType, array $condition = array(), array $apply = array()) : object
Format the particular entry of column of table
string | $applyOn | Column name to be formatted |
string | $formatType | type of format |
array | $condition | format condition ot be matched |
array | $apply | rules toe be applied |
Object of class
tableColAddition(string $colName, string $type, array $paramaters = array()) : object
Add a new column to the table
string | $colName | Column name to be added |
string | $type | type of column |
array | $paramaters | parameters on basis of which column to be added |
Object of class
tableColUsingDatasource(string $colname, string $data, string $joinColName, string $dataCol, string $dataSource = "db") : object
Set content of crud col based on the value from another table or array of data
string | $colname | crud table column name to be replaced |
string | $data | Name of table (if datasource = db) or array to get data |
string | $joinColName | Join column name (if datasource = db) |
string | $dataCol | Data column name (if datasource = db) |
string | $dataSource | dataSource = db or datasource = array |
Object of class
addTooltip(string $elementName, string $toolTip, string $type = "field") : object
Add tool tip
string | $elementName | element for which tooltip needs to be added |
string | $toolTip | tooltip to be added |
string | $type | type of element whether element or column |
Object of class
relatedData(string $mainTableCol, string $relTable, mixed $relTableCol, mixed $relDisplayCol, array $where = array(), array $orderby = array(), mixed $fieldType = "select") : object
Get related column data as list from other tables
string | $mainTableCol | Column name of the main table |
string | $relTable | Related table name |
mixed | $relTableCol | Matching related table columns |
mixed | $relDisplayCol | Related table column to be display |
array | $where | where condition array |
array | $orderby | Order by condition array |
mixed | $fieldType | Field type to be displayed for that field, default is "select", if empty, then textarea will be shown |
Object of class
where(string $colName, string $val, string $operator = "=", string $andOroperator = "", string $bracket = "") : object
Add where condition
string | $colName | column name for which where condition to be applied |
string | $val | value of column |
string | $operator | any operator like =, !=, default value is "=" |
string | $andOroperator | whether to use "and" or "or" operator, if empty, default andOrOperator = "and" will be used |
string | $bracket | whether to use opening "(" or closing bracket ")", leave empty if not required |
Object of class
addFilter(string $filterName, string $displayText, string $matchingCol, string $filterType) : object
Add advanced filter option
string | $filterName | unique filter name |
string | $displayText | display text for filter |
string | $matchingCol | column to be matched |
string | $filterType | type of filter , default is radio button |
Object of class
setFilterSource(string $filterName, mixed $dataSource, string $key, string $val, string $bind = "db") : object
Set data source of filter
string | $filterName | unique filter name |
mixed | $dataSource | data source either tablename or array of data |
string | $key | name of col, that will serve as data key |
string | $val | name of col, that will serve as field valye |
string | $bind | whether datasource is db table or array, default is db table |
Object of class
setAdvSearchSource(string $columnName, mixed $dataSource, string $key, string $val, string $bind = "db") : object
Set data source of advance search columns
string | $columnName | column name to be searched |
mixed | $dataSource | data source either tablename or array of data |
string | $key | name of col, that will serve as data key |
string | $val | name of col, that will serve as field valye |
string | $bind | whether datasource is db table or array, default is db table |
Object of class
setAdvSearchParam(string $columnName, string $displayText, string $searchType) : object
Add advanced search column parameter
string | $columnName | unique filter name |
string | $displayText | display text for filter |
string | $searchType | type of filter , default is radio button |
Object of class
setTriggerOperation(string $tableName, array $colVal, array $where, string $operationType = "update", string $event = "after_update") : object
Trigger another operation after current operation completed e.g. update another table's data
string | $tableName | unique table name |
array | $colVal | array of column name and value |
array | $where | where condition with column name and value |
string | $operationType | operation type i.e. insert update or delete |
string | $event | At which event, we need to perform this operation i.e. before_update, after_update |
Object of class
addSidebar(string $sidebarImage, string $sidebarHeading1, string $sidebarHeading2, array $sidebarURLs, string $position = "left") : object
Add sidebar to existing data in edit/view form
string | $sidebarImage | column name of image or url of image |
string | $sidebarHeading1 | column name for sidebar heading 1 or some text |
string | $sidebarHeading2 | column name for sidebar heading 2 or some text |
array | $sidebarURLs | sidebar urls |
string | $position | Position of the sidebar (either left or right) |
Object of class
enqueueActions(array $action, string $type = "switch", mixed $text = "", string $colName = "", array $attr = array()) : object
enqueue col based actions
array | $action | action values |
string | $type | type of action |
mixed | $text | text to be used |
string | $colName | name of column |
array | $attr | attribute of columns |
Object of class
enqueueBtnActions(array $actionName, mixed $action, string $type = "switch", mixed $text = "", string $colName = "", array $attr = array(), string $cssClass = "") : object
enqueue button actions
array | $actionName | name of acion |
mixed | $action | action values |
string | $type | type of action |
mixed | $text | text to be used |
string | $colName | name of column |
array | $attr | attribute of columns |
string | $cssClass | Css Class of buton |
Object of class
enqueueBtnTopActions(array $actionName, mixed $text = "", string $url = "javascript:;", array $attr = array(), string $cssClass = "") : object
enqueue button actions
array | $actionName | name of acion |
mixed | $text | text to be used |
string | $url | url |
array | $attr | attribute of columns |
string | $cssClass | Css Class of buton |
Object of class
forgotPassword(string $email, string $password, string $from = array(), string $subject = "", string $message = "", string $encryption = "md5") : object
Send email with password to email address
string | Email field of the table |
|
string | $password | password field of the table |
string | $from | from email to be used to send email |
string | $subject | subject of the email |
string | $message | message of the meail |
string | $encryption | encryption to be used, default type md5 |
Object of class
addDateRangeReport(string $text, string $type, string $dateField) : object
Add date range report buttons (eg daily ,monthly ,yearly report button)
string | $text | Name/Text of the button |
string | $type | Type of the report to be generated. |
string | $dateField | date field in the database to be used |
Object of class
exportDB(string $filename, string $includeTables = array(), string $excludeTables = array()) : object
Export complete database
string | $filename | File name |
string | $includeTables | Include particular tables |
string | $excludeTables | Exclude particular tables |
Object of class
setUserSession(string $sessionName, string $val) : object
Set session for select operation for user login management. By default, it checks value against database table, if it doesn't find value in database tab;e then value will be treated as string and will be saved in session.
string | $sessionName | Name/Text of the session |
string | $val | Value of the session (column name of table or some fixed value) |
Object of class
getUserSession(string $sessionKey = "")
Get array of sessions or particular session value, set by user for user management functionality using setSession function
string | $sessionKey | session key that needs to be retrived (optional) return array sesion set by user using setSession function |
unsetUserSession(string $sessionKey = "") : boolean
Unset array of sessions or particular session value, set by user for user management functionality using setSession function
string | $sessionKey | session key that needs to be unset (optional) |
If session is unset successfully, return true else return false
checkUserSession(string $sessionKey = "", string $val = array()) : boolean
Check whether session is set or not by user for user management functionality using setSession function
string | $sessionKey | session key that needs to be checked (optional) |
string | $val | value that needs to be checked (optional) |
return true/false depending upon session set or not
addChart(string $chartName, string $chartType, mixed $dataSource, string $key, string $val, string $bind = "db", string $param = array()) : object
Add pie chart, bar chart, google charts etc using add chart function
string | $chartName | Name of the chart |
string | $chartType | Chart type |
mixed | $dataSource | data source either tablename or array of data |
string | $key | name of col, that will serve as data key |
string | $val | name of col, that will serve as field valye |
string | $bind | whether datasource is db table or array or sql, default is db table |
string | $param | data parameter for the chart element |
Object of class
addPlugin(string $pluginName) : object
Add js/css based plugin, plugin needs to be placed inside plugins folder with js files under js folder and css files under css folder
string | $pluginName | Name of the plugin to be added, make sure plugins folder is readable |
Object of class
applyJS(string $applyOn, string $applyOnVal, string $functionName, string $action = "on_form_load", string $options = array()) : object
Add directly javascript
string | $applyOn | Apply on element name |
string | $applyOnVal | Value to be used of that element |
string | $functionName | function name |
string | $action | action to be used |
string | $options | options for that function |
Object of class
multiTableRelation(string $field1, string $field2, \PDOCrud $obj, string $renderParam = "CRUD") : object
Multi Table Relation (nested table) - Editing of related records in other table
string | $field1 | field name of object to matched |
string | $field2 | field name of 2nd object to be matched |
\PDOCrud | $obj | 2nd table (object) |
string | $renderParam | render type, default is CRUD |
Object of class
loadPluginJsCode(string $pluginName, string $elementName, array $params = array())
Loads plugin js code, must be called after render function
string | $pluginName | Name of plugin |
string | $elementName | Element name for which plugin needs to be called |
array | $params | list of parameters/options for the plugin js code return string String of js code |
setAjaxActions(string $elementName, string $event, string $callbackFunc, string $returnValueElement = "", array $otherElements = array()) : object
Set/Call ajax actions for the form elements on some js event
string | $elementName | Name of table column (element name) you want to apply event |
string | $event | Javascript event name |
string | $callbackFunc | Function to be called upon |
string | $returnValueElement | On which element, return value should be displayed |
array | $otherElements | Other elements to be passed along if any |
Object of class
setJsActions(string $element, string $formula, string $event, string $eventFields = array()) : object
Set/Call js actions for the form elements on some js event
string | $element | Main element, On which element, calculated value should be displayed |
string | $formula | Formula to be applied |
string | $event | Javascript event, this will be applied on formula fields if no event fields passed |
string | $eventFields | Event fields if any |
Object of class
setLeftJoinJsActions(string $element, string $formula, string $event, string $eventFields) : object
Set/Call js actions for the left join form elements
string | $element | Main element, On which, calculated value should be displayed |
string | $formula | Formula to be applied |
string | $event | Javascript event, this will be applied on formula fields if no event fields passed |
string | $eventFields | Event fields |
Object of class
fileUpload(string $fileName, string $fileUploadPath = "", integer $maxSize = 10000000, array $allowedFileTypes = array()) : boolean
Upload files using html file control. You can apply various restriction to make file uploading more secure.
string | $fileName | file upload control |
string | $fileUploadPath | Path to upload file |
integer | $maxSize | Max size allowed, default is 10000000 |
array | $allowedFileTypes | Allowed file types |
return true if file uploaded successfully else false
arrayToCSV(array $csvArray, string $outputFileName = "file.csv")
Generates the csv file as output from the array provided.
Returns true if operation performed successfully else return false.
array | $csvArray | Associative array with key as column name and value as table values. |
string | $outputFileName | Output csv file name |
arrayToXML(array $xmlArray, string $outputFileName = "file.xml")
Generates the xml as output from the array provided. Returns true if operation performed successfully else return false
array | $xmlArray | Associative array with key as column name and value as table values. |
string | $outputFileName | Output xml file name |
arrayToHTML(array $htmlArray, array $outputFileName = "file.html", boolean $isCalledFromPDF = false)
Generates the html table as output from the array provided.
array | $htmlArray | Associative array with key as column name and value as table values. |
array | $outputFileName | Output file name |
boolean | $isCalledFromPDF | This function is used internally in arrayToPDF() also, to check whether it is called directly or using the pdf function |
arrayToPDF(array $pdfArray, string $outputFileName = "")
Generates the pdf as output from the array provided. Returns true if operation performed successfully else return false
array | $pdfArray | Associative array with key as column name and value as table values. |
string | $outputFileName | Output pdf file name |
bulkImport(string $fileName, string $tableName)
Import data from csv/xml/excel file to database table directly. The key name(column name) must match the table column name to insert the data properly.
string | $fileName | Name or path of file. |
string | $tableName | Name of database table. |
sendEmail(array $to, string $subject, string $message, array $from = array(), string $altMessage = "", array $cc = array(), array $bcc = array(), array $attachments = array(), string $mode = "PHPMAIL", array $smtp = array(), $isHTML = true) : boolean
Sends email using phpmailer
array | $to | List of receipient |
string | $subject | Subject of email |
string | $message | Message of email |
array | $from | List of senders |
string | $altMessage | For non html clients |
array | $cc | List of cc |
array | $bcc | List of bcc |
array | $attachments | List of attachments |
string | $mode | Send mail using php mail function or SMTP, default is phpmail function |
array | $smtp | SMTP authentication details if SMTP mode is used |
$isHTML |
return true if email function works properly