The data of each table in Table 1 is sorted in descending order. However, if the table in table 2 is updated, the corresponding data in Table 1 is sorted in descending order after TABLE 2 is updated. lilidavetom is arranged in this way. if Table 2 is updated, it is arranged in this way...
The data of each table in Table 1 is sorted in descending order. However, if the table in table 2 is updated, the corresponding data in Table 1 is sorted in descending order after TABLE 2 is updated.lili dave tomIf Table 2 is updatedtom lili dave,tomNo2001But the latest value is2007The result I want is this sorting, but how can this be achieved? How should I write the code in the controller?
$t1=M('table1');$res=$t1->order('time desc')->select();
Reply content:
The data of each table in Table 1 is sorted in descending order. However, if the table in table 2 is updated, the corresponding data in Table 1 is sorted in descending order after TABLE 2 is updated.lili dave tomIf Table 2 is updatedtom lili dave,tomNo2001But the latest value is2007The result I want is this sorting, but how can this be achieved? How should I write the code in the controller?
$t1=M('table1');$res=$t1->order('time desc')->select();
Join can be used for two table join queries.
$Model = M('table1');$Model->join('left join table2 ON table1.name = table2.name')->order('table2.time desc')->select();
TP has a table method and a join method that can be used for multi-table queries.