dimanche 12 juin 2016

How to get number of rows by select query using mysql in go lang

I'm new in go lang. I want to create a login verification from MySQL db. I want a method like as in PHP mysqli_num_rows($res)==1... I tried len(rows) or rows.Column() @fmt.Println("No of rows are :",rows) but it won't... The code which i tried ... (It is a dummy code)

rows, err := db.Query("select * from userLog where u_name = ? and u_pass = ?", uname,pswd)
  if err != nil {
     log.Fatal(err)
   }
   fmt.Println("No of rows are :",rows)
   defer rows.Close()

If you have another solution for login verification purpose then kindly suggest and explain it briefly Kindly help me out.

Aucun commentaire:

Enregistrer un commentaire