Implementing database using php files? or phpmyadmin? - php

Hello I'm a super newbie for php. I started learning php from w3schools website, according to that tutorials databases for the website are created using php files.
I want to know, does it is the standard way that the web developers do for database implementation? or do they use tools like phpMyAdmin?
Creating databases

While most people would use a client to connect to the database-server and create a database and tables, it is not the only solution
If your application is starting to get bigger, you might want to 'migrate' to a new version of your database. Using a script to perfrom this migration, even if it is just a small extra table, could be the best way to make sure you can keep track of what you are doing.
This could be a php file, although creating it with a .sql script and a client (simple cli for instance) would be another method.
In the end it does not matter: you need certain sql commands send to your sql server. It might be easy to use a client (phpmyadmin is a client, just as the 'mysql' commandline client, mysql workbench, etc etc), it might be better to use a script (for advanced deployements preferable).
The page you link to is nothing more then an explanation that you can do this, as far as I see it does not mention you should do this.

It's easier to use phpMyAdmin. If you want to use a pretty graphical interface, you can also use MySQLWorkbench.

Related

Connecting Android Studio to Web Service to SQL Server

i heard that the best way to connect android to sql server database is by creating web service around it. Is there any specific tutorial to create the web service?
Do we need install server like xampp for mysql or it will be just fine with sql server management studio?
What is exactly a web service? Connecting via post method to php is a web service?
What software i must use to make it work?
-android studio
-sql server management studio
-php written in notepad (?)
-apache tomcat?
anything else?
Sorry for bad english, Thanks
You gave us a very broad question.
I'll try to get you going.
First, a webservice can be a lot, but most often it is a server (php in your case) that uses SOAP.
Look up SOAP yourself to get the details, but it boils down to sending XML files to the server. The server then responds with something appropriate.
Here is a very short introduction with code, just to get the idea what it is about:
http://www.codeproject.com/Tips/671437/Creating-Web-Service-Using-PHP-Within-Minutes
The reason you want a wrapper around your database is this: You don't want to allow everybody to access your database directly. So you write a wrapper around it, that ONLY performs tasks you allow it to.
For example: Get all users in group x. Or: Update the birthday of userid 455.
etc. That way you control what goes in and out, and you only have to send some XML to get the job done. Your PHP script will take care of the actual database interaction.
Where you write your PHP in isn't very important. I would advice you to use at least an editor with syntax highlighting and UTF8 support.
Don't use Notepad.
Look up notepad++ if you want something better: Notepad++ can do that. If you take bigger projects you probably want to use a real IDE. (There are many for PHP)
Apache? Linux? Windows?
As long as you can run PHP, it is OK. If you are planning to use MSSQL Server from Microsoft, you will have an easier time if you run on windows. If you use mySQL, it doesn't matter too much.
I want to warn you: You seem to be pretty new to PHP (since you asked if Notepad is OK to develop in). This project might be a little over your head. :-)

MySql database version control system

I have PHP, MySQL, and Mono installed.
I've been searching for an equivalent of Tarantino's Database script executable for MySQL and have failed miserably in finding something that will work. I don't want to use Liquibase because I find the dealing with tons of Xml extremely unappealing. I don't want to use DVS,because it seems to be way over kill for what I need. I don't want to install Ruby in order to use migrations either. I want the ability to just execute raw scripts like Tarantinos.
Does anyone know of a good one to use or am I going to have to end up rolling my own?
Have a look at Doctrine Migrations http://www.doctrine-project.org/projects/migrations.html
I've been using it in one of my projects, and it is working quite nicely. You just maintain php files that are classes that have the sql files to run against the DB. There is one simple table that tracks what version the db is currently on.

How to sync mysql db between 2 localhost?

