Jump to content

Trouble with SQL query in module


Harmen
 Share

Recommended Posts

Hi there,

 

I am writing a module for people who want to import their products from the prestashop database to a new PW website. But if the database of the customer has another prefix then my database, they can't run the code or their needs to be a possibillity to input their own prefix. So I've added a field where you can input the prefix for the database, but then that inputted prefix needs to be set in the query. I tried the following: 



$categories = $prestashop->prepare("
	SELECT .... .....
	FROM :prefix_category c
	etc etc

and then in the function to import the categories:

$prefix = $this->session->dbPrefix;
$categories = $this->get_category();
$categories->execute(array(':prefix'=>$prefix));
$categories->fetchAll(PDO::FETCH_ASSOC);

But if I run the code, I get the following error:

ImportPagesPrestashop: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Does anyone have an idea how to solve this? Is it possible to make this changeable or should the customers change their prefix to the same prefix as mine?

I hope someone has an idea....

 

(Sorry if you don't understand it. English isn't my native language).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...