<?php
班级Gotoandlearn
{
公共函数__construct()
{
//mysql_connect("server", "username", "password");
//mysql_select_db("database");
}
/**
* Retrieves tutorial data
* @returns title, description, and url
*/
function getTutorials($myId)
{
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Name, Map FROM xxx WHERE Uid=$myId";
// $sql = "SELECT Uid, Name, Map FROM xxx";
$result = $conn->query($sql);
// Check connection
if ($result->num_rows > 0) {
return $result;
} else {
echo false;
}
$conn->close();
//return mysql_query("SELECT title, description, url FROM Tutorials");
}
}
&GT;
答案 0 :(得分:0)
使用Amfphp,您无法返回资源。最佳做法是使用PDO http://php.net/manual/en/book.pdo.php,它返回一个可以发回的对象或数组。
您可以在此处查看一些示例代码https://github.com/silexlabs/amfphp-2.0/blob/master/Examples/Php/ExampleServices/UserService.php