Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top