app that auto-generates CRUD UI for database table - php

I have a MySQL database that has a few very simple tables.
I would like to find an app (implemented in Perl, Python or PHP) that will do the following:
Point the app to a database table, and it automatically retrieves the table's schema from the database.
It then generates an HTML view of the table's data. The data is displayed as a grid, with all fields being user-editable. If there are a lot of rows, then it automatically provides pagination.
Bonus points for allowing the user to click a column heading, which would then sort the data by that column.
Bonus points for allowing the data to be filtered by a "where" clause.
I have already looked at a few packages (phpMyAdmin, webmysql), but they do not seem to provide the editable table view. They seem more oriented towards database administrators. What I need is something that's more oriented towards someone who wants to view, enter and modify data.

Use phpGrid. This is all you need.
$dg = new C_DataGrid(“SELECT * FROM orders”, “orderNumber”, “orders”);
$dg -> display();
Outcome:

See if Java NakedObejcts is what you want. http://www.nakedobjects.org

If you can use groovy then Grails can get you jump started. It will build an ORM of your entire DB, build views and your basic CRUD is all built in.
If you have a real aversion to anything thats Java-based then perl's Catalyst can help build all your mappings but might not get you the whole 9 yards. You will need to write some of your basic CRUD, which is easy and can be accomplished by simple following the Catalyst tutorial.

Thanks for the responses, but none of those exactly fit the bill, so I decided to implement it myself.
The result is a new open source project called DWI, which stands for Database Web Interface. It took me about 3 days to get it working, and I did it in about 600 lines of PHP and javascript.
If you want to check it out, it's located at http://code.google.com/p/dwi.

Use CakeApp.com, it does exactly what you want!
CakeApp.com is a rapid development online tool. It's easy to use, no
other software than your browser is needed. Benefit from ER-Diagrams
of others and share your visions too.

Related

is there a package for making a simple query API?

I have simple, 1 table, data source that I want to be able to query through an API.
I want to be able to query on any one of the columns. Ideally, I could query for multiple values per column. One column has text, for which I need to be able to do partial and approximate matches (as well as handle diacriticals)
I am wondering what packages people recommend for building this. I realize its something simple, but it seems like a common enough goal that I thought there would be something available to do all the heavy lifting.
Ideally, I'd like to work with python/django, but could also do PHP. Is there something available to help with this?
I assume since you mentioned django, that you are asking to create a web facing API (like what twitter and facebook provide), if that's the case there are a few options:
You may not have to write anything at all. There are platforms like apigee that allow you to create an API just by clicking a few links. They have free accounts, like almost everyone on the net.
If that doesn't work for you, you can use flask-rest (optimized for the Flask microframework) or tastypie which works great with django for Python. Both will allow you to easily create APIs for your data source and they will take care of most of the boilerplate code for you.
For PHP, someone already asked the same question earlier so that would be a good resource.
If you just want to create an API on top of an existing database and use this API to query the database in other applications, then the de-facto standard for Python is SQLAlchemy.
Probably you may want to check out this link, that will give you some lights about structuring and some template code (in PHP) for building an API:
http://net.tutsplus.com/tutorials/php/creating-an-api-centric-web-application/
From the formatting of the URL to the call of the methods called in it. I.e.:
$controller = ucfirst(strtolower($params['controller']));
import sqlite3
conn = sqlite3.connect("some_db.sqlite")
conn.execute("SELECT * FROM TABLE WHERE some_field=?",('field_value',)) #this should properly escape values
# or
conn.execute("SELECT * FROM TABLE WHERE some_field LIKE ?",('%parial_match%',))
not sure if thats what you are asking for (this is python)

Front-End for MySQL Forms (Windows or OSX)

