Database Code Snippets in the NetBeans PHP editor

Posted by Andrei Badea on Jun 10 2008, 01:31:49 PM CEST

One of my favorite features in NetBeans is the ability to quickly generate Java code. By invoking the Insert Code [Alt+Insert] action you can generate a large variety of pieces of  Java code: constructors, getters, setters, properties, and so on.

Until yesterday, this feature was only available in the Java editor. But now you can invoke the Insert Code action in the PHP editor too. Two code snippets are available: to generate code which connects to a MySQL database, and to display a database table.


The Connection to Database snippet generates code to connect to the database using the MySQLi extension. After invoking it, you can use the generated connection variable to execute queries, or you can invoke the second snippet, Database Table. This snippet generates PHP code which executes a SELECT statement for a table you specify and displays its results.

These snippets are available in the daily builds and will of course also be in NetBeans 6.5 M1.


Category: Features | Permalink | Comments [3]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/database_code_snippets_in_the
Comments:

Is there a way for the user to write custom snippets?

Posted by Azrael Valedhel on July 29, 2008 at 09:39 PM CEST #

Not exactly snippets, but you can write code templates (Options -> Editor -> Code Templates). We want to support code snippets in the next version.

Thanks,
Petr

Posted by Petr on July 29, 2008 at 10:15 PM CEST #

reyrertyrty

Posted by 146.230.128.29 on August 08, 2009 at 06:58 PM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed