我从Flash Builder 4中创建的Flash应用程序中回来了一个数组。
我有一个服务设置,可以成功查询并从数据库中恢复数据,但是Update脚本正在生成未定义的属性错误。
我还在学习PHP和Flash Builder,并且不完全了解$ this->命令。
如果有人可以建议这个脚本出错的地方,它基本上只是由Flash Builder生成的,而不是我自己开发的东西,我会很感激吗?
如果有人可以解释$ this->对我来说太棒了?
我之前见过它们,但后来我看到脚本做了同样不使用它们的东西,所以这是一种旧的做事方式吗?
真的很感激任何人都可以提供的任何意见。
针对完整的PHP代码进行了更新。
生成错误。
[18-Jun-2010 13:01:37] PHP注意:第48行的C:\ wamp \ www \ Coradia-175105-debug \ services \ tbltrustservice.php中的未定义属性:stdClass :: $ inst_code
[18-Jun-2010 13:01:37] PHP注意:第48行的C:\ wamp \ www \ Coradia-175105-debug \ services \ tbltrustservice.php中的未定义属性:stdClass :: $ trust_name
[18-Jun-2010 13:01:38] PHP注意:第48行的C:\ wamp \ www \ Coradia-175105-debug \ services \ tbltrustservice.php中的未定义属性:stdClass :: $ trust_code
[18-Jun-2010 13:01:38] PHP注意:第48行的C:\ wamp \ www \ Coradia-175105-debug \ services \ tbltrustservice.php中的未定义属性:stdClass :: $ trust_key
<?php
//reroute errors to get rid of that annoying CHANNEL DISCONNECTED message.
ini_set('error_log', 'errorLog.txt');
ini_set('html_errors', '0');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
class tbltrustservice {
public $connection;
public function connect() {
$this->connection = mysqli_connect("ahoey-1:3306", "<Username Removed For StackOverflow>", "<Password Removed for StackOverflow>", "enabmodules") or die(mysqli_connect_error());
}
public function getAllItems($search) {
$this->connect();
if ($search=="") {
$sql = "SELECT * FROM tbltrust";
} else {
$sql = 'SELECT * FROM tbltrust WHERE trust_name LIKE \'%'.mysql_escape_string($search).'%\' OR trust_code LIKE \''.mysql_escape_string($search).'%\' OR inst_code LIKE \'%'.mysql_escape_string($search).'%\'';
}
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
}
public function updateItem($item) {
// TODO Auto-generated method stub
// Update an existing record in the database and return the item
// Sample code \'
$this->connect();
$sql = "UPDATE tbltrust SET inst_code = '$item->inst_code', trust_name = '$item->trust_name', trust_code = '$item->trust_code' WHERE trust_key = '$item->trust_key'";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE $this->tablename SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
}
*/
public function getItem($itemID) {
// TODO Auto-generated method stub
// Return a single record from the database and return the item
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "SELECT * FROM books where itemID=$itemID";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
public function createItem($item) {
// TODO Auto-generated method stub
// Insert a new record in the database using the parameter and return the item
// Sample code
/*
$this->connect();
$sql = "INSERT INTO books (title, au_first_name, au_last_name)
VALUES ('$item->title','$item->au_first_name','$item->au_last_name')";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$autoid= mysqli_insert_id($this->connection);
mysqli_close($this->connection);
return $autoid;
*/
}
/*
public function updateItem($item) {
$stmt = mysqli_prepare($this->connection, "UPDATE tbltrust SET trust_code=?, trust_name=?, inst_code=? WHERE trust_key=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssi', $item->trust_code, $item->trust_name, $item->inst_code, $item->trust_key);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
} */
public function deleteItem($itemID) {
// TODO Auto-generated method stub
// Delete a record in the database
// Sample code
/*
$this->connect();
$itemID = mysqli_real_escape_string($this->connection, $itemID);
$sql = "DELETE FROM books WHERE itemID = $itemID";
mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
mysqli_close($this->connection);
*/
}
public function count() {
// TODO Auto-generated method stub
// Return the number of items in your array of records
// Sample code
/*
$this->connect();
$sql = "SELECT * FROM books";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rec_count = mysqli_num_rows($result);
mysqli_free_result($result);
mysqli_close($this->connection);
return $rec_count;
*/
}
public function getItems_paged($startIndex, $numItems) {
// TODO Auto-generated method stub
// Return a page of records as an array from the database for this startIndex
// Sample code
/*
$this->connect();
$startIndex = mysqli_real_escape_string($this->connection, $startIndex);
$numItems = mysqli_real_escape_string($this->connection, $numItems);
$sql = "SELECT * FROM books LIMIT $startIndex, $numItems";
$result = mysqli_query($this->connection, $sql) or die('Query failed: ' . mysqli_error($this->connection));
$rows = array();
while ($row = mysqli_fetch_object($result)) {
$rows[] = $row;
}
mysqli_free_result($result);
mysqli_close($this->connection);
return $rows;
*/
}
}
?>
答案 0 :(得分:3)
哦,我的:)。
$这是你所在当前对象的“名称”。我相信你刚从一个较大的对象中复制了该函数,将它粘贴在一个随机的地方,它现在停止工作了,因为它丢失了本身的基本部分......
要使用该脚本,您需要完整的源代码。您最好尝试学习一些PHP基础知识,否则您将很难自己解决它们。