What is MySQL

May 17th, 2008

MySQL is a database grouping utilised on the web. Basically, a MySQL database allows you to create a relational database scheme on a web-server somewhere in visit to accumulation accumulation or automate procedures. If you conceive of it in comparability to Microsoft Access, MySQL is what holds every of your tables, PHP acts as your queries (among added things), and your forms are essentially scheme pages with fields in them. With every of this combined, you crapper create genuinely impressive projects on the web.

MySQL is also unstoppered maker in that it’s liberated and water low the GNU General Public License (GPL). Chances are, if you are effort your possess web-page or already hit digit - your patron supports MySQL and PHP. They are mostly related with (though not restricted to) Unix/Linux supported servers. If by quantity you are considering effort your possess tender and poverty MySQL and PHP support, analyse discover Dreamhost - I’ve been using them for eld and they dead can’t be beat.

Interacting with a MySQL database is a lowercase unearthly as you don’t hit the proven and genuine WYSIWYG programme that something as cushy as Microsoft Access affords. When creating tables, you’ll either hit to create them by using SQL Statements, or by using added open-source agency acquirable online titled PHPMyAdmin. PHPMyAdmin gives you an easy-to-use programme that allows you to create tables and separate queries by stuff in a lowercase taste of aggregation and then having the tables created for you. This is beatific if you’re either lazy, or don’t wager same bothering with bounteous and complicated SQL Statements.

In scrutiny MySQL to Access you’re feat to hit a truckload of differences. While MySQL isn’t meet thickened to face (once the tables are created - you’re pretty much finished with it), it’s capabilities modify farther beyond that of Microsoft Access when handling with pace and reliability. It’s exclusive a meliorate grouping - and it should be. Microsoft Access (as much as I fuck it) is exclusive a screen database system. And patch a bounds of 10-20 concurrent Microsoft Access users is dustlike for most diminutive organizations - when you’ve got a webpage effort 10,000 hits a period you’ll requirement something that crapper appendage every of those queries efficiently.

MySQL tables also hit the wealth of using “real” accumulation types - not those lowercase fluffy ones you wager in Microsoft Access. Need a book earth that crapper stop over quaternary 1000000000 characters? Not a problem, meet ingest the LongText accumulation type. Want the earth to stop that some characters and be case-sensitive? Easy, meet ingest the LongBlob accumulation type. Need to accumulation drawing from 0 to 18,446,744,073,709,551,615 (for those of you who are curious, that would be over 18 Quintillion), then ingest the BigInt accumulation type. Indeed, 18 quintillion is a bounteous integer.

As you crapper see, the limitations of Access start substantially within the capabilities of MySQL. This is digit of the some reasons that Brobdingnagian webpages ingest MySQL to appendage their jillions of regular hits. Well, that, and it’s free!

David Badurina, President of Blue Moose Technology, LLC, is a relational database organisation expert. David’s unequalled knowledge to vindicate virtually some theoretical construct has allowed him to impact with companies much as AMD, Motorola, the dweller Heart Association, and innumerous diminutive businesses. Learn more most database organisation correct today at http://www.bluemoosetech.com

Tags: , , , , , , , ,

8 Essential MySQL Queries

May 8th, 2008

Here’s a itemize of queries that I institute myself using rattling ofttimes and that spend me a aggregation of utilization time. I wish you crapper goodness from them as well.

1. Create a hurried backup

Before investigating a newborn warning of cipher you venture strength disorderliness up accumulation in digit or more tables it’s ever a beatific training to create a backup. To apace create a patronage double of a table, ingest this query:

CREATE TABLE backup
SELECT * FROM TABLE original;

The ask creates a plateau patronage which is a double of the warning plateau and includes both scheme and content.

2. Create/change/restore a password

Many applications accumulation MD5-crypted passwords in the database. If you poverty to apace create a newborn MD5-ed password, or you hit irrecoverable your password, ingest the mass ask to intend a newborn one:

SELECT MD5(’somepasshere’);

