This seems so stupid.
This works:
$db = "nameone";
$coll = "utf8_bin";
$sth = $this->dbh->prepare("CREATE DATABASE $db COLLATE $coll");
$sth->execute();
But this gives the following errors: $sth->errorInfo[0] => 42000. $sth->errorInfo[2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''nametwo' COLLATE 'utf8_bin'' at line 1.
$db = "nametwo";
$coll = "utf8_bin";
$sth = $this->dbh->prepare('CREATE DATABASE :db COLLATE :coll'); // Changing to double quotes does not matter. Get same error.
$sth->bindParam(':db', $db);
$sth->bindParam(':coll', $coll);
$sth->execute();
What am I missing that would cause the second code with the named parameters and bindParam to error like that. Please note that I'm using database name and collation type, not table name and column name, and that the errors are syntax related. Is there a module that needs to be enabled in php.ini?
Thanks,
Steve