Jump to content

PHP - MySql - My Project


jsladek

Recommended Posts

Hello, 

It's probably a little premature to be posting something like this but I am planning on building my own Application Builder (reinventing the wheel).  I'm mostly doing it to learn how to write PHP.  I already know enough to be dangerous but there is still a lot that I need to know.  I don't get to use PHP @ work, hence this project...

The Basic Concept.  You want to build an application that uses a MySQL database.  You build the tables first and now it is time to write some PHP to interact with those tables.  This is where my program is going to come in.  You load it up on your server, put in your server info, database name, username, password and click go.  My program will use the database info you supplied and rough out an application or scripts to get you started. 

I've already started working on this thing and should probably wait till I get a little farther along but the version I have now does a pretty good job of demonstrating what I am trying to do.

If you have a MySQL database and PHP running on a server and have some free time, check it out and let me know what you think.
http://www.iobe.net/proj/


Later,
John Sladek
Link to comment
Share on other sites

  • 1 month later...
200 + views and no comments?  Has anyone tried this?  I realize it needs some work but it is a work in progress.

Any feedback would be great. Good, bad, whatever.

I'm also interested in what people think of this not being OOP. 

-John
Link to comment
Share on other sites

If you insist.

I don't see any use for it. You're avoiding some logic by hardcoding column and table names in scripts, but that also makes it EXTREMELY inflexable. Every time I change something in the structure of my database, I have to re-run your script. If I wan't to change something about the view, I have to edit every file for every table. It is impossible to manage.

Forget about the fact that it is not using OOP, even for procedural it is extremely inflexable and un-reusable.

I wouldn't recommend it to anyone, n00bish or not.

[b]Edit: [/b]It may look like I'm shooting you down, but you did ask for opinions. I didn't want to repy because it might seem too negative.
Link to comment
Share on other sites

In order to do what you're suggesting you might need to know something about the database schema.  For example consider the following tables:

theatres {theare_id, theatre_name}
addresses {address_id, theatre_id, address, city, state, zip}
movies {movied_id, title}
movie_theatre_map {theatre_id, movie_id}

I'm assuming that your application will generate a method / function for me called getTheatres that might look something like this:

[code]
<?php
function getTheatres($id){
  return DB::query('SELECT * FROM theatres WHERE theatre_id = ' . DB::prepare($id));
}
?>
[/code]

But what if when I call getTheatres I want the theatre name and address?  Or what if I want all of the movies playing at the theatre as well?  This will require a couple of joins, and in order for you to know that you would have needed to know that there was a relationship between the afore mentioned tables. 

I don't think that the idea behind your application is bad, I think that it could be very helpful in jump starting the data access /  model layer of an application but it's going to take a lot of foresight and planning.  I also think that if you choose not to build this in an object oriented manner you're going to spend a lot of time chasing your tail, might I ask why the hesitation to go OO?

Best of luck with your idea, and even if it doesn't work out you'll definitely learn alot along the way.
Link to comment
Share on other sites

You give me too much credit :0)

My application really just builds what a newbie would learn in a beginners PHP class.  Only difference is it puts all the functions in one file.  My program certainly is not smart enough to know that you would want to JOIN, UNION, or whatever for any particular table, It just builds a CRUD (non OOP & hard coded) for each table.  When I read the table I do look at the Data Type and add functionality to the CRUD.  For instance, I will display if it is Primary key and if it is an Auto Incrementing feild.  Also, if it is a TIME or TIME_DATE feild I include a little calendar icon you can click on and a popup calendar will pop up and let you select the TIME/TIME_DATE much like phpMyAdmin does.

I figured that if I were to need to do a JOIN or something I could go into one of the files and edit the sql and also the format of the output to display what I wanted.  On a previous project I did for a Senior Project @ School, Me and another student build a lot of forms and processing files to update log records.  There were different types of logs but each one was really queried individually.  The first forms were tough but ehn we did a lot of cutting and pasting from one form to another.  If we had a tool like the one I am making we could have cut our time down significatly.

I have been assembling a bunch of test tables in a database and have 100+ that the program seems to be working pretty well on. 
Check it out if you wish, there is no form validation yet but there is nothing important in the database. http://www.iobe.net/proj/workshop/index.php (I've not changed any code, everything there is auto generated)

Each script is also stand alone
so this link.
http://www.iobe.net/proj/workshop/index.php?pg=medications
and this link.
http://www.iobe.net/proj/workshop/medications.php
Are calling the same script, the first just uses an include. (I have made it so the injected file is verified before included to keep people from including their own files) 

The reason for not using OOP?  I'm not really too good with it. I've learned a little in a JAVA class I had in school but it was very little.  I've since been looking @ cakePHP to try and see how a REAL Framework/Scaffolding works. 

I've been able to sucessfully build the Blog http://www.iobe.net/cake/ but I still have no idea what is going on.  My program built something similar for the same table http://www.iobe.net/proj/workshop/posts.php and I can understand the code it wrote and I know where it is since it is all in 1 file (except images) called posts.php

I'm going to put a lot more effort in to learning how to use cakePHP or even ZEND Framework.  I firmly believe that I need to know how to use a popular product if I ever want to build business applications for a living, I think it makes too much business sense to use something like that rather than have somone build a custom application from scratch. 

I'm going to try to keep this project active also.  Maybe once I have more experience with other frameworks and OOP I will make some changes in my approach of my own.  Only problem is Time.  I have Math and Bio classes to worry about and I recently changed positions @ work and I am in Pole climbing school, which is kicking my a$$ after being straped to a desk for six years.

Thanks for your comments, I am learning a lot and maintaining what little skills I have.  PHPFreaks is a great place to keep that juices flowing... I've gotten away from PHP b4 and it is easy to forget things.

Thanks,
John Sladek

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.