我需要在闪电JS控制器中获取sobject的API名称,在组件方面我们需要指定<?php
header( "Content-type: application/json" );
$sitename = "xxxxxxxxxxxxxxxx";
$hostname = "localhost";
$username = "xxxxxxxx";
$password = "xxxxxxxx";
$database = "xxxxxxxxx";
$tbl_name = "xxxxxxxx";
$error = array();
$json = file_get_contents('php://input');
$obj = json_decode($json, TRUE);
$id = intval($obj['id']);
$name = $obj[‘name’];
$email = $obj[‘email’];
$date = $obj['date'];
$query="INSERT INTO ".$tbl_name."(id, name, email, date) VALUES(".$id.", '".$name.
"', '".$email."', '".$date."')";
$connect = @mysqli_connect( $hostname , $username , $password , $database );
if( $connect )
{
@mysqli_query( $connect , "SET CHARACTER SET utf8;" );
@mysqli_query( $connect , $query );
if( @mysqli_affected_rows( $connect ) > 0 )
{
$error['error'] = "done";
}
else
{
@unlink( $location );
$error['error'] = "failure_inserting_database!";
}
}
else
{
@unlink( $location );
$error['error'] = "failure_connecting_database";
}
}
die ( json_encode( $error['error'] ) );
?>
,但是要在控制器中访问,可以请一些人说。
对于<aura:attribute name="sObjectName" type="String" />
,我们这样做,
recordId
答案 0 :(得分:0)
您需要在组件中实现 force:hasSObjectName ,如下所示
<aura:component implements="force:hasRecordId,force:hasSObjectName" access="global" >
然后在您的JS控制器中,您可以检索名称,如下所示
var name = component.get("v.sObjectName"); // gives you the sObject name
var name = component.get("v.recordId"); // gives you the id of the sObject