[Edit: I have awarded the bounty but not the question, as I feel there is still a chance for a better answer.]
I usually code my MySQL data entry interfaces in php.
But for quick projects where I would like to focus on the web side of things (pulling data from the database), I am looking for a form front-end to MySQL. Ideally, this would be an off-the-shelf Win or OSX program that I can hand over to a friend or client so she can input data into forms.
An Example
The lines above summarize the question, but here is a typical situation to showcase why "just give them phpMyAdmin" or some other web interface to MySQL generally wont work.
We have two main tables: images and albums. The third is an associative table that associates images with albums.
Images: id (PK), filename
Albums: id (PK), album
Album_Image: id (PK), imageid, albumid (these are foreign keys: the two id PKs from the Images and Albums tables)
For big projects, I don't mind coding a nice "back-end" interface (CRUD) that lets me edit data in a very comfortable, customized way.
For small projects, for instance an image gallery for a friend, I would like to be able to only program the "front-end": web interfaces that pull data from the database.
For the back-end, ideally, I would like to give my friend an off-the-shelf solution so she can enter images, albums, and associations between images and albums.
In the old days (I am thinking of DBaseIII), it was really easy to give interfaces to do that entry side of things.
Here is a crude approach I have tried. I have set up a view of the associative table joined to the parent tables, so it shows albumid, imageid (the PKs) and album, filename (associated fields in the parents) using this query:
SELECT albumid, imageid, album, filename FROM album_image axi
JOIN albums a ON a.`id` = axi.`albumid`
JOIN images i ON i.`id` = axi.`imageid`
The idea with this crude approach is that my friend would enter the parent PKs (albumid and imageid) in the associative table through the view, and that after hitting Insert, the full parent fields (filename and album) would be visible in the View for visual feedback. I have tried this view in three GUI tools: SQLyog (Win), HeidiSQL (Win) and Sequel Pro (OSX).
In Heidi and Sequel Pro, I have not found a way to edit the view.
In SQLyog, I can edit the PK fields (albumid and imageid) in the view, and the parent fields (album and filename) show properly when I hit "refresh". That's great. It works because even though the view shows three tables, we are only editing from one table. But I cannot delete a row as SQLyog doesn't know from which of the three tables we are trying to delete. On the other hand, in SQLyog, I able both able to insert and delete in a Query tab that contains the same query that creates the view, because in this kind of tab SQLyog allows me select the table being edited. So that works, but this workflow might start to be a little complex for my friend: she would have to open SQLyog, connect, open a saved query, select the right table to edit within the query, and make all the other right moves.
Wondering if any one knows an existing tool that is really good at making forms for MySQL---ideally a Windows or OSX binary. I will consider a web solution, but I am not interested in a framework---the key is speed of deployment, and if we went the framework route I would be better off making the interface with my own CRUD libraries. Again, I can code it, but my goal with these kinds of "quickie projects" is to focus my workload on the front end (web interface to the database), leaving the back end to an off-the-shelf tool.
Thanks heaps in advance for any insights. :)
Edit: I see that no one has mentioned Navicat or MySQL Workbench. I haven't tried either, wondering if someone knows off the top of their head whether they would do the trick.
I think what you're looking for is a form front-end for MySQL.
Since it sounds like you are more interested in binaries than web apps, have you looked into Microsoft Access? It can talk to MySQL and could be just what you need.
Open Office Base may not have quite the features you're looking for.
You already have the solution, your attempt at making things simpler is creating the complication.
There is no benefit to your friend in adding album images in a view if that view that only shows the filename and album title after they have entered the IDs and clicked Insert.
Before adding an image, your friend needs to know the album ID and the image ID. This information may not be in the view. She will therefore look at the album table and look at the image table to find this information, cross-referencing the filename with her own list of uploaded images.
Then, having written these two numbers down, she can insert a row directly into the album_image.
For visual feedback, she can check the frontend website.
It is true that a view showing the album name and filename would make deleting entries easier, but I would assume that images and albums are added much more frequently than they are deleted.
The ability to edit an associative table in a view that shows linked information, therefore, should not greatly affect your choice of tool. I could suggest tools, and phpMyAdmin is a logical choice, particularly if it is desirable to teach your friend computer skills that are widely applicable. It appears you have already identified some executable tools.
I imagine that you could add some additional hidden frontend views that could make your friend's workflow easier, such as a list of images and IDs that aren't in albums, a list of album IDs, or a view that shows the IDs. I do recommend you consider extending the frontend with a simple login and Edit options using your CRUD library, rather than devising a separate backend GUI.
I appreciate this is not an answer to the exact question, but it does resolve your problem.
I'm not sure if this will be helpful or not. I was hoping to find a UI with some eye candy/styling, but while searching I stumbled upon this:
https://blogs.oracle.com/MySqlOnWindows/entry/introducing_mysql_for_excel
As part of the new product initiatives of the MySQL on Windows group we released a tool that makes the task of getting data in and out of a MySQL Database very friendly and intuitive, and we paired it with one of the preferred applications for data analysis and manipulation in Windows platforms, MS Excel.
Like I said, not sure if it will help. I'm in a similar situation - low-tech, low budget client. The difference is my weakness in MySQL, but for me I just need a single table, so I think this will work.
There is no tool that will allow you delete such values from such a view, not for mysql, since For a multiple-table updatable view ... DELETE is not supported, see Updatable and Insertable Views
I guess you are looking for the equivelent of the Python based Django admin system which practically builds itself from analysis of the data structure.
Frameworks like Symfony, Cake and Yii have some of this built in, however I'm guessing that your database architecture may not be compatable as these types of systems normally require you to stick to strict naming conventions, but it's certainly worth taking a look.
Playful,
I already posted one answer, but this one is different enough to merit a seperate response, IMO.
Since you are looking for a simple, client-friendly solution, may I suggest Adminer?
http://www.adminer.org/en/?
Specifically, I used the Wordpress plugin here on a site recently:
http://wordpress.org/extend/plugins/adminer/
It provides pretty much full phpMyAdmin funcitonality. Very easy for the client, and if they want to, they can export the database as .csv and edit in excel, then re-upload. Just about everyone is familiar with editing in Excel, and they can make backups regularly.
Hope this helps!
J
You can very quickly and easily make a front-end for this type of use with Xataface. I find it very quick and useful. I would be happy to help you get going with it.
www.xataface.com

