我搜索了很多页面的Google搜索结果以及此处的stackoverflow,但找不到适合我情况的解决方案.我似乎只在我试图构建的函数中有一个最后的障碍,它使用call_user_func_array来动态创建对象.
我得到的可捕获的致命错误是Object of class Product could not be converted to string.当错误发生时,在日志中我得到其中五个(每个参数一个):PHP Warning: Missing argument 1 for Product::__construct(),在可捕获的致命错误之前.
这是函数的代码:
public static function SelectAll($class, $table, $sort_field, $sort_order = "ASC")
{
/* First, the function performs a MySQL query using the provided arguments. */
$query = "SELECT * FROM " .$table. " ORDER BY " .$sort_field. " " .$sort_order;
$result = mysql_query($query);
/* Next, the function dynamically gathers the appropriate number and names of properties. */
$num_fields = mysql_num_fields($result); …Run Code Online (Sandbox Code Playgroud) 我只是附上一张图片作为参考.我很难过.在调试器中,值肯定彼此相等,但Find<T>仍然返回null并Exists<T>仍然返回false.供参考:UserRepository实现IEnumerable<T>,其中T是DomainUser.

鉴于以下脚本:
DECLARE @table1 TABLE (t1num int NOT NULL);
DECLARE @table2 TABLE (t2num int NOT NULL);
DECLARE @table3 TABLE (t3num int NOT NULL);
INSERT INTO @table1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO @table2 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
INSERT INTO @table3 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
SELECT
t2num,
(
SELECT t1num AS [t1.num]
FROM @table1
FOR JSON PATH
) AS t1s
FROM …Run Code Online (Sandbox Code Playgroud)