1. Trang chủ
  2. » Công Nghệ Thông Tin

Professional LAMP Linux Apache, MySQL and PHP5 Web Development phần 10 pot

38 336 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 38
Dung lượng 1,33 MB

Nội dung

ASP.NET/C# visibility interface InterfaceName { } JSP/Java visibility interface InterfaceName { } Class Using Interface PHP class ClassName implements InterfaceName { } ASP/VBScript Not supported ASP.NET/C# visibility class ClassName : InterfaceName { } JSP/Java visibility class ClassName implements InterfaceName { } Including External Files PHP include(‘filename’); include_once(‘filename’); require(‘filename’); require_once(‘filename’); ASP/VBScript <! #include ‘filename’ > ASP.NET/C# Inclusion handled by varying methods, including traditional ASP inclusion (above) 343 Language Translation 17_59723x appa.qxd 10/31/05 6:40 PM Page 343 JSP/Java <%@ include file=”filename” %> Exception Handling PHP try { } catch (ExceptionType $e) { } ASP/VBScript Not specifically supported ASP.NET/C# try { } catch (ExceptionType e) { } finally { } JSP/Java try { } catch (ExceptionType e) { } finally { } Throwing Exceptions PHP throw new ExceptionType(args); ASP/VBScript Err.Raise number 344 Appendix A 17_59723x appa.qxd 10/31/05 6:40 PM Page 344 ASP.NET/C# throw new ExceptionType(args); JSP/Java throw new ExceptionType(args); HTTP POST Values PHP $_POST (array) ASP/VBScript Request.Form (collection) ASP.NET/C# System.Web.HttpRequest.Form (NameValueCollection) JSP/Java request.getParameter() (method lookup) HTTP GET Values PHP $_GET (array) ASP/VBScript Request.QueryString (collection) ASP.NET/C# System.Web.HttpRequest.QueryString (NameValueCollection) JSP/Java request.getParameter() (method lookup) Server Variables PHP $_SERVER (array) 345 Language Translation 17_59723x appa.qxd 10/31/05 6:40 PM Page 345 ASP/VBScript Request.ServerVariables (collection) ASP.NET/C# System.Web.HttpRequest.ServerVariables (NameValueCollection) JSP/Java request.getVariable() (method lookup; different method per server variable) 346 Appendix A 17_59723x appa.qxd 10/31/05 6:40 PM Page 346 Alternative Tools Whenever discussions of popular PHP tools spring up, the conversations usually center around text editors or coding IDEs. Which has the best language support, syntax highlighting, code pars- ing, and so on? Unfortunately, with all the focus on text editors, excellent non-coding tools can sometimes get neglected. Instead of rehashing the usual arguments for one editor versus the other, this appendix shows you some of the tools you can use in your development cycle — those that don’t immediately churn out code, but those that you might find hold a key position in the overall development process. MySQL Tools When you administer a MySQL database, you usually have two main options for administration tools: the standard command-line toolset, or a graphical interface. Despite the attitudes of many hardened system administrators, there’s absolutely nothing wrong with using a graphical tool to get the job done. Although the command-line interface offers unlimited control over the database, it just can’t match the speed and clarity of a good graphical user interface to help facilitate your administration workflow. If you’re looking for a good set of GUI-based MySQL administration tools, you need look no fur- ther than MySQL AB’s own MySQL Administrator and MySQL Query Browser. MySQL Administrator MySQL Administrator is a feature-rich GUI administration tool or maintaining MySQL databases. The main interface is shown in Figure B.1. 18_59723x appb.qxd 10/31/05 6:39 PM Page 347 Figure B.1 MySQL Administrator allows you to do the following: ❑ View real-time server information, including connection information and statistics, memory statistics, the value for MySQL internal variables and configuration settings, and more. ❑ View the different server logs: Error log, Slow log, General Log (localhost only). ❑ Control the MySQL process itself (localhost only). ❑ Perform backup and restore operations, and even schedule periodic backups. ❑ Administer the server’s user access and privileges. ❑ Create and edit complete databases, including tables using the built-in MySQL Table Editor. MySQL Administrator is available for Windows, Linux, and Mac OS X; MySQL Administrator is a free download from the MySQL website: http://www.mysql.com/products/administrator/. 348 Appendix B 18_59723x appb.qxd 10/31/05 6:39 PM Page 348 MySQL Query Browser MySQL Query Browser is a GUI that allows you to test and run various queries against the MySQL database. In a sense, it is a beefed-up GUI version of the command-line client, as you can see in Figure B.2. You can also use MySQL Query Browser similar to a standard spreadsheet program or desktop database application — you can pull up rows of data, and edit them directly in the query browser. In addition to just typing in and executing queries, and manipulating data, it also includes the MySQL Table Editor found in MySQL Administrator, allowing you to visually create and edit databases and tables. Figure B.2 Windows, Linux, and Mac OS X versions are available from MySQL at http://www.mysql.com/ products/query-browser/ . So you’ve got your applications up and running, and your servers tweaked for peak performance. But are your database queries as lean and mean as they can be? The only way to know for sure is to use a benchmarking tool. 349 Alternative Tools 18_59723x appb.qxd 10/31/05 6:39 PM Page 349 Most MySQL benchmarking tools perform in roughly the same way: you provide a query to run, and it runs said query a large number of times, often using concurrent connections. By thoroughly testing and experimenting with some of your “heavier” queries (often found in the MySQL slow query log), you can improve the execution times and server load at application bottlenecks. MySQL Super Smack Originally developed by Sasha Pachev, MySQL Super Smack is a standalone stress-testing tool for use with MySQL and PostgreSQL. MySQL Super Smack takes one or more files containing queries, and hammers the target database a predefined number of times for each query, with a specified number of concurrent connections. MySQL Super Smack is available at http://vegan.net/tony/supersmack/. MyBench MyBench is a Perl-based benchmarking tool created by MySQL guru Jeremy Zawodny. Like MySQL Super-Smack, it can be used to send a barrage of connections and queries at a target MySQL machine, and give clear results on how well it stood up to the attack. Since it is written in Perl, you can easily modify and extend it as you wish. The downside is that a large test batch can hog machine resources, so it’s best to run this tool on a different machine than the target MySQL server, to avoid tainting of the results. MyBench is available at Jeremy Zawodny’s site: http://jeremy.zawodny.com/mysql/mybench/. Version Control You might want to consider some form of version control system in your development lifecycle or work- flow, if you haven’t already. Version control systems provide a way to store historical snapshots of code during development, and allow multiple developers to check files in and out of the repository, control- ling the evolution of the codebase. Two of the most popular open-source version control systems in use today are CVS and Subversion. CVS and Subversion are each version control systems that support the same basic features: historical records of file versions, and multiple developer support with check-in/check-out functionality. CVS has been around since 1989, and is the perennial favorite among many developers. Subversion is newer to the scene, first appearing late 2000, but is quickly gaining devotees because of its feature set, which extends beyond the “standard” functionality found in CVS. Features such as atomic commits, “safe” file renaming, file and directory copying, and WebDAV support are some of the reasons that many develop- ers are going with Subversion these days. If you are looking for a robust feature set with good support both client- and server-side, Subversion is probably your best bet. If you’re looking for stability, track record, and support built-in to many development tools, CVS is probably preferable — although more and more development packages are gaining Subversion support lately. 350 Appendix B 18_59723x appb.qxd 10/31/05 6:39 PM Page 350 Whichever you choose, it’s a good idea to get some sort of version control in place when you can—it makes multiple-developer projects easier to manage, and can provide a safety net in case newer code actually causes nasty new bugs or regression problems. CVS is available at https://www.cvshome.org/. Subversion is available at http://subversion.tigris.org/. UML Tools If you ever get deep into the realm of system architecting and design, chances are you will cross paths with UML at some point. If you’re not familiar with UML, simply put, it is a way to model and represent the structure, behavior, architecture, and process flow of an application or other system. You can use UML to diagram different aspects of a system or application, including the class structure, user interac- tion, object interaction, process flow, and so on, similar to flowcharts and other diagrams you might make with Visio, Kivio, or other related tools. There are nine diagram types in UML, but from the developer’s point of view, one of the most important is the Class diagram. Class diagrams help you plan your various classes, and the relationships between those classes. If you use UML in your PHP workflow, you have a couple tools at your disposal — some popular free tools are ArgoUML and Umbrello. ArgoUML ArgoUML is a Java-based UML editor created by the Tigris.org community. It supports eight of the major UML diagram types, and can help you quickly plan out your objects, relationships, and behaviors. One of the main features of ArgoUML, from a PHP developer’s point of view, is that it can generate valid PHP5 class skeletons from UML class diagrams automatically (as well as C#, Java, C++, and PHP4), as shown in Figure B.3. You simply create your class diagrams in UML and tell ArgoUML what and where to generate the code, saving you the time of typing the structure of the classes, and letting you get on to the meat of the code: the implementation. ArgoUML also provides machine-generated suggestions regarding your class struc- tures, and features an integrated to-do list. ArgoUML is available as a desktop Java application, both downloadable and runnable from the Internet via JavaWebStart, at http://argouml.tigris.org/. 351 Alternative Tools 18_59723x appb.qxd 10/31/05 6:39 PM Page 351 Figure B.3 Umbrello Umbrello is another UML diagramming application, much like ArgoUML. Umbrello is now part of the KDE developer tools package, and supports many of the major UML diagram types, including Class diagrams, Use Case diagrams, State diagrams, and Sequence diagrams. As of version 1.4, Umbrello can generate PHP5 class skeletons, as well as code for several other programming languages, as shown in Figure B.4. 352 Appendix B 18_59723x appb.qxd 10/31/05 6:39 PM Page 352 [...]... SHOW COLUMNS command, 101 SHOW CREATE TABLE command, 101 102 SHOW DATABASES command, 102 SHOW GRANTS command, 102 starting the command-line client, 74 tables_priv table, 99, 100 unions, 82–86 updating database information, 77, 91–92 USE statement, 75 user administration, 93 100 user table, 97–98, 99 100 USING statement, 79 WHERE clause, 79, 80, 81 MySQL Administrator tool, 347–348 MySQL Query Browser... extension (PHP) SHOW COLUMNS command (MySQL) , 101 SHOW CREATE TABLE command (MySQL) , 101 102 SHOW DATABASES command (MySQL) , 102 SHOW GRANTS command (MySQL) , 102 Simple AJAX Toolkit (SAJAX), 282–283 SimpleXML extension (PHP) overview, 16, 269–270 xpath() method, 125, 127 single quotes (‘), speed of strings and, 201–205 site security See also authentication access control with Apache, 165–166 access control... USE statement (MySQL) , 75, 149 user administration (MySQL) alternatives to GRANT and REVOKE, 97 100 columns_priv table for, 99, 100 db table for, 98–99, 100 GRANT command for, 94–96 overview, 93–94 reloading privilege tables, 100 REVOKE command for, 96–97 tables_priv table for, 99, 100 user table for, 97–98, 99 100 user table (MySQL) , 97–98, 99 100 USING statement with inner joins (MySQL) , 79 V var... directive, 107 MySQLi settings, 12 output compression settings, 149 for PHP authentication example, 171 PHP5 improvements, 12, 107 108 recommended configuration directives, 105 107 register_globals directive, 105 , 116 register_long_arrays directive, 107 retrieving settings at runtime, 109 – 110 safe_mode directive, 171 session.hash_bits_per_character directive, 108 session.hash_function directive, 108 short_open_tag... control (Apache) See authentication access control (MySQL) alternatives to GRANT and REVOKE, 97 100 columns_priv table for, 99, 100 db table for, 98–99, 100 GRANT command for, 94–96 reloading privilege tables, 100 REVOKE command for, 96–97 server restriction, 100 tables_priv table for, 99, 100 user administration, 93 100 user table for, 97–98, 99 100 access control (PHP) Basic Authentication, 166–171... 266–269 websites for further information, 263 mod_alias (Apache), 226 mod_auth _mysql (Apache) advantages, 166 AuthMySQLAuthoritative directive, 154 AuthMySQLDB directive, 151, 152 AuthMySQLEnable directive, 151, 152 AuthMySQLGroupCondition directive, 154 AuthMySQLGroupField directive, 154 AuthMySQLGroupTable directive, 154 AuthMySQLHost directive, 152 AuthMySQLNameField directive, 153 AuthMySQLPassword... tool, 349–350 MySQL Super Smack tool, 350 mysqli class, 13–15 MySQLi (MySQL improved), 12–16 mysqli_pconnect() function, performance and, 231 mysqli_result class, 16 mysqli_stmt class, 15 N namespaces collision prevented by create_function() function, 57–58 language translation, 337 naming conventions, 220–222 nesting, reducing levels of, 217–220 network connection, performance and, 210 new keyword... 208–209 Apache web server improvements, 211–213 benchmarking, defined, 206–207 benchmarking, speed of strings example, 201–205 caching and, 223–227 checking array size and, 229 conditional statements and, 230 echo versus print and, 228–229 hardware improvements, 210 211 memory and, 200 multiplication operators and, 200–201 NT4/Access report generator anecdote, 200 ob_start(‘ob_gzhandler’) and, 231 output... operators, performance and, 200–201 MyBench MySQL tool, 350 my.cnf configuration file (MySQL) , 88, 100 MyISAM tables (MySQL) converting InnoDB to, 93 converting to InnoDB, 90 as default storage engine, 88 MySQL See also SELECT statement (MySQL) access control, 93 100 aliases for tables, 78–79 ALTER TABLE statement, 87, 90–91, 92 alternative tools, 347–350 analyzing databases, 100 102 Apache authentication... databases, 103 104 monitor, 74 MyBench tool, 350 my.cnf configuration file, 88 MyISAM tables, 88, 90, 93 MySQL Administrator tool, 347–348 MySQL Query Browser tool, 349–350 MySQL Super Smack tool, 350 outer joins, 81–82 querying multiple tables, 77–86 reloading privilege tables, 100 restoring from backups, 103 104 retrieving database information, 76–77 REVOKE command, 96–97 server restriction, 100 setting . using the built-in MySQL Table Editor. MySQL Administrator is available for Windows, Linux, and Mac OS X; MySQL Administrator is a free download from the MySQL website: http://www .mysql. com/products/administrator/. 348 Appendix. control (MySQL) alternatives to GRANT and REVOKE, 97 100 columns_priv table for, 99, 100 db table for, 98–99, 100 GRANT command for, 94–96 reloading privilege tables, 100 REVOKE command for,. times and server load at application bottlenecks. MySQL Super Smack Originally developed by Sasha Pachev, MySQL Super Smack is a standalone stress-testing tool for use with MySQL and PostgreSQL. MySQL

Ngày đăng: 12/08/2014, 23:23

TỪ KHÓA LIÊN QUAN