PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 17, 2022

[FIXED] cakephp get schema for list of tables

 March 17, 2022     cakephp     No comments   

Issue

Is there an easy way in cakephp to get an array of tables schema for a list of specific tables? For example, i want a table schema for table a, b, d, f, and z; Also, is there a way to get a schema array of all the tables?


Solution

Get a datasource, by:

$db =& ConnectionManager::getDataSource('default');

or

$db =& $this->User->getDataSource(); // or any other model 

Then you can get all the tables by calling:

$db->listSources()

And get the schema for a table, say "products"

$db->describe('products');

However, passing a string to describe is only in CakePHP 2.0, 1.3 requires a model object.



Answered By - ori
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing