PDOModel - Database abstraction and helper PHP class

Description
“PDOModel is a powerful database abstraction and helper PHP class that simplifies insert, update, delete, and select operations using PDO—no queries required and with minimal code. It seamlessly supports MySQL, PostgreSQL, SQLite, Oracle and SQL Server databases.”.
DocumentationVersion 1.3 – PDOModel now supports Oracle and SQL Server along with PGSQL, SQLite and Mysql.
PDOModel provides a complete solution to perform CRUD operations on three different types of databases (Mysql, Postgres and Sqlite). It provides various helper functions to export data directly to csv,excel,xml,pdf,html and many more useful functions.
Example of how to write SQL select query using PDOModel
$pdomodel = new PDOModel(); //create object of the PDOModel class
$pdomodel->connect("localhost", "root", "", "pdocrud");//connect to database
$result = $pdomodel->select("emp"); //select * from `emp`
That’s it, you need to write just 2-3 line of code. You can write very complex queries using PDOModel functions
PDOModel supports three type of database, Mysql, Postgres and Sqlite.
PDOModel script allows you to export data directly in various database formats.
Examples
$pdomodel = new PDOModel();//create object
$pdomodel->connect("localhost", "root", "", "pdocrud");//connect to database - three different database type available
/* INSERT , UPDATE AND DELETE OPERATION */
$pdomodel->insert("emp", array("firstName" => "John", "lastName" => "Jonathan", "gender" => "male"));
$pdomodel->where("orderId", 7);
$pdomodel->update("order", array("orderNumber"=>"44", "customerName"=>"BKG", "address"=>"140 shakti nagar"));
$pdomodel->where("orderId", 7);
$pdomodel->delete("order");
/* SELECT */
$result = $pdomodel->select("emp");
/* WHERE, AND, OR, BETWEEN, GROUP BY, ORDER BY, LIKE , HAVING */
$pdomodel->where("orderNumber", "5", "!=");
$pdomodel->openBrackets ="(";
$pdomodel->where("city", "Indore", "=");
$pdomodel->andOrOperator="OR";
$pdomodel->closedBrackets =")";
$pdomodel->groupByCols = array("orderId");
$pdomodel->orderByCols = array("orderId desc", "state asc");
$pdomodel->havingCondtion = array("sum(orderId)>2");
$pdomodel->limit = "0,5";
$pdomodel->where("empId", array(36,37), "BETWEEN");
$pdomodel->where("firstName", '%P%', "LIKE");
$pdomodel->where("empId", array(36,37,39,40), "IN");
/* subquery/inner query */
$pdomodel->subQuery("select empId from emp where empId=?","empId",array(34));
/* where subquery */
$pdomodel->where_subquery("orderId", "select orderId from `order` where orderId=?", "IN",array(10));
/*rename, trucate, drop table, column name, primary key, tablefield info*/
$pdomodel->truncateTable("wp_postmeta");
$pdomodel->renameTable("states","state");
$pdomodel->dropTable("empleave");
$records = $pdomodel->columnNames("order");
$records = $pdomodel->primaryKey("order");
$records = $pdomodel->tableFieldInfo("order");
/*execute sql*/
$result = $pdomodel->executeQuery("select * from emp where empId = ?", array(39));
Main Features:
- Perform Insert, update, delete, and select operations using simple functions
- Three different types of database support (Mysql, PGSql, SQLServer, Oracle and SQLite)
- Complex queries support with use of multiple “and” and “or”
- Multiple table join Operation using simple functions
- Table-related operations like getting all tables from a database, truncating table, deleting table, renaming table etc.
- Subquery/inner query can be embedded
- Column-based operation like getting all columns of the table, the primary key of the table etc
- Export functions to export data in CSV, PDF, Excel, HTML, XML Format
- Helper functions like pagination, random password generation
- Best practices using PDO with use of prepared statements
- Support for PDO Transactions
- Support for batch operations for insert, update and delete
- Execute query directly with parameter binding
- Various debugging options like get last query, get rows inserted, error messages etc
- Support for order by, group by, like, between, in, not in, having etc
- Well documented and demo codes to make things easier to understand
- Supports method chaining
- Batch operations for faster result
Version 2.1
Added-
- Now support the Oracle database.
- Updated to meet latest PHP version requirements
Version 1.4
Added-
- Now support the Insert On Duplicate Update statement also.
- Resolved bug for sqlite
Version 1.3
Added-
- Now support sql server database also. Please note that you must have SQLServer extension installed for this. For more details, check here http://php.net/manual/en/ref.pdo-sqlsrv.php
- Resolved bug for sqlite
Version 1.2
Added-
- Json export option
- CSV Import option
- Excel Import option
- XML Import option
- Various functions to support chaining
- Resolved bug for truncate function for sqlite
- improved documentation
Credits:
Tcpdf phpExcelOur other popular script
| Type | PHP Script |
|---|---|
| Author | ddeveloper |
| Category | Php Scripts / Database Abstractions |
| Price | $15 |
| Sales | 248 |
| Rating | 5.00 from 18 ratings |
| Published | Apr 20, 2016 |
| Last Update | Nov 19, 2024 |
| Compatible Software | PHP 8.x, PHP 7.x, MySQL 8.x, MySQL 5.x |
| Source Files Included | JavaScript JS, HTML, CSS, PHP |
Categories
Tags
External listing. code.market does not sell this product and does not process payment for it. Pricing, payment, delivery, licensing, refunds, and support are handled by the third-party merchant on its own website. We may earn an affiliate commission from a referral. Details.
Products of the Week.
Submit🥇
STOP GUESSING WHAT TO POST
AI that learns your brand voice and builds a month of consistent, on-brand social content: carousels, posts and hooks that sound like you, not like everyone else's AI.
SaaS · 4,277 views · 38 clicksSaaS · Week 45 · 4,277 views · 38 clicks
🥈
Conversational Backlinks for Busy Founders
Place Backlink Relevant Conversation for your domain across Forums and Conversations
Website · 41,987 views · 223 clicksWebsite · Week 45 · 41,987 views · 223 clicks
🥉
upvote.club
Free Social Media Engagement that Helps Boost Your Content. Upvote Club supports 19 social networks with 100+ engagement actions in one dashboard. Add links to your posts and get free engagement from real users.
SaaS · 40,029 views · 117 clicksSaaS · Week 45 · 40,029 views · 117 clicks
#4
Substack Posting API
Onboard your Agent to Substack. Write Publish on Substack via API
SaaS · 59,040 views · 198 clicksSaaS · Week 45 · 59,040 views · 198 clicks
#5
Seenshot App
Free, Fast, MacOS Screenshot app. Make Screenshot cmd+shift+2 and send it via link
Desktop App · 28,411 views · 122 clicksDesktop App · Week 45 · 28,411 views · 122 clicks
#6
Hand-Placed Backlinks $9.99 per link. Flat rate.
Buy hand-placed forum, Q-A and directory backlinks. Flat $9.99 per link, no subscriptions — you only pay for approved listings.
Website · 4,248 views · 19 clicksWebsite · Week 45 · 4,248 views · 19 clicks
#7
Free Invoice Generator - PDF Invoices in Your Browser, No Sign-Up
A free invoice maker for freelancers and small businesses: fill in the invoice, check the live preview, and download a PDF that looks exactly like it. Any currency, tax per item, three templates, no sign-up, and nothing leaves your device.
2,928 views · 17 clicksWeek 45 · 2,928 views · 17 clicks
#8
Merge PDF Files Free - Combine PDFs in Your Browser, No Upload
A free PDF merger for office workers, students, and freelancers: combine PDFs and images into one file in the browser, reorder files and pages, pick page ranges, keep bookmarks, and open password-protected PDFs. Nothing is uploaded, no sign-up, no watermark.
2,704 views · 13 clicksWeek 45 · 2,704 views · 13 clicks
PDOModel supports three type of database, Mysql, Postgres and Sqlite.
PDOModel script allows you to export data directly in various database formats.
