SelectAll returns all rows from the table. SetTableName must be called first.
()
| 233 | |
| 234 | // SelectAll returns all rows from the table. SetTableName must be called first. |
| 235 | func (t *Table) SelectAll() result.Result[*sql.Rows] { |
| 236 | if t.tableName == "" { |
| 237 | return result.FmtErr[*sql.Rows]("table name cannot be empty") |
| 238 | } |
| 239 | t.sqlCode = `SELECT * FROM ` + t.tableName + `;` |
| 240 | |
| 241 | mc := getMysqlConst() |
| 242 | mc.maxConnChan <- true |
| 243 | defer func() { |
| 244 | <-mc.maxConnChan |
| 245 | }() |
| 246 | return result.Ret(db.Query(t.sqlCode)) |
| 247 | } |
| 248 | |
| 249 | func wrapSQLKey(s string) string { |
| 250 | return "`" + strings.ReplaceAll(s, "`", "") + "`" |