You don't have to say much about the interface. Raise your hand!
Here, I will post the method of database access and extjs table creation.
1 access SQLite 3:
Function get_sqlite3_data ()
{
D = new array ();
Q = "select * From test_table ;";
DB. Query (Q );
While (db. Fetch ())
{
Idx = dB. get_array_data ("idx ");
Name = dB. get_array_data ("name ");
Email = dB. get_array_data ("email ");
A = new array (idx, name, email );
D. Push ();
}
Return D;
}
2. Access MySQL
2.1 JavaScript part
Function get_myssql_data (host, user, PWD)
{
Create_mysql_data (host, user, PWD );
// PHP = DVM. getdomaindobject ("php"); alert (PHP. get_output_string ());
D = new array ();
Q = "select * From mymatters ;";
Mysql_db.query (Q );
While (mysql_db.fetch ())
{
Name = mysql_db.get_array_data ("name ");
Amount = mysql_db.get_array_data ("amount ");
Describe = mysql_db.get_array_data ("Description ");
A = new array (name, amount, describe );
D. Push ();
}
Return D;
}
2.2 PHP part
Class mysqlaccess
{
Public $ dB;
Public $ query_result;
Public $ row_array;
Public Function open ($ host, $ user, $ PWD ){
$ This-> DB = mysql_connect ($ host, $ user, $ PWD );
// Die ($ this-> dB );
Mysql_select_db ("test ");
// $ This-> query ("create table mymatters (name varchar (30), amount int, kind varchar (16), buyself int, description varchar (255 ))");
// Die (mysql_errno ($ this-> dB). ":". mysql_error ($ this-> dB ));
}
Public Function close (){
Mysql_close ($ this-> dB );
}
Public Function query ($ SQL ){
$ This-> query_result = mysql_query ($ SQL );
// Echo ($ this-> query_result );
}
Public Function fetch (){
$ This-> row_array = mysql_fetch_assoc ($ this-> query_result );
If ($ this-> row_array)
Return true;
Return false;
}
Public Function get_array_data ($ field_name ){
Return $ this-> row_array [$ field_name];
}
}
3. Use extjs to generate table display data
Function show_mysql_data (mysql_data_panel, my_data, host, user, PWD)
{
VaR XG = ext. grid;
// Shared Reader
VaR reader = new Ext. Data. arrayreader ({},[
{Name: 'idx '},
{Name: 'name '},
{Name: 'email '}
]);
//////////////////////////////////////// //////////////////////////////////////// ////////
// Grid 1
//////////////////////////////////////// //////////////////////////////////////// ////////
VaR grid1 = new XG. gridpanel ({
Store: New Ext. Data. Store ({
Reader: reader,
Data: my_data
}),
CM: New XG. columnmodel ([
{ID: 'idx', header: "name", width: 3, sortable: True, dataindex: 'idx '},
{Header: "quantity", width: 10, sortable: True, dataindex: 'name '},
{Header: "Description", width: 10, sortable: True, dataindex: 'email '}
]),
Viewconfig :{
Forcefit: True
},
Width: 600,
Height: 300,
Collapsible: True,
Animcollapse: false,
Title: 'mysql data: '+ host + ":" + User + "-" + PWD,
Iconcls: 'icon-grid ',
Renderto: mysql_data_panel
});
}
Download