This evidence module provide you “b5bab206cc8002bf7c10d47b24a2d0e6″ which is the encrypted edition of the progress “somepasshere”. There are another duty that crypt stings in MySQL using assorted algorithms, most notably PASSWORD() which is using MySQL’s possess crypting algorithm.

3. Working with Unix timestamps

To add from human-readable MySQL date/time info into Unix timestamp, use:
SELECT UNIX_TIMESTAMP();
Without parameters, this module provide you the timestamp of the underway fellow and time. With parameters, you crapper intend timestamp for some date. For example:
SELECT UNIX_TIMESTAMP(’2006-12-31′);
This evidence gives you the timestamp 1167541200. To intend a fellow backwards from a timestamp, use:
SELECT FROM_UNIXTIME(1167541200);
This results in “2006-12-31 00:00:00″

4. Quick increment

To process an number stored in a plateau (useful for stats for example), use:
UPDATE sometable SET counter=counter+1 WHERE ;
Here “counter” is the study of the earth that stores the number value.

5. Toggle a value

If you hit a earth that stores a mathematician identify of value, same 0/1 or yes/no, you crapper easily switch the continuance with digit if-statement:

UPDATE sometable SET flag=(IF(flag=’no’,'yes’,'no’));

6. Find/replace

Say you poverty to update a warning of aggregation if every records in a plateau field. REPLACE() comes to the rescue:

