Home > Mobile >  WeChat small program how to access the database implementation to fix and delete?
WeChat small program how to access the database implementation to fix and delete?

Time:09-22

I made a server, Wex5 when installed, installation of SQL server08, I do WeChat small program can now be read to the SQL server database, but won't write data to the SQL server, a great god, please help, thank you, urgent! Be urgent! Be urgent!

CodePudding user response:

OnLoad: function (options) {
var that=this;
Wx. Request ({
Url: 'https://mascgh.zicp.vip/baas/mydatas/api_news/queryNews',
Data: {
X: "'
Y: "'
},
Header: {
'the content-type:' application/json//the default
},
Success (res) {
The console. The log (res) data) rows);
That the setData ({
The items: res. Data. Rows
});
}
})
},
I read this database, but I don't know how to write data to the database,

CodePudding user response:

Small program by the need to write the request data sent to the back-end, write generally is handled by the backend logic, such as Java PHP python...

CodePudding user response:

Will read the data, that is, will the SQL, incredibly not insert data, also is magic!

CodePudding user response:

Read the code is also learning others', I turned out to be the Delphi programming, but the Web is not really, there should be no understand, I'm sorry!
I hope warrior help!

CodePudding user response:

Backend server process: WeChat small program request data sent parameters such as the x: you y: 1, 2 to the server url address, and then use the back-end PHP, JAVA, PYTHON, etc. To receive to connect to the database, such as PHP, connect to the database first
$hostname="localhost: 3306";
$username="root";
$password="";
$dbname="";
$conn=new mysqli ($hostname, $username, $password, $dbname); ,
$x=$_GET [' x ']. $y=$_GET [' y '];//receive the x, y, and
$SQL="select * from XXX where x=". $x, "and y=". $y;
$result=$conn - & gt; The query ($sql1);//database processing
If ($result) {
Echo json_encode ($result);//output back to the WeChat small program success (res) res in the console. The log (res); Print can see the data back to the
}
Just for an example of a query, you want to add authorization is changed $SQL statements to do database processing good
Multiple data the database result sets $result put cycle into array echo again print back WeChat applet
Logic is so similar, I also just learn some of the new

CodePudding user response:

$result=$conn - & gt; Above the $SQL query () write a 1

CodePudding user response:

Small program JavaScript support
Operating limits
Based on security considerations, the small program does not support the dynamic execution of JS code, namely:

Don't support the use of eval JS code execution
Does not support the use of new Function to create Function

So the above code have $conn= new mysqli ($hostname, $username, $password, $dbname); And it can no longer be run normally,
  • Related