AIR和SQLite:如果表存在的条件 [英] AIR and sqLite : if table exists conditional

查看:117
本文介绍了AIR和SQLite:如果表存在的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在AS3一个布尔值是否一个表或数据库中的一个条目存在?

How do I get a Boolean value in AS3 whether a table or an entry exists in the database?

推荐答案

至于反对与SQL手动找到它,你应该使用内置的架构信息类/功能。这里是它如何工作的例子。

As opposed to finding it manually with SQL you should use the built in Schema information classes/functions. Here is an example of how it would work.

public function doesTableExist(connection:SQLConnection, tableName:String):Boolean
{
    connection.loadSchema();
    var schema:SQLSchemaResult = connection.getSchemaResult();

    for each (var table:SQLTableSchema in schema.tables)
    {
        if (table.name.toLowerCase() == tableName.toLowerCase())
        {
            return true;
        }
    }
    return false;
}

这篇关于AIR和SQLite:如果表存在的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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