What does each of the keys in $ _schema var do in models in CakePHP?

CakePHP cookbook introduces the following ( http://book.cakephp.org/2.0/en/models/model-attributes.html#schema ):

Contains metadata describing the fields of the model database table. Each field is described by:

  • name
  • type (integer, string, datetime, etc.)
  • Null
  • default value
  • Length

Some of them require no explanation, but here are my questions:

  • Title - What is the purpose of this? Is the cakebook simply fuzzy saying that the other values ​​will be in an array stored under the field name, or is it a key that can give a different name and what will it be for?
  • Type - I understand what type, but can anyone give me a complete list of parameters? It’s hard to say what it is if I don’t know what options I have. Are they based on typical database types or form types, or what?
  • Is null the same as a null database variant? Basically, just need a value or an error?

I would like to write each of my table schemas for various reasons, but I am a bit stuck due to these issues.

Thank you for your help!

+3
source share
1 answer

You can find most of the answers to your questions yourself. either you debug the returned data from

$this->Model->schema();

which contains all the fields above. Or you use the cake wrapper to create / upload a schema file in / Config / Schema:

cake schema generate

this way you can see what the cake creates.

, "foobars" , , . , , . : "default not null", - "default null", , "null". .

, - . .

0

All Articles