我在 javascript 中有一个数组,我想将它发布到 php 以存储到 oracle varchar2 中。我想知道如何在 php.ini 中获取这个数组。现在我总是有一个字符串 [object Object] 而不是 oracle 中的数组。我使用 JQuery $.post 将变量发送到 php,如下所示:
function savePolygons(){
$.get('oracle_deletePolygons.php');
for (var i = 0; i < createdShapes.length; i++){
var nom_zone = escape(document.getElementById('nom_zone_' + createdShapes[i].id).value);
var couleur = escape(createdShapes[i].fillColor);
var code_cs = escape('711');
var shapeid_export = escape(createdShapes[i].id);
var geometry = createdShapes[i].getPath();
alert(geometry)
var url1 = "oracle_savePolygons.php?nom_zone=" + nom_zone + "&couleur=" + couleur + "&code_cs=" + code_cs + "&shapeid_export=" + shapeid_export + "&geometry=" + geometry;
$.get(url1);
}
}
在 php 中:
<?php
require("oracle_dbinfo.php");
sleep(5);
$nom_zone =$_GET['nom_zone'];
$shapeid_export = $_GET['shapeid_export'];
$code_cs = $_GET['code_cs'];
$couleur = $_GET['couleur'];
$geometry = $_GET['geometry'];
$conn = oci_connect($username, $password, $database);
$query = oci_parse($conn, 'INSERT INTO test1 (nom_zone, shapeid, code_cs, couleur, geometry) VALUES (:nom_zone, :shapeid_export, :code_cs, :couleur, :geometry)');
oci_bind_by_name($query, ":nom_zone", $nom_zone);
oci_bind_by_name($query, ":shapeid_export", $shapeid_export);
oci_bind_by_name($query, ":code_cs", $code_cs);
oci_bind_by_name($query, ":couleur", $couleur);
oci_bind_by_name($query, ":geometry", $geometry);
oci_execute($query);
oci_commit($conn);
?>
var 几何是多边形每个顶点的坐标数组。