Re: Retrieve schema of model

2009-10-22 Thread emmexx



On 22 Ott, 12:28, emmexx  wrote:
> On 22 Ott, 12:04, Jon Bennett  wrote:

> > The easiest way would be to use ClassRegistry::init('ModelName')->_schema;

For the record:

This works with php5:
ClassRegistry::init('ModelName')->_schema;

With php4 use:
$obj = ClassRegistry::init('ModelName');
$fields = $obj->_schema;

bye
   maxx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Retrieve schema of model

2009-10-22 Thread emmexx



On 22 Ott, 12:04, Jon Bennett  wrote:

> The easiest way would be to use ClassRegistry::init('ModelName')->_schema;
>
> hth

It did help!
Thank you.

I had tried that but my code was messed up and it hadn't worked.

   maxx


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Retrieve schema of model

2009-10-22 Thread Jon Bennett

Hi Maxx,

> I tried with
> loadModel($selectedModel);
> $this->$selectedModel->_schema
> but this syntax is wrong in php (and I don't know php classes well).
> I can't use php 5 syntax.

The easiest way would be to use ClassRegistry::init('ModelName')->_schema;

hth

jon


-- 
jon bennett - www.jben.net - blog.jben.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Retrieve schema of model

2009-10-22 Thread emmexx

I need to retrieve the schema of the fields associated with a model.
I know there's the _schema property but I don't know how to access it.
The problem is I need the schema inside the controller and I want a
list of the fields of any of the models.

I'm creating a page where the user can select one of the models  and,
using ajax, another select box gets filled with the fields of that
model.

I used Configure::listObjects('model') to get the list of the models
but I don't know what to do now.

I tried with
loadModel($selectedModel);
$this->$selectedModel->_schema
but this syntax is wrong in php (and I don't know php classes well).
I can't use php 5 syntax.

Thank you for any suggestion.

maxx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---