Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP-based database models that sync with database?

Django models are really cool because you define all your models/tables right in the code, and then sync it with the database. That way when you go to update your production server, you just run the migration/sync script and you can't forget to update any tables.

The project I'm working on now though isn't Django or Python-based, it's written in PHP, and all the queries are written in straight SQL (no ORM). We've got many databases that need to be updated every time we make a change. Right now we're basically copying and pasting our SQL scripts and running them where-ever they need to be ran, or if it's a big change, we might use a script. The problem though, is that sometimes we forget to include some SQL.

If, however, we had a code-based solution, then it would automatically get checked in with our pushes, and we couldn't forget to run it. So... I'm looking for a solution that will let us define all our models in PHP, but let us continue to write straight SQL without the use of an ORM (project is 10 years old, would be too much work to implement an ORM right now). Would be nice if it could convert our existing DB into PHP models too.

Are there an existing solutions for this?

like image 777
mpen Avatar asked Jun 21 '11 16:06

mpen


People also ask

What databases can be used with PHP?

PHP supports many database management systems including MySQL, MariaDB, Db2, MongoDB, Oracle, PostgreSQL, and SQLite.

Is PHP good for database?

PHP allows connection to almost any type of database. The most common choice is MySQL, mainly because it is free, effective, and popular among developers. Other solid options of database management systems compatible with PHP are mSQL, MS-SQL, SQLite, PostgreSQL, etc.

Why MySQL is used with PHP?

MySQL is a first choice of PHP developers. As an open source Relational Database Management System (RDBMS) that uses SQL language, MySQL database helps to automate data retrieving and provide great support in PHP MySQL web application development.

How do you connect to a database server?

Connect to a SQL Server instanceStart SQL Server Management Studio. The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine. For Server type, select Database Engine (usually the default option).


1 Answers

I haven't used a PHP-based system with the fantastic model support offered by Django, but this project looks promising: Django-like PHP querying interface

like image 114
George Cummins Avatar answered Oct 30 '22 20:10

George Cummins