Designing auto-generated html form from MySql database using PHP

I'm building a simple internal website for a medium-sized independent restaurant chain. The website will be a repository for contact information, general documents, etc. We have a central kitchen that produces and delivers around 50 different items daily to the 7 different restaurants in our city. We currently have a pen, paper, and phone tag system for placing these orders. The part of the site I am struggling with is creating a section for ordering these items through the internal site.
The website can be logged into currently from each restaurant's unique user id, and there is a mysql table for each restaurant's daily order. I need to create an html form that allows the manager of each restaurant to enter integers for each item and have that information update as a new record in the mysql table. I know it should be a straightforward task, and one that an advanced php programmers would scoff at...but that I am not!
Any help at all would be appreciated, even a reference to an open-source solution that is well documented that would help me in getting started!
These classes can also help you :
Form auto generator ( A Simple class for creating HTML forms )
Forms generation and validation ( A professional class using for Form generation and validation )
You may want to consider using a Framework as #hakre suggested in this comment. From a business perspective using a Framework is a time and money saver because you're not having to create the wheel when something in the Framework already exists:
symfony
Zend
and a dozen others would accomplish what you want but would take some time learning them right out of the box.
These, and many other frameworks, have form generators (command-line utilities or open sourced available Code Gallery classes), that make the forms from your database schema.
But this would only be the LONG term solution as this would eventually allow you to customize your site to exactly want you want but would require resources from an experienced developer to maintain.
I think you may also want to look at phpmaker, they have a trial. But essentially you point it at the database > enter the connection information. and it will generate add/remove/edit/delete
I just used it to build a couple sites to administer my databases on the backend. Since I didn't need it to be all pretty and colorful for the end-user experience, it was very useful, and customizable for straight data management.
PhpMaker is really powerfull choice. I have used it for many applications.
If you are a PHP programmer, you can go deep and do most every customization you want.
You can also install some advance extensions like ilovephpmaker.

How to Build Basic "To-Do" list style Website

I am trying to create a website that will allow me to list all of the different types of beers I have tried including name, type, location, and brief tasting notes. I have a basic login created and believe that I will have to store the information about the beer in a database as well (with a cell for each of the elements). I was wondering a) if this is how people would suggest going about doing this and b) if anyone knows of good tutorials on how to set this up. I plan on using mySQL and PHP for the database and jQuery for the visual side of things. I am relatively new at this, so I am having trouble figuring out what exactly to Google to find what I am looking for.
I plan on going about it similar to a to-do list (only each element would have multiple attributes — name, type, etc.). Any help/suggestions/direction would be awesome! Thanks!
First off you need to decide on the features you want to implement, and then work out which to do first.
For example,
you need a database, which has a table for your beer info. (but do you need another one for people to have a user account too?)
you need to create a set of functions that you can access from the web site.
list beers
add beer
etc.
How do you want the front end to work?
How do you want the front end to look?
Once you know exactly what you want to do, it's much easier to break down the tasks into jobs you need the application to do.
I'd also suggest you look at Ruby on Rails (especially + the Hobo addon) to get you up and running faster (instead of PHP) - if you are set on PHP, have a look at CakePHP or another similar framework, so that you don't end up re-inventing the wheel.
Update:
Once you get started, further more detailed problems will be faced, many you can get a quick answer from google or the documentation for the language / database etc. If something is extra tricky, post another question on StackOverflow.
As it is your question is too general for a more specific answer, but if you need any additional info, just yell.

Is there any php framework which exactly reflect the msaccess

I am fond of dbstructure definition of msaccess which lets defining at once and creating the data entry forms, datatables and reports at once easily.
I have been searching for some framework which would generate the data entry forms, data tables and reports easily. I guess the only thing I need to define is complete datatable structure.
Is there any like that or better one than that?
EDIT:
well i am afraid that PHP frameworks have been limited to programmers only. I would like to extend it with some automated functions like autoform in msaccess which would generate data entry form, auto report for data listing. So that my development time would be again some less. I found doctrine nearly matching my specification but not sure as i haven't fully explored doctrine
Cake offers both "hard" (bake) and "soft" scaffolding, which should be very close to what you want. It's still only meant as a quick proof-of-concept tool and to get you up and running faster so you can concentrate on programming the business logic. It's not meant as a hands-off solution nor to be used in production.
What you seem to be looking for is a database frontend like phpMyAdmin or SQL Buddy, not a PHP framework.
Symfony provides an admin generator that builds all the forms on the fly and it will also update itself when you change your db schema. It is based on doctrine which you say you looked at so that would make things a bit easier for you.

Categories