我有一个网络应用程序(在本地运行 - 在apache localhost中),我在其中添加新学生。然后,我使用数据库中的数据填充Quickbooks(在创建新学生之后)。我遇到的问题是学生表有自定义字段。我在Quickbooks中手动创建了这些字段,但是当我创建一个新学生时,这些自定义字段不会填充数据。没有错误,所以我无法确定什么是错的。任何帮助将不胜感激。
附图显示了我在Quickbooks中的自定义字段
以下是我用于将新学生请求从服务器添加到Quickbooks Desktop的代码段
将请求排队到Web连接器的代码
<?php
$host = "localhost";
$user = "root";
$password = "";
$dbname = "academy";
// Create connection
// $link = mysqli_connect($host, $user, $password, $dbname);
$dsn02 = 'mysql:host=' . $host . ';dbname=' . $dbname;
$handler = new PDO( $dsn02, $user, $password );
/**
* Require some configuration stuff
*/
require_once '../motionplus/app_web_connector/config.php';
$sql = "INSERT INTO students (firstname,level,registration_number)
VALUES(?, ?, ?);";
$sql .= "INSERT INTO bills_module (firstname,level,registration_number)
VALUES(?, ?, ?);";
$sql .= "INSERT INTO bills (firstname,level,registration_number)
VALUES(?, ?, ?)";
$pdo = $handler -> prepare($sql);
if ($pdo -> execute([
$_POST['firstname'],
$_POST['level'],
$_POST['registration_number'],
$_POST['firstname'],
$_POST['level'],
$_POST['registration_number'],
$_POST['firstname'],
$_POST['level'],
$_POST['registration_number']
])
) {
// Get the primary key of the new record
$id = $handler -> lastInsertId();
// Queue up the customer add
$Queue = new QuickBooks_WebConnector_Queue($dsn);
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $id);
echo "<center>New record created successfully</center>";
header("Location:fees_capture.php");
echo "<center><a href='fees_capture.php'>View Registered Students</a></center>";
} else {
echo "Some serious error happened. Run!";
}
将学生添加到quickbooks的代码
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Fetch student record from the database
$host = 'localhost';
$dbname = 'academy';
$user = 'root';
$secret = '';
$dsn01 = 'mysql:host=' . $host . ';dbname=' . $dbname;
$handler = new PDO( $dsn01, $user, $secret );
$pdo = $handler -> prepare("SELECT * FROM students WHERE id = ?");
$pdo -> execute([$ID]);
$record = $pdo -> fetch(5);
// Create and return a qbXML request
$qbxml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>' . $record -> firstname . '</Name>
<CompanyName>The Lilongwe Academy</CompanyName>
<FirstName>' . $record -> firstname . '</FirstName>
<LastName>' . $record -> lastname . '</LastName>
</CustomerAdd>
</CustomerAddRq>
<DataExtModRq>
<DataExtMod>
<OwnerID>0</OwnerID>
<DataExtName>Registration Number</DataExtName>
<ListDataExtType>Customer</ListDataExtType>
<ListObjRef>
<FullName>Kingsley Nyirenda</FullName>
</ListObjRef>
<DataExtValue>' . $record -> registration_number . '</DataExtValue>
</DataExtMod>
</DataExtModRq>
</QBXMLMsgsRq>
</QBXML>';
return $qbxml;
}
答案 0 :(得分:0)
Classs
的自定义字段,您的屏幕截图显示您DataExtName =班组长
$ sql =&#34; INSERT INTO学生(名字,级别,registration_number) VALUES(&#39; $ _ POST [姓名]&#39;&#39; $ _ POST [等级]&#39;&#39; $ _ POST [registration_number]&#39;);&#34 ;;
$ sql。=&#34; INSERT INTO bills_module(firstname,registration_number,level) VALUES(&#39; $ _ POST [姓名]&#39;&#39; $ _ POST [registration_number]&#39;&#39; $ _ POST [等级]&#39;);&#34 ;;
$ sql。=&#34; INSERT INTO bill(firstname,registration_number,level) VALUES(&#39; $ _ POST [姓名]&#39;&#39; $ _ POST [registration_number]&#39;&#39; $ _ POST [等级]&#39;)&#34 ;; < / p>