烘焙工具无法在SQLite3数据库中查看表 [英] Bake tool cannot see tables in SQLite3 database

查看:164
本文介绍了烘焙工具无法在SQLite3数据库中查看表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用CakePHP 2.1.1使用SQLite3作为数据库构建一个简单的应用程序。为了节省时间,我尝试使用烘焙工具为下表创建模型:

  CREATE TABLE animals b id integer primary key autoincrement,
name text
);

但是bake工具返回以下错误:您的数据库没有任何表格。



我想到Cake有一个问题连接到数据库,所以我继续创建相应的模型,控制器, 。我在动物表中插入了一条记录。它工作。



我在搜索网络后没有想到。没有人试图在SQLite3数据库上使用烘焙工具,或者我有运气不好。



有没有任何想法?



UPDATE
$ b

下面是 cake bake 的输出结果:

  johan @ ubuntu:〜/ php / app $控制台/蛋糕烘焙模型

欢迎来到CakePHP v2.1.1控制台
------------- --------------------------------------------------
应用:app
路径:/ home / johan / php / app /
------------------------ ---------------------------------------
------- -------------------------------------------------- ------
烘焙模型
路径:/ home / johan / php / app / Model /
----------------- ----------------------------------------------
您的数据库没有任何表。

和配置文件:

 < $ php 
class DATABASE_CONFIG {
public $ default = array(
'datasource'=>'Database / Sqlite',
' persistent'=> false,
'host'=>'localhost',
'database'=>'cake',
);
}

数据库文件位于〜/ php / app / webroot / / p>

解决方案

尝试将完整路径放入数据库配置,这是我在我的应用程序:

 <?php 
define('DEFAULT_DB',TMP.'db'.DS.'main.db3');

class DATABASE_CONFIG {
public $ default = array(
'datasource'=>'Database / Sqlite',
'persistent'=> false,
'host'=>'',
'database'=> DEFAULT_DB,
'encoding'=>'utf8',
);
}


I am trying to build a simple app with CakePHP 2.1.1 using SQLite3 as the database. To save time I tried to use the bake tool to create a model for the following table:

CREATE TABLE animals (
  id integer primary key autoincrement,
  name text
);

but the bake tool returns the following error: Your database does not have any tables.

I figured Cake had a problem connecting to the database, so I went ahead and created the appropriate model, controller, and views myself. I inserted a single record into the animals table. And it worked.

I came up with nothing after searching the web. Either nobody tried to use the bake tool on an SQLite3 database, or I am having bad luck.

Does anyone have any ideas?

UPDATE

Here's the output of cake bake:

johan@ubuntu:~/php/app$ Console/cake bake model

Welcome to CakePHP v2.1.1 Console
---------------------------------------------------------------
App : app
Path: /home/johan/php/app/
---------------------------------------------------------------
---------------------------------------------------------------
Bake Model
Path: /home/johan/php/app/Model/
---------------------------------------------------------------
Your database does not have any tables.

and the config file:

<?php
class DATABASE_CONFIG {
    public $default = array(
        'datasource' => 'Database/Sqlite',
        'persistent' => false,
        'host' => 'localhost',
        'database' => 'cake',
    );
}

The database file is located at ~/php/app/webroot/cake

解决方案

Try putting a full path into your database config, this is what I did in my app:

<?php
define('DEFAULT_DB', TMP.'db'.DS.'main.db3');

class DATABASE_CONFIG {
    public $default = array(
        'datasource' => 'Database/Sqlite',
        'persistent' => false,
        'host' => '',
        'database' => DEFAULT_DB,
        'encoding' => 'utf8',
    );
}

这篇关于烘焙工具无法在SQLite3数据库中查看表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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