- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 PHP 和 CakePHP 的新手。在使用 CakePhp 连接我的数据库时发现问题。
下面是我的应用配置。我在 Bitnami WAMP 堆栈 5.4.40-0我正在使用 CakePhp 3.0.4 创建一个 web mvc 应用程序
我的 app.php 文件中的数据源条目
/**
* Connection information used by the ORM to connect
* to your application's datastores.
* Drivers include Mysql Postgres Sqlite Sqlserver
* See vendor\cakephp\cakephp\src\Database\Driver for complete list
*/
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
/**
* CakePHP will use the default DB port based on the driver selected
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
* the following line and set the port accordingly
*/
//'port' => 'nonstandard_port_number',
'username' => 'test2',
'password' => 'computer',
'database' => 'jobs',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
/**
* Set identifier quoting to true if you are using reserved words or
* special characters in your table or column names. Enabling this
* setting will result in queries built using the Query Builder having
* identifiers quoted when creating SQL. It should be noted that this
* decreases performance because each query needs to be traversed and
* manipulated before being executed.
*/
'quoteIdentifiers' => false,
/**
* During development, if using MySQL < 5.6, uncommenting the
* following line could boost the speed at which schema metadata is
* fetched from the database. It can also be set directly with the
* mysql configuration directive 'innodb_stats_on_metadata = 0'
* which is the recommended value in production environments
*/
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
],
我可以使用 bake 命令生成基本样板代码
但是现在当我在 localhost:8765/myapp 中运行我的应用程序时
出现以下错误
2015-07-01 14:31:22 Error: [RuntimeException] Unable to locate an object compatible with paginate.
请求网址:/myjobs
我的 Controller 代码
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* Jobs Controller
*
* @property \App\Model\Table\JobsTable $Jobs
*/
class MyJobsController extends AppController
{
/**
* Index method
*
* @return void
*/
public function index()
{
$this->paginate = [
'contain' => ['Jobs']
];
$this->set('jobs', $this->paginate($this->Jobs));
$this->set('_serialize', ['jobs']);
}
/**
* View method
*
* @param string|null $id Job id.
* @return void
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function view($id = null)
{
$job = $this->Jobs->get($id, [
'contain' => ['Jobs']
]);
$this->set('job', $job);
$this->set('_serialize', ['job']);
}
/**
* Add method
*
* @return void Redirects on successful add, renders view otherwise.
*/
public function add()
{
$job = $this->Jobs->newEntity();
if ($this->request->is('post')) {
$job = $this->Jobs->patchEntity($job, $this->request->data);
if ($this->Jobs->save($job)) {
$this->Flash->success(__('The job has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The job could not be saved. Please, try again.'));
}
}
$jobs = $this->Jobs->Jobs->find('list', ['limit' => 200]);
$this->set(compact('job', 'jobs'));
$this->set('_serialize', ['job']);
}
/**
* Edit method
*
* @param string|null $id Job id.
* @return void Redirects on successful edit, renders view otherwise.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$job = $this->Jobs->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$job = $this->Jobs->patchEntity($job, $this->request->data);
if ($this->Jobs->save($job)) {
$this->Flash->success(__('The job has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The job could not be saved. Please, try again.'));
}
}
$jobs = $this->Jobs->Jobs->find('list', ['limit' => 200]);
$this->set(compact('job', 'jobs'));
$this->set('_serialize', ['job']);
}
/**
* Delete method
*
* @param string|null $id Job id.
* @return void Redirects to index.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$job = $this->Jobs->get($id);
if ($this->Jobs->delete($job)) {
$this->Flash->success(__('The job has been deleted.'));
} else {
$this->Flash->error(__('The job could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}
还想知道在 8765 端口运行的内部服务器在哪里。 ?我想使用 eclipse 调试此服务器上的资源。
最佳答案
当您键入错误的 url 时会发生此错误:
应该是其中之一
localhost:8765/my-app
localhost:8765/myApp
localhost:8765/my_app
但不是:localhost:8765/myapp
关于php - 无法定位与分页兼容的对象。使用 CakePHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31165889/
我必须从我的网站中删除()一些iem,然后将它们追加()回来,但是当我追加它们时,它们出现在不同的地方,而我希望它们完全显示在它们以前的同一个地方是。 有什么解决办法吗? 这是一个沙箱,请随意更新(注
一个。图片 (960x7)b. div(宽度:960,填充:10) 我想定位 (a),使其距顶部 50 像素,居中。我想将 (b) 放置在 (a) 的正下方,没有空格。 我的 CSS 如下: @cha
放置某物的正确方法是什么?我有一个在中心显示博客文章的 div。 "" rel="bookmark"> BY LOUIS MOORE ON " pubdate>
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭1
我已经成功地使用了 position:fixed 设置 CSS/CSS3 并且工作得很好! 我几天前看到了这个,想知道他们是如何实现向下滚动时发生的效果的,菜单栏在滚动前处于一个位置,然后转到顶部并自
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improv
接口定义 能够对于文字、段落乃至任何元素的精准定位 并做出增删改查,都是在开发一款富文本编辑器时一项最基本也是最重要的功能之一。让我们先来看看Slate中对于如何在文档树中定位元素是怎么定义的
例如,使用 WPF 在选项卡控件的最左上角定位三个 tabitem 和在最右上角定位一个 tabitem 的正确方法是什么? 我尝试通过更改边距将第四个 tabitem 向右移动,但这并没有产生好的结
我正在尝试使用 Javascript 创建一个跟随鼠标在页面上移动的东西。我希望它是米老鼠,我希望他的眼睛跟随鼠标移动他的眼球...这是我到目前为止的代码(从网络上的各个地方收集,因此归功于编写该部分
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭 9 年前。 Improve
我试图将两个按钮放置在左上角。但它们始终位于顶部中心。 我已经尝试过这个: jp = new JPanel(); jp.setLayout(new GridBagLayout()); GridBagC
我在使用 JQuery 向下滑动功能时遇到问题。我可以让它正常工作,但是我向下滑动的元素的位置会根据视口(viewport)的大小而变化。我想做的是将它与它滑动的元素联系起来。 This JSfidd
我正在尝试创建一个棋盘,并将其放置在屏幕中间,但到目前为止我无法将它直接放在中间。我不想将位置硬编码到屏幕上,因为我要处理不同的屏幕尺寸。 var winsize = cc.director.
我正在尝试从 mysql 中的 2 个字符串点之间提取数据,我的示例脚本是 'otherdata&p1=textneeded&otherdata' 我需要拉出“textneeded”位,“P1=”是起
如何在 JavaFX 中设置按钮的位置?我的代码: bZero = new Button(); bZero.setPrefSize(45, 20); mainPane.getChildren().ad
我有一个 iPhone 应用程序,我可以在其中显示一系列图像。当用户点击图像时,我需要将该图像带到第一个位置,表明它是所选图像。我可以通过子类化实现 uiscrollview 中的点击。但是我无法将
在下图中,它显示了一个image、textbox 和一个css menu image 我的 CSS 菜单非常完美。我终于按照我需要的方式得到了它。我的问题是我需要导航栏中央的文本框,然后我需要我的图像
我必须创建一个看起来像这样的 div id为2的div应该出现在图片的右下角,图片的大小不固定id=2的div应该应用什么css id =1 的 div 没有定义位置,所以使用默认值,图像也是
如何将我的文本和图像对齐在同一行? 每当我使用 padding 或 margins 时,它就会崩溃到我正在使用的圆形图像中。 #alignPhoto { padding-right: 50px;
简单的问题,如何定位具有整个页面引用的元素? 在我的例子中,我在标题中得到了一个 float 图像,然后是 2 组标题。当我使用时: text-align: center; 它使用图像宽度端和页面其余
我是一名优秀的程序员,十分优秀!