From: Steve D. <st...@wo...> - 2005-05-24 19:26:32
|
Robin Bowes wrote: > One thing occurs to me (as it does for the phpPgAdmin project) and that > is why are you not riding on the back of phpMyAdmin and simply replacing > the DB-specific stuff? Surely, that would be a simpler approach? Or am I > being too simplistic? I wish it were that easy. I actually started doing that, but there are some major differences. One, being that no matter what frontend you're writing, you're going to be pulling a lot of metadata from the databases. The queries are going to be absolutely different. In SQLite it's something like querying master_database or something like that.. you can look at sqlite.org and it has some docs on how to pull the stuff out. Well, there's other reasons, but they boil down to the same concept -- the queries are just too different because of how you're hitting system data, eventually. It would be easy, however, to copy the layout and display of pma, I think. There are a lot of HARD features to copy everything straight over though, and you would need to work on a good backend so you know how to go about doing that stuff. For example, if someone wants to delete a row, and there's no primary key, how do you delete the right one? Well, there's a couple of ways ... you could say "DELETE FROM table_name WHERE field1 = $field1, field2 = $field2, " etc ... or I think pma actually does something like "DELETE FROM table LIMIT 1 OFFSET $offset" where $offset is known based on the page you're displaying (display 30, start at offset 30), then the row number (delete row 5, so offset 30 + 5 .. ). Pretty, smart actually. The problem I keep running into when hacking on psa is whether to start from scratch and replicate the look/feel/functionality of pma or mangle the current release and try to mold it into something else. The first option is fun until you realize you quickly have to have some kind of class to make the common functions easy, and the second one is entertaining until you realize you're hacking with frames and the layout can confuse you. If I had to start all over again, I would just start building one from scratch -- not replicating pma in *every* respect, but instead starting with the very basic functions: display the databases, select a database, display the table metadata, display the table, add a query form. And just go from there. Things are much, much easier to work with once you have something where you can just *browse* your databases + data to see what you're working with, so you don't go quite insane. :) I'm speaking partially from experience since I'm using sql server 2000 at work, and I had to develop a small frontend for it just so I wouldn't go insane. Building those basics is actually really, really easy. I've even got it so I can export any query to CSV which is cool. But it's when you get down to the nitty-gritty like creating tables in a frontend, and deleting rows and stuff like that that it gets tough. So, I don't really have any advice on how to go about building a db frontend, really. Other than keep it simple, add features slowly, and write some functions and maybe a class to help you do the simple things. My only suggestion would be to layout what features you want it to have, argue about how to implement it, make a function so it's easy to do, and then anticipate any errors that might come along and work around those, and get it working. Worry about design, layout and look and feel last. The important thing is to get the functionality coded and working and stable first. Who cares if your frontend is a two framed html horror -- as long as it works, you can always go back later and add some css magic. The great thing about writing a frontend to a dba is that 1) you get to learn it's possibilties and limitations REALLY quickly and 2) you don't have to manage everything command line anymore. Anyway, I shouldnt say too much more, since I never really contribute anything. Someday, I hope. :) Steve p.s. and if anyones interested, I can pass along some screenshots of my mssql frontend if you want to see what I'm talking about. |