简体   繁体   English

AMFPHP 2.2 backoffice调用很简单,但是调用amf返回null?

[英]AMFPHP 2.2 backoffice call simple works but call amf returns null?

in back office when calling simple everything is fine all i have to do is fill in the appropriate field with a UID(userid) but when i use call AMF it returns null 在后台,当调用简单时,一切都很好,我所要做的就是用UID(userid)填写适当的字段,但是当我使用调用AMF时,它返回null

<?php

class Gotoandlearn { Gotoandlearn类{
public function __construct() { 公共功能__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");
    }
}

?> ?>

With Amfphp you can't return a resource. 使用Amfphp,您无法返回资源。 Best practice is to use PDO http://php.net/manual/en/book.pdo.php which returns an object or an array that be can be sent back. 最佳做法是使用PDO http://php.net/manual/en/book.pdo.php ,它会返回可以发送回的对象或数组。

You can see some sample code here https://github.com/silexlabs/amfphp-2.0/blob/master/Examples/Php/ExampleServices/UserService.php 您可以在这里查看一些示例代码https://github.com/silexlabs/amfphp-2.0/blob/master/Examples/Php/ExampleServices/UserService.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM