gpt4 book ai didi

php - fatal error : Class ConnectionWrapper not found in ConnectionFactory. PHP

转载 作者:行者123 更新时间:2023-11-29 21:42:38 26 4
gpt4 key购买 nike

我是 Propel ORM 的新手。我将 ORM 安装到我的服务器上。我做了所有的配置。我的模型类已生成,我可以创建对象并调用它们的特定方法。

但是,当我尝试调用 propel 类的 save 方法时,它会在 apache 日志中打印一个 fatal error 。您可以看到下面的日志错误:

Fatal error: Class ConnectionWrapper not found in ConnectionFactory.php on line 46

这是我的 composer.php 文件,它生成 autoload.php 文件:

{
"require": {
"propel/propel": "~2.0@dev",
"slim/slim": "2.*"
},
"autoload": {
"classmap": ["generated-classes/"]
}
}

这是我的 test_service.php 文件,我将其称为 propel 方法

<?php
require_once 'vendor/autoload.php';
require_once 'generated-conf/config.php';
echo "ENTERED"."\n";


$date = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $date)));
echo $date."\n";

$customer = new Customer();
$customer->setName("Jason");
$customer->setSurname("Statham");
$customer->setType(2);
$customer->setEmail("jasonstatham@gmail.com");
$customer->setGender("Male");
$customer->setPassword("123");
$customer->setSignupDate($date);



echo $customer->getName()."\n";
echo $customer->getSurname()."\n";
echo $customer->getType()."\n";
echo $customer->getEmail()."\n";
echo $customer->getGender()."\n";
echo $customer->getPassword()."\n";
echo date_format($customer->getSignupDate(), 'Y-m-d H:i:s');
$customer->save();

echo "EXIT"."\n";

?>

在上面的代码中,Propel 类getset 方法工作没有问题。然而,当谈到

$customer->save();

apache 将错误打印到日志中。以下是对请求的响应:

ENTERED
1970-01-01 02:00:00
Jason
Statham
2
jasonstatham@gmail.com
Male
123
1970-01-01 02:00:00

我在这里想念什么?谢谢。

最佳答案

我解决了我的问题...

问题是由于 propel.yaml 文件包含数据库信息引起的:

propel:
database:
connections:
test:
adapter: mysql
classname: Propel\Runtime\Connection\ConnectionWrapper
dsn: "mysql:host=localhost;dbname=test"
user: admin
password: admin
attributes:
runtime:
defaultConnection: test
connections:
- test
generator:
defaultConnection: test
connections:
- test

这是问题已解决的文件。一开始我把ConnectionWrapper类的系统路径写到了classname中,就报错了。它采用 ConnectionWrapper 类的命名空间关系。所以当我用命名空间关系更改它时,问题就解决了。

关于php - fatal error : Class ConnectionWrapper not found in ConnectionFactory. PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34373543/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com