Home arrow PHP arrow Page 5 - Doing More with phpMyAdmin (Part 2)

Bookmark Bandit - PHP

phpIn the first segment of this two-part tutorial, I gave you a quick overview of some of the interesting new features available in phpMyAdmin. In this concluding segment, find out how to use phpMyAdmin to define relationships between tables, maintain a log of commonly-used queries and create entity-relationship diagrams.

TABLE OF CONTENTS:
  1. Doing More with phpMyAdmin (Part 2)
  2. The Ground Work
  3. Total Recall
  4. Tangled Relationships
  5. Bookmark Bandit
  6. Looking Up the Dictionary
  7. History Lesson
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 41
December 08, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Just as most browsers allow users to bookmark favorite Web sites, phpMyAdmin allows developers to bookmark complex queries, so that they can be easily reused over and over again. As an example, consider the following query, which returns a list of customers along with the services that they have opted for:

SELECT clients.cname, services.sname 
FROM branches, clients, branches_services, services 
WHERE branches.bid = branches_services.bid 
AND clients.cid = branches.cid 
AND branches_services.sid = services.sid


This query can easily be bookmarked by popping open the Query window (bottom left of the application) and entering the query above into the query box. Once a result set appears, simply scroll to the bottom of the results page, enter a name for the bookmark, and click the Bookmark this SQL-Query button to save the query to the bookmarks file.

When you need to execute the query again, use the SQL tab to obtain a drop-down list of all previously-bookmarked queries. Find the query you bookmarked earlier, select it and Bob's your uncle!

You can also use variables in such bookmarked queries. For example, if you want to specify the sid of the service in the query on a per-instance basis, simply alter the query string to look like this:

SELECT clients.cname, services.sname 
FROM branches, clients, branches_services, services 
WHERE branches.bid = branches_services.bid 
AND clients.cid = branches.cid 
AND branches_services.sid = services.sid /* 
AND services.sid = [VARIABLE] */ 


Now, run the query. The first time around, phpMyAdmin will ignore the condition between the "/*" and "*/" comment marks and run the query after discounting that section of the query string. No matter; when the result set appears, bookmark this query and then use the SQL tab to run it again. This time, you'll be asked for a value for the sid variable, as seen here.

While this is a good feature, be warned that it is still a little buggy: I could not use it with string variables correctly and, while it certainly offers a great way to store complex queries for reuse, it still needs some tweaking.

 
 
>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: