0

I am using click house with PHP CURL. curl query for select is working fine. But when do the insert it doesn't work. This is the query I am using for inserting.

http://localhost:8123/?query=INSERT%20INTO%20vas_services%20VALUES%20(, 0710715609, 'Ebill',1,'2020-02-25 00:01:01')

Can any one say is there any incorrect thing in above query or alternative solution for the problem?

u_mulder
  • 54,101
  • 5
  • 48
  • 64

1 Answers1

2

You shouldn't use GET for insert action. Consider using POST, then you can use body to pass the parameters. Also - never use whole query as argument of any kind.

You should have query like this:

INSERT INTO vas_services VALUES(:first_name...)

Using raw queries is very dangerous, as you could easily get SQL injection attacks. Also using raw parameters is not advised - always use functions that makes your SQL parameters validated and properly escaped e.g. you would use PDO functions e.g. bindParam.

After that you would call your action like described here.

PatNowak
  • 5,721
  • 1
  • 25
  • 31
  • 1
    `VALUES(:first_name -- ` it stops streaming parser and turn on slow memory-greedy parser. Dont do that for inserts. – Denny Crane Feb 25 '20 at 15:16