i want to develop some php stuff with a friend together. We managed to sync our local projects with an subversion repository on unfuddle.com and with subclipse. Now we need to now how to synchronize the local mysql databases, too. (We both use xampp and we want to use Mysql Workbench to mange the tables)
It's not an option for us to use an online database, because we want to able to write and test code offline.
I'm really a noob at mysql dbs, i just know how to let my php work with them.
so a programm or a eclipse plug-in which could let use the unfuddle repository would be perfect.
Thank you very much,
Someonelse
First of all, it's a bad idea to share a development database. It makes it very difficult to get consistency when other people may be modifying your data. It will very likely interfere with your thought process while coding.
I would recommend adding your database schema (or snapshots) to the svn repository and load them on each database instead. Once you get more comfortable with this, you can start looking at using an ORM like Propel to manage your database schema and preferably a whole framework like Symfony as well.
Now, if you're really stubborn about doing this (and a little crazy too) If you're in the same LAN, look at master-master replication.. It might work remotely too, but depending on the amount of data being read/written it might be really laggy. Again, you'll likely end up having problems regardless of what route you go with if you decide to share a single db.
Cheers!

Desktop Application with Flash and Php

I want to develop a desktop application using Adobe Flash remember a desktop not a web application. I want to connect Database (MySQL) to it for which I think I should use Php.
Can I send and receive data from Php files silently means without running the Php file itself.
Is there some method to achieve something like this?
Honestly it sounds like your best bet is going to be to use Adobe AIR. You can use the NativeProcess API to call PHP on the host computer, but you also have the option to use a SQLLite database directly from AIR with no need to mess with PHP.
Here's a link to a sample project with source code provided, this may help. Good luck!
http://www.peterelst.com/blog/2008/04/07/introduction-to-sqlite-in-adobe-air/
Is there some method to achieve something like this?
There are ways to package an Apache/PHP/mySQL environment into an executable, but they are terribly complex to set up and not especially light-weight.
You are probably much better off doing this on a native platform for desktop applications. Every major programming platform has the means to connect to a mySQL database - if that really is the database of choice for a desktop app.

stand alone php app

What is the best way to build a non web browser stand alone php app that works with some sort of database without requiring the user to install a database server. Or am i just asking too much?
If you're targeting Windows, try WinBinder. It allows you to develop native Windows applications using PHP.
It also supports SQLite, so you don't need a database server.
Embed the SQLite database in your app, then configure PHP to talk to the SQLite database:
http://us.php.net/sqlite
Have a look at php compilers, you'll end up with a binary for people to run. It could be a desktop GUI application, or a "web server in a box" type of thing.
bamcompile
phc
roadsend
I'd suggest you try miniPHP. It is basically an IDE around Winbinder; it lets you concentrate on writing PHP while it takes care of details like compiling the application. You can create either GUI or command-line apps and it works just fine with both SQLite and MySQL. It has a preview mode and some debugging capabilities too.
Here is an idea: information can be stored in XML and thus usage of database can be avoided. That will work only for certain kind of purposes of course.
As Oakcool has mentioned, check out PHP-GTK. It is a GUI development tool on the similar lines of MFC for C/C++.
PHP-GTK alongwith SQLite or a text file as others mentioned above should do the trick.
Take a look at this 3 links
PHP GTKenter code here
http://gtk.php.net/
FLEX
http://www.adobe.com/products/flex/?promoid=BPDEQ
AIR
http://www.adobe.com/products/air/
I think any those will help you, check it out.
I don't have any experience with it but there's a portable version of XAMPP.
You wouldn't necessarily have to use the Apache portion. The app could just run from the command-line, depending on what you're trying to do.
I dont know how to use PHP as standalone programming language, I mean without using a web server and a browser.i can answer your other question.
SQLite is a database system(to be more specific: a library!) which provides you all the basic capabilities of SQL database without needing to install any specific database servers.But you do need to copy a small .dll file(sqlite3.dll i suppose) into your working dirctory.The file is only a very small one,but you get all of the basic capabilities of a database such as INSERT DELETE UPDATE SELECT etc..Its a great light weight database..i mean it..really lightweight.
also PHP has inbuilt support for SQLite database.so compatibility will never be a problem
Have a look at their home page https://sqlite.org/
This is what they describe themselves:SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world.
Checkout phpdesktop that gives you:
Embedded web browser based on Chromium framework let you benefits from HTML5, javascript and jQuery.
Embedded web server with mongoose let you use php.
embedded database engine with SQLite.

Categories