Jump to content

Adding values in the database


beginner1

Recommended Posts

Hi I am trying to add the values in the database. I know that this statement is used to insert the values.

 

Db::getInstance()->insert("ps_mymodulename", $values_array);

Have I written the statement correctly? The arguments are correct too? The modules are named in the database with ps_modulename and the second argument is the array that includes the column name as key and arguments as the values in the respective columns in the database.

Link to comment
Share on other sites

If you have that table in the database, yes. If not, you have to create it, prestashop doesn't do it manually. Also you don't need the prefix:


Db::getInstance()->insert("mymodulename", $values_array);

Just make sure you have that table in the db, and the key=> value pairs of the array match the columns

Link to comment
Share on other sites

13 hours ago, NemoPS said:

If you have that table in the database, yes. If not, you have to create it, prestashop doesn't do it manually. Also you don't need the prefix:


Db::getInstance()->insert("mymodulename", $values_array);

Just make sure you have that table in the db, and the key=> value pairs of the array match the columns

Okay. Can you tell me what would be the reason for this problem? 
Problem: I created a module and added some values through the module to the database. The database is phpMyAdmin and the server is local Wamp Server. Everything is working fine and the values are being added to the database. Now I uploaded the module to an online server and added values to them. The values are not being added to the database although everything else is the same (database is still phpMyAdmin). I don't know the reason why this is happening. It was working when I was using the local Wamp Server.

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
×
×
  • Create New...