Database Code Snippets in the NetBeans PHP editor

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.


Comments:

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

Posted by Azrael Valedhel on July 29, 2008 at 02: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 03:15 PM CEST #

reyrertyrty

Posted by guest on August 08, 2009 at 11:58 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today