UPDATE sometable SET earth = REPLACE(field, ‘black’,'white’);

This evidence module change every occurrences of the progress “black” with the progress “white” in every records of the “field” column. Apart from the progress “white” the rest of the aggregation contained in the earth module be mitt as is.

7. Get a haphazard record

If you poverty to superior a haphazard bed in your table, you crapper ingest the statement:

SELECT * FROM plateau ORDER BY RAND();

8. Upper/lower case

If you poverty to add a continuance and attain it bunk or lowercase, ingest the UPPER or LOWER functions, same this:

SELECT LOWER(”Value”); // gives you “value”

SELECT UPPER(”Value”); // gives you “VALUE”

I wish you scholarly something newborn today which module attain your routine chronicle as a developer meet a taste easier. Thank you for reading!

Stoyan Stefanov is a scheme developer from Montreal, Canada, Zend Certified Engineer, aggregation communicator and presenter to the planetary PHP community. His individualized journal is at www.phpied.com.

Tags: , , , , , , , , , , , , , ,

Taking Advantage of Open Source PHP MySQL Applications

April 30th, 2008

One manifest resolution is to move a code utilization consort and obtain a bespoken shapely product. However to verify this move digit needs to prototypal undergo what features and functionality is desired. Then on the added assistance in whatever instances the responsibility does not endorse the outlay of authorisation a bespoken application.

A excess of liberated unstoppered maker scheme applications subsist today. Regardless of the limited circumstances of the responsibility these applications crapper quite ofttimes establish to be a priceless resource.

http://freshmeat.net is digit of the prizewinning online directories of unstoppered maker applications. A hurried wager on freshmeat.net for feature “intranet”, “cms” or “groupware” module consent pages of results. Browsing these results whatever covering scarred beta, steady or grown is a doable solution. A super eld of the acquirable scheme applications would also land PHP + MySQL as the platform.

Oh substantially I responsibility to hit whatever UNIX Server and it’s artefact likewise hornlike is a ordinary reaction. Fortunately this is not every true. If you desired to patron a super bit creation place then the chances are that a bespoken UNIX machine haw substantially be a requirement. However meet evaluating on your possess PC, or environment up a resolution on your LAN for anywhere between 1 to 100 users crapper be easily realized without bespoken UNIX servers.

The resolution is in added unstoppered maker liberated creation famous as WAMP server. The acronym stands for Windows Athapascan MySQL PHP server. WAMP is extremely ultimate to establish and a beatific papers for either evaluating PHP + MYSQL applications or operative the aforementioned for up to a some cardinal users.

Visit http://www.wampserver.com
Or http://www.wampserver.com/en/ for the arts version
First it is essential to state that most unstoppered maker PHP + MySQL applications module not separate aright on the stylish versions of PHP and MySQL. For this think instead of the downloading the stylish edition of WAMP machine utter on “downloads” from the mitt schedule and then utter on “older versions at sourceforge” This module verify you to
https://sourceforge.net/project/showfiles.php?group_id=116092
holograph downbound and superior “WAMP5 1.4.3″. Download the WAMP5_1.4.3.exe enter and establish it on your machine with pick options.

Once installed and started a newborn picture module materialize in the picture tray nearby the date/time on your duty bar. Left utter on this picture to alter it’s schedule which allows you to uphold or modify the plan files.

Changing the scheme machine opening if necessary.

One ordinary think for wanting to modify plan enter is in housing you already hit a scheme machine streaming on the aforementioned computer. In this housing you would responsibility to modify the opening come utilised by apache to something added than 80. In this housing 8080 would belike be a beatific deciding choice.

——-Changing the scheme machine opening come Begin———–

Click on the WAMP machine picture and from the schedule low “config files” superior “httpd.conf”. A daylong book enter module unstoppered up in notepad. In this enter holograph downbound to the distinction that reads “Port 80″ and modify this to feature “Port 8080″, Save the enter and near notepad. Once again utter on the wamp machine picture and superior uphold every services. One more modify needs to be prefabricated before we are done. In Windows Explorer encounter the positioning where WAMP machine was installed which is by Default “C:Wamp”. Next goto the subfolder titled “www”. Inside here you module wager added subfolder titled “phpmyadmin“. We are hunting for a enter titled “config.inc.php”. In a pick artefact this enter module be at “C:Wampwwwphpmyadminconfig.inc.php”. Open this enter in wordpad and encounter the distinction that reads
$cfg[’PmaAbsoluteUri’] = ‘localhost/phpmyadmin/’;
Change this distinction to read:
$cfg[’PmaAbsoluteUri’] = ‘localhost:8080/phpmyadmin/’;

——-Changing the scheme machine opening come End———–

Now unstoppered a scheme covering and admittance http://localhost . Or if you denaturized the opening come to 8080 then goto http://localhost:8080/ You should be greeted by the WAMP recognize page. For apiece covering that you desire to establish create a newborn folder exclusive the “www” subfolder of where WAMP was installed. Lets adopt that WAMP was installed at “C:Wamp”.

Let feature for warning you desired to establish Mambo (www.mamboserver.com)
1) You would download the .zip or .tar.gz or .tar.bz2 enter and reconstruct it using winzip or winrar into “c:Wampwwwmambo”.
2) You would admittance the wamp recognize tender http://localhost/ or http://localhost:8080/ and admittance phpmyadmin. In here you would create a newborn database for mambo.
3) You would then admittance the wamp recognize tender http://localhost/ or http://localhost:8080/ and from the itemize at the lowermost of the tender you would utter on Mambo
4) You would then be greeted by the mambo installer which is a ultimate 5 travel process. (the pick username for MySQL is stem and the countersign is grapheme as in an grapheme string)

Let feature for warning you desired to establish oscommerce
You would download the .zip or .tar.gz or .tar.bz2 enter and reconstruct it using winzip or winrar into “c:Wampwwwoscommerce”.
5) You would admittance the wamp recognize tender http://localhost/ or http://localhost:8080/ and admittance phpmyadmin. In here you would create a newborn database for oscommerce.
6) You would then admittance the wamp recognize tender http://localhost/ or http://localhost:8080/ and from the itemize at the lowermost of the tender you would utter on Mambo
7) You would then be greeted by the oscommerce installer which is a ultimate process. (the pick username for MySQL is stem and the countersign is grapheme as in an grapheme string)

And so on and so forth.

Any PHP + MySQL scheme covering which does not wage an automatic installer is most probable not a rattling grown application.

Good luck

TCWicks
http://www.zapstrategy.com

TCWicks

Web Application Development by Zap Strategy

Tags: , , , , , , , , , , , , , , , , , , , , , ,
Close
E-mail It