LoginSignup
1
0

More than 1 year has passed since last update.

Sample App of Flutter3 x MySQL8 with mysql_client 2

Last updated at Posted at 2022-09-11

select_pageを修正しました。 

 といっても、残念ながら懸案のListView化ではないのですが・・・。

修正済みコードはこちら

元の記事はこちら

検索機能の強化 

 当初の設定ではcountryというcolumnについて、書き込んだ国名で絞り込む、という設定でした。 

 今回はどのcolumnについて絞り込むかを、複数、自由に記入でき、なおかつそれをand または or で繋いでいます。変更箇所は次の通りです。 

 var result = await conn.execute(
        "SELECT * FROM timeline WHERE $targetColumn1 = '$searchTerm1' $logique $targetColumn2 = '$searchTerm2' ORDER BY year");

 例えば 
 

  • targetColum1 を country
  • targetColum2 を place
  • logique を and
  • searchTerm1 を Italy
  • searchTerm2 を Rome

 とすれば、イタリアの中でも、特にローマで起こった事件のみを選択できます。 
 また 

  • targetColum1 を country
  • targetColum2 も country
  • logique を or
  • searchTerm1 を Italy
  • searchTerm2 を Greece

 とすれば、イタリアかギリシアでの出来事が抽出されます。 

注意点 

 SELECT文全体を " " でかこみ、$searchTermはさらにシングルクォートで囲みます。ただし、targetやlogiqueを囲むと、エラーになります。
 

めざせListView 

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0