电晕文本框循环到数据库 [英] corona textbox loop into database

查看:76
本文介绍了电晕文本框循环到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Corona的新手,我有一组10个问题,输入的范围是0-8.我编写了代码,这样我的数字文本框将循环i次(i =数组中的问题数).
我的问题是如何将这些键入的值插入到我创建的数据库中?我是否需要为这些单个问题分配变量?

I am new to Corona and I have a set of 10 question and the input is in the range from 0-8. I have code it such that my numeric textbox will loop for i times (i = number of question in array).
My question is how do I insert these value that is being keyed in into the database that i have created? Do i need to assign these individual question with a variable?

local madrs = display.newGroup()
local function textListener( event )
if ( event.phase == "began" ) then

elseif ( event.phase == "ended" or event.phase == "submitted" ) then
    -- Output resulting text from "defaultField"

print( event.target.text )

elseif ( event.phase == "editing" ) then
    print( event.newCharacters )
    print( event.oldText )
    print( event.startPosition )
    print( event.text )
    end
end
-- Create text field
madrs = native.newTextField( 640, 150 + (i * 450), 100, 100 )
madrs.inputType = "number"
madrs:addEventListener( "userInput", textListener )
madrs.font = native.newFont( native.systemFontBold, 50 )
scrollView:insert( madrs )

如果您不确定我要问什么,请在下面随意评论,我将与您澄清问题.

If you are unsure of what i am asking, feel free to comment down below i will clarify the question with you.

推荐答案

您首先需要问自己是否真的需要SQL/SQLite数据库来存储数据.我会说,如果仅将数据存储为txt文件(通常使用JSON格式),那么99%的Corona应用程序都可以正常运行.

You first need to ask yourself if you really need a SQL/SQLite database to store your data. I would say that 99% of the Corona apps would run as fine if you just store the data as a txt file (usually using JSON format).

如果您仍然想使用SQLite,只需看一下适合您的文档即可.它提供了有关如何执行查询的示例(在您的情况下为INSERT)

If you still want to use SQLite, just take a look at the documentation for you. It provides example on how to execute queries (in your case, INSERT)

Corona/Lua SQLite的链接: https://docs.coronalabs. com/api/library/sqlite3/index.html

Link for Corona/Lua SQLite : https://docs.coronalabs.com/api/library/sqlite3/index.html

这篇关于电晕文本框循环到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