4
比方說,我有一個bonified \Cake\ORM\Entity
對象 - $kablammo
我可以確認,並確保它有做相關的存儲庫中的以下內容:如何從cakephp 3中的實體對象獲取表模式/列?
use Cake\ORM\Entity;
// ..snip
if ($kablammo instanceOf Entity && !empty($kablammo->source())) {
$repository = $kablammo->source();
// ... what do I do here to get the table schema info/columns?
}
我希望能夠查看錶列本實體的關聯表基本上。什麼是最好的方法來做到這一點?我是否已經錯了?
我很笨。這很明顯。也許這會幫助別人。 – Kevin
對於任何需要它的表:使用Cake \ ORM \ TableRegistry; $ table = TableRegistry :: get('my_table_name'); $ table-> schema() - > columns(); – woodscreative