更改資料庫連接,testdb->care(HistoricalPage)
This commit is contained in:
@@ -29,20 +29,20 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
|||||||
print('connect');
|
print('connect');
|
||||||
|
|
||||||
final conn = await MySQLConnection.createConnection(
|
final conn = await MySQLConnection.createConnection(
|
||||||
//host: '203.64.84.154',
|
host: '203.64.84.154',
|
||||||
host: '10.0.2.2',
|
//host: '10.0.2.2',
|
||||||
//127.0.0.1 10.0.2.2
|
//127.0.0.1 10.0.2.2
|
||||||
port: 3306,
|
port: 33061,
|
||||||
userName: 'root',
|
userName: 'root',
|
||||||
//password: 'Topic@2024',
|
password: 'Topic@2024',
|
||||||
password: '0000',
|
//password: '0000',
|
||||||
//databaseName: 'care', //testdb
|
databaseName: 'care', //testdb
|
||||||
databaseName: 'testdb',
|
//databaseName: 'testdb',
|
||||||
);
|
);
|
||||||
await conn.connect();
|
await conn.connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var result = await conn.execute('SELECT * FROM users');
|
var result = await conn.execute('SELECT HomeElderFall.*, HomeElder.heName FROM HomeElderFall JOIN HomeElder ON HomeElderFall.heId = HomeElder.heId;');
|
||||||
print('Result: ${result.length} rows found.');
|
print('Result: ${result.length} rows found.');
|
||||||
|
|
||||||
if (result.rows.isEmpty) {
|
if (result.rows.isEmpty) {
|
||||||
@@ -51,14 +51,12 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_results = result.rows
|
_results = result.rows
|
||||||
.map((row) => {
|
.map((row) => {
|
||||||
'id': row.colAt(0),
|
'長者ID': row.colAt(0),//去裝資料庫的行數
|
||||||
'name': row.colAt(1),
|
'姓名': row.colAt(8),
|
||||||
'age': row.colAt(2),
|
'跌倒時間': row.colAt(1),
|
||||||
'gender': row.colAt(3),
|
'跌倒原因': row.colAt(2),
|
||||||
'phone': row.colAt(4),
|
'跌倒地點': row.colAt(7),
|
||||||
'email': row.colAt(5),
|
})
|
||||||
'password': row.colAt(2)
|
|
||||||
})
|
|
||||||
.toList();
|
.toList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -93,12 +91,12 @@ class _HistoricalRecordState extends State<HistoricalRecord> {
|
|||||||
itemCount: _results.length,
|
itemCount: _results.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(_results[index]['name']),
|
title: Text(_results[index]['姓名']),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'age: ${_results[index]['age']}, '
|
'長者ID: ${_results[index]['長者ID']}\n, '
|
||||||
'gender: ${_results[index]['gender']}, '
|
'跌倒時間: ${_results[index]['跌倒時間']}\n, '
|
||||||
'phone: ${_results[index]['phone']}, '
|
'跌倒原因: ${_results[index]['跌倒原因']}\n, '
|
||||||
'email: ${_results[index]['email']}',
|
'跌倒地點: ${_results[index]['跌倒地點']}\n',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _saveChanges() async {
|
void _saveChanges() async {
|
||||||
/*final conn = await MySQLConnection.createConnection(
|
final conn = await MySQLConnection.createConnection(
|
||||||
host: '203.64.84.154',
|
host: '203.64.84.154',
|
||||||
port: 33061,
|
port: 33061,
|
||||||
userName: 'root',
|
userName: 'root',
|
||||||
@@ -88,7 +88,7 @@ class _PersonalInfoState extends State<PersonalInfo> {
|
|||||||
databaseName: 'care',
|
databaseName: 'care',
|
||||||
);
|
);
|
||||||
|
|
||||||
await conn.connect();*/
|
await conn.connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
|
|||||||
Reference in New Issue
Block a user