How do I get the table schema/columns from an entity object in cakephp 3?

Kevin

Let's say I have a bonified \Cake\ORM\Entity object -- $kablammo I can confirm and make sure it has an associated repository by doing the following:

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?
}

I'd like to be able to view the table columns for this Entity's associated table basically. What's the best way to do this? Am I going about it wrong already?

Kevin

I think I figured it out.

use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;

// ..snip

if ($kablammo instanceOf Entity && !empty($kablammo->source())) {
    $repository = $kablammo->source();
    $table = TableRegistry::get($repository);
    debug($table->schema());
}

At least I'm on the right track now.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I get first item from CakePHP 3 results object

From Dev

How do I get the first and last name of a person in a select box from an associated table in cakePHP 2.4?

From Dev

How can I get the className of my table in cakephp 3?

From Dev

In a cakephp 3 app, how do I build a query that finds all from a Table that does NOT contain it's associated table?

From Dev

Cakephp 3: Calling Table functions from Entity is a bad or good idea?

From Dev

How do i get multiple table rows from the JSON Object in to the Application

From Dev

How do I get the returned entity from a entitydatasource binding to a detailsview?

From Dev

CakePHP How to get Photo from different table?

From Dev

How to receive data from associated table in CakePHP 3.x as object(currently receiving as an array)

From Dev

How to receive data from associated table in CakePHP 3.x as object(currently receiving as an array)

From Dev

How I do do get session in model? CakePHP 3.x

From Dev

How do I use a PostgreSQL function that returns a table as a CakePHP 3 Model?

From Dev

How can i get assocation table colums name? cakephp 3.x

From Dev

cakephp 3 how to create new record from existing entity

From Dev

cakephp 3 how to create new record from existing entity

From Dev

How do I randomly select an object from a table in Lua?

From Dev

How do I randomly select an object from a table in Lua?

From Dev

C# Entity framework, how to get the primary key from an object created from a Junction table

From Dev

How do I get the node/entity from an instance of entity_metadata_wrapper in Drupal 7?

From Dev

CakePHP right way to do this (get value from setting's table)

From Dev

Entity name is different then the table name in Cakephp 3

From Dev

How do I get a Sqlite Table attribute from a Class?

From Dev

How do I get table and columns information from Redshift?

From Dev

How do I get SalesForce Table Names from SalesForce data

From Dev

How do I get all the rows from the table SQLite?

From Dev

How do I get id number from another table?

From Dev

How do I get data from another table in MySQL?

From Dev

How do I get all the rows from the table SQLite?

From Dev

how do i get values from multidimensionnal table in javascript?

Related Related

  1. 1

    How do I get first item from CakePHP 3 results object

  2. 2

    How do I get the first and last name of a person in a select box from an associated table in cakePHP 2.4?

  3. 3

    How can I get the className of my table in cakephp 3?

  4. 4

    In a cakephp 3 app, how do I build a query that finds all from a Table that does NOT contain it's associated table?

  5. 5

    Cakephp 3: Calling Table functions from Entity is a bad or good idea?

  6. 6

    How do i get multiple table rows from the JSON Object in to the Application

  7. 7

    How do I get the returned entity from a entitydatasource binding to a detailsview?

  8. 8

    CakePHP How to get Photo from different table?

  9. 9

    How to receive data from associated table in CakePHP 3.x as object(currently receiving as an array)

  10. 10

    How to receive data from associated table in CakePHP 3.x as object(currently receiving as an array)

  11. 11

    How I do do get session in model? CakePHP 3.x

  12. 12

    How do I use a PostgreSQL function that returns a table as a CakePHP 3 Model?

  13. 13

    How can i get assocation table colums name? cakephp 3.x

  14. 14

    cakephp 3 how to create new record from existing entity

  15. 15

    cakephp 3 how to create new record from existing entity

  16. 16

    How do I randomly select an object from a table in Lua?

  17. 17

    How do I randomly select an object from a table in Lua?

  18. 18

    C# Entity framework, how to get the primary key from an object created from a Junction table

  19. 19

    How do I get the node/entity from an instance of entity_metadata_wrapper in Drupal 7?

  20. 20

    CakePHP right way to do this (get value from setting's table)

  21. 21

    Entity name is different then the table name in Cakephp 3

  22. 22

    How do I get a Sqlite Table attribute from a Class?

  23. 23

    How do I get table and columns information from Redshift?

  24. 24

    How do I get SalesForce Table Names from SalesForce data

  25. 25

    How do I get all the rows from the table SQLite?

  26. 26

    How do I get id number from another table?

  27. 27

    How do I get data from another table in MySQL?

  28. 28

    How do I get all the rows from the table SQLite?

  29. 29

    how do i get values from multidimensionnal table in javascript?

HotTag

Archive