我已经使用 PRAGMA table_info 来获取 ionic 框架中特定表的信息但是当我尝试编译它时我收到错误作为 table_info 的意外标记。但是当我在数据库浏览器中尝试相同的查询时(SQLite ) 我得到了结果。
我在我的应用中使用了 CordovaSQLite 插件。
PRAGMA table_info(contacts)
最佳答案
尝试在这样的查询中给出它
$cordovaSQLite.execute(self.db, 'PRAGMA table_info(category)').then(function (res) {
for (var i = 0; i < res.rows.length; i++) {
if (res.rows.item(i).name === 'is_deleted') {
hasISDeleted = true;
}
}
if (hasISDeleted === true) {
$log.log('going to update category');
var query = 'UPDATE category SET is_deleted = ? WHERE is_deleted IS NULL';
prom = $cordovaSQLite.execute(self.db, query, ['false']).then(function (res) {
console.log(res);
$log.log('category response', res);
});
$log.log('category prom', prom);
proms.push(prom);
$q.all(proms).then(function () {
defer.resolve('Sucess');
});
} else {
defer.resolve('Sucess');
}
});
希望它能奏效。
关于angularjs - 在 ionicframework 中为 sqlite 获取 table_info 的意外标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45834285/