想要使用 Doctrine DBAL

发布于 2024-10-22 07:00:37 字数 908 浏览 6 评论 0原文

我想使用 Doctrine DBAL ,我从网站下载了 DBAL 文件夹。并将该文件夹放在我的服务器上。 然后将此代码写入我的文件中。

use Doctrine\Common\ClassLoader;

require 'Doctrine/Common/ClassLoader.php';

$classLoader = new ClassLoader('Doctrine', 'Doctrine');
$classLoader->register(); 


$config = new \Doctrine\DBAL\Configuration();
//..
$connectionParams = array(
    'dbname' => 'mydb',
    'user' => 'user ',
    'password' => 'password',
    'host' => 'host',
    'driver' => 'pdo_mysql',
);
$conn = DriverManager::getConnection($connectionParams);
$stmt = $conn->query($select_resellerData);
    $fetch = $stmt->fetch();
print_r($fetch); 

给了我这个错误。

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/abhijitnair/sandbox/reseller dashboard/manual_population/populatenew.php on line 3

请建议我需要什么来使用 dbal。

谢谢

I want to use Doctrine DBAL , I downloaded the DBAL folder from a site. and put the folder on my server .
and then write this code in my file .

use Doctrine\Common\ClassLoader;

require 'Doctrine/Common/ClassLoader.php';

$classLoader = new ClassLoader('Doctrine', 'Doctrine');
$classLoader->register(); 


$config = new \Doctrine\DBAL\Configuration();
//..
$connectionParams = array(
    'dbname' => 'mydb',
    'user' => 'user ',
    'password' => 'password',
    'host' => 'host',
    'driver' => 'pdo_mysql',
);
$conn = DriverManager::getConnection($connectionParams);
$stmt = $conn->query($select_resellerData);
    $fetch = $stmt->fetch();
print_r($fetch); 

is giving me this error .

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/abhijitnair/sandbox/reseller dashboard/manual_population/populatenew.php on line 3

Please suggest what i need to use dbal.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痕至 2024-10-29 07:00:37

如果错误来自“use”行,则该错误很可能是因为您没有安装(或正在使用)PHP 5.3 或更高版本。命名空间是在 5.3 中引入的,因此任何早期版本都不会将“use”一词识别为语言关键字来指示所使用的命名空间。解析错误很可能是由于过时的 PHP 版本认为“use”是一个函数,并且函数名称后面需要一个 (

If the error is from the line on "use", then the error is most likely because you don't have PHP 5.3 or later installed (or in use). Namespaces were introduced in 5.3 so any earlier version would not recognize the word "use" as a language keyword to indicate the used namespace. The parse error is most likely caused, because the dated PHP version thinks that "use" is a function and it's expecting a ( after the function name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文