CakePHP表即使存在也缺失

编程入门 行业动态 更新时间:2024-10-09 04:16:25
本文介绍了CakePHP表即使存在也缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试Google搜索并在此搜索答案,

i tried googling and searched for an answer here too,

问题

即使CakePHP存在,CakePHP也找不到该表。

CakePHP can't find a table even when it exist.

我尝试的:

  • 清除缓存文件夹
  • 验证表格名称连接字符串。
  • 添加useTable =urls
  • / strong>

    The code

    class Url extends AppModel { public function add_url($the_url,$the_content,$title) { $this->create(); $this->set('url', $the_url ); $this->set('content', $the_content ); $this->set('title', $title ); $this->save(); } }

    错误: / p>

    The error:

    缺少数据库表

    Missing Database Table

    错误:未找到模型Url的表网址数据源默认。

    Error: Table urls for model Url was not found in datasource default.

    也许有人知道这个答案?

    Perhaps someone knows the answer to this?

    推荐答案

    检查缓存问题

    消除)缓存相关的问题是简单地禁用缓存:

    /** * Turn off all caching application-wide. * */ Configure::write('Cache.disable', true);

    如果这解决了问题,有必要进一步看看为什么以前的努力清除缓存显然失败了。如果使用基于文件的缓存,确保删除 tmp 下的所有文件,如果使用不同的缓存存储,确保实际被清除。

    If this solves the problem, it's necessary to take a closer look at why previous efforts to clear the cache apparently failed. If file-based caching is used ensure all files under tmp are deleted, if a different cache store is being used ensure it's actually being cleared.

    另一个相对常见的原因是数据库用户不能有权限列出给定数据库中的表,这可以用相同的方式检查 a model does it :

    Another relatively common cause for what is described is for the database user to not have permission to list the tables in the given database, this can be checked for in the same way a model does it:

    $db = ConnectionManager::getDataSource('default'); debug($db->listSources()); die;

    如果没有列出任何表 - 检查连接凭据,并确保是没有权限相关的问题。执行 CakePHP正在执行的同一个sql 通过cli并确保结果符合预期:

    If there are no tables listed at all - check the connection credentials and ensure that, for example, there are no permission related problems. Execute the same sql that CakePHP is executing via the cli and ensure that the result is as expected:

    $ mysql -uuser -ppassword databasename mysql> show tables from foo; +-----------------+ | Tables_in_foo | +-----------------+ | posts | | urls | +-----------------+ 2 rows in set (0.00 sec)

    如果是列表,则双击,三重和四重检查连接凭据,因为相关代码正常工作,缺少实际上不存在于应用程序正在连接的数据库中。

    If there are tables listed - then double, triple and quadruple check the connection credentials as the relevant code is working as expected and the table that is missing does not in fact exist in the database the application is connecting to.

    更多推荐

    CakePHP表即使存在也缺失

    本文发布于:2023-11-28 01:04:43,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1640353.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:缺失   CakePHP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!