Re: Cake 2 : Any sort of automatic schema creation from models?
On Jan 29, 6:01 am, maxarbos maxar...@yahoo.com wrote: I was responding to the the post from Ryan about 'bake' doing what I was asking for. When I 'run' a project in grails, that is when the table construction from a model is done, so i thought there was more to 'bake' than I had originally thought. I did go through the blog tutorial as well as the docs on how to create a model. And from what I remember, in both places I had to create the db table myself. omg the manual labor. So where in the blog tutorial did it ask you to define in the model the fields for the db table you'd just created? Where is the suggestion that what you're asking for, edit properties in a model, and the db schema alters to suit, is conceptually compatible with cake? You give the docs too much credit to think that in 15 minutes I am supposed to understand why I have to create the db table: 'posts' by hand (http://book.cakephp.org/view/1530/Creating-the-Blog-Database) and then little bit later have to create a model 'Post' with only a property of 'name' that = 'Post' with no other methods. And even then, the reason for that '$name' property isnt exactly clear as to why it's needed: 'The $name variable is always a good idea to add, and is used to overcome some class name oddness in PHP4.' I can understand the logic that the model is an interface to that table, but I dont remember seeing that outlined anywhere. So back to my original questions and just to be clear what you are saying is that the only way a table and it's rows are created are by manually creating them in the db myself, right? That wasn't your original question - and the answer to that question is also no. I understand your original post as a whole to be summarized by: I don't want to have to edit the db AND my php files - I want them to be in sync - how do I do that? and the answer to that paraphrased question is: you. just. edit. the. db. Let's try and cover all bases: * You're being boneheadedly stuborn ;) Cake doesn't work like that. Like that no worky cake. Work like that not: cake. * Cake bases the schema of your models of the schema of the db it's using, not the otherway around and it does this automatically. * If you think the docs are wrong - edit them. * WRT your question, bake generates view files which will reflect the db schema at the time it is run. * The book isn't intended to duplicate all the info that's in the api - another source of info which I'd recommend looking at. * There are other means of editing your db schema - such as the migrations. They aren't in the core and won't ever be afaik ht answers a few things. AD -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
I read through the very minimal bake command documentation at: 9.1 and 9.2 in the docs, but it's pretty superficial. The generation of the schema is a pretty big deal i think and something that should be highlighted a little more, if this is what it can do. When I started with cake 1.3 a few months ago, I didnt see anything that outlined this function. Going through some of the tutorials were pretty lacking as well. If there is someplace that has better information on this process, please let me know and I would love to review it. Thanks. On Jan 27, 1:38 am, Ryan Schmidt google-2...@ryandesign.com wrote: On Jan 26, 2011, at 00:48, maxarbos wrote: So would the model be automatically be built with the correct properties and types by telling it which table to read from? That's what cake bake is all about, isn't it? Have you tried it? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
On Jan 28, 5:04 pm, maxarbos maxar...@yahoo.com wrote: I read through the very minimal bake command documentation at: 9.1 and 9.2 in the docs, but it's pretty superficial. The generation of the schema is a pretty big deal i think and something that should be highlighted a little more, if this is what it can do. When I started with cake 1.3 a few months ago, bake has very little to do with your question In cake you edit your db tables however you want and create a model file to represent your php interface to that table. Creating model files is actually optional since cake will use an app model instance for any referenced model which doesn't have a specific file. Therefore if you add a table to your db foos and add this to your e.g. user model: var hasMany = array('Foo'); you can immediately do $this-Foo-find() in/from your user model. The blog tutorial should have cemented this for you in the first 15 minute of using cake - if that wasn't the case for you I'd suggest you edit the bit that didn't clarify that's how cake works. AD -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
I was responding to the the post from Ryan about 'bake' doing what I was asking for. When I 'run' a project in grails, that is when the table construction from a model is done, so i thought there was more to 'bake' than I had originally thought. I did go through the blog tutorial as well as the docs on how to create a model. And from what I remember, in both places I had to create the db table myself. You give the docs too much credit to think that in 15 minutes I am supposed to understand why I have to create the db table: 'posts' by hand (http://book.cakephp.org/view/1530/Creating-the-Blog-Database) and then little bit later have to create a model 'Post' with only a property of 'name' that = 'Post' with no other methods. And even then, the reason for that '$name' property isnt exactly clear as to why it's needed: 'The $name variable is always a good idea to add, and is used to overcome some class name oddness in PHP4.' I can understand the logic that the model is an interface to that table, but I dont remember seeing that outlined anywhere. So back to my original questions and just to be clear what you are saying is that the only way a table and it's rows are created are by manually creating them in the db myself, right? On Jan 28, 2:44 pm, AD7six andydawso...@gmail.com wrote: On Jan 28, 5:04 pm, maxarbos maxar...@yahoo.com wrote: I read through the very minimal bake command documentation at: 9.1 and 9.2 in the docs, but it's pretty superficial. The generation of the schema is a pretty big deal i think and something that should be highlighted a little more, if this is what it can do. When I started with cake 1.3 a few months ago, bake has very little to do with your question In cake you edit your db tables however you want and create a model file to represent your php interface to that table. Creating model files is actually optional since cake will use an app model instance for any referenced model which doesn't have a specific file. Therefore if you add a table to your db foos and add this to your e.g. user model: var hasMany = array('Foo'); you can immediately do $this-Foo-find() in/from your user model. The blog tutorial should have cemented this for you in the first 15 minute of using cake - if that wasn't the case for you I'd suggest you edit the bit that didn't clarify that's how cake works. AD -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
On Jan 28, 2011, at 23:01, maxarbos wrote: On Jan 28, 2:44 pm, AD7six andydawso...@gmail.com wrote: On Jan 28, 5:04 pm, maxarbos maxar...@yahoo.com wrote: I read through the very minimal bake command documentation at: 9.1 and 9.2 in the docs, but it's pretty superficial. The generation of the schema is a pretty big deal i think and something that should be highlighted a little more, if this is what it can do. When I started with cake 1.3 a few months ago, bake has very little to do with your question I was responding to the the post from Ryan about 'bake' doing what I was asking for. When I 'run' a project in grails, that is when the table construction from a model is done, so i thought there was more to 'bake' than I had originally thought. You create the database tables manually in the database. Then you use cake bake to create the model PHP file for you. Correct, the model PHP file might not contain a lot of lines of code; the default methods from the Model class are often sufficient for the basics. You can then add methods to your models as needed for specific functionality. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
On Jan 26, 2011, at 00:48, maxarbos wrote: So would the model be automatically be built with the correct properties and types by telling it which table to read from? That's what cake bake is all about, isn't it? Have you tried it? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Cake 2 : Any sort of automatic schema creation from models?
Hello, Will cake2 have any sort of automatic table schema creation and management? I have been using grails for a bit and it has an orm built in that creates and manages table schemas. So to create a table for people i create a class: People and add properties for firstName, lastName, etc... and if there is no 'People' table, one is created with the fields: 'first_name', 'last_name'. if i remove any property, that column is dropped. I would prefer to not have to manage the tables and FK relationships independantly of the application. (grails gives you the ability to set specific field types, sizes, etc..but defaults to certain types/sizes for 'Integer', 'String', etc...) I see a package RedBeanPHP, but cannot get it working (due to my knowledge limit on it) with the other LIght framework I am testing out. Thanks. Cake 2 : Any sort of automatic schema creation from models? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
No. Cake has always taken the approach of basing the models off the schema, not the other way around. This is not planned to change for 2.0. -Mark On Jan 25, 2:56 pm, maxarbos maxar...@yahoo.com wrote: Hello, Will cake2 have any sort of automatic table schema creation and management? I have been using grails for a bit and it has an orm built in that creates and manages table schemas. So to create a table for people i create a class: People and add properties for firstName, lastName, etc... and if there is no 'People' table, one is created with the fields: 'first_name', 'last_name'. if i remove any property, that column is dropped. I would prefer to not have to manage the tables and FK relationships independantly of the application. (grails gives you the ability to set specific field types, sizes, etc..but defaults to certain types/sizes for 'Integer', 'String', etc...) I see a package RedBeanPHP, but cannot get it working (due to my knowledge limit on it) with the other LIght framework I am testing out. Thanks. Cake 2 : Any sort of automatic schema creation from models? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Cake 2 : Any sort of automatic schema creation from models?
So would the model be automatically be built with the correct properties and types by telling it which table to read from? If I just have to setup the tables, that would work too, but what I dont want is to have to maintain a model as well as a table structure independently. On Jan 25, 7:02 pm, mark_story mark.st...@gmail.com wrote: No. Cake has always taken the approach of basing the models off the schema, not the other way around. This is not planned to change for 2.0. -Mark On Jan 25, 2:56 pm, maxarbos maxar...@yahoo.com wrote: Hello, Will cake2 have any sort of automatic table schema creation and management? I have been using grails for a bit and it has an orm built in that creates and manages table schemas. So to create a table for people i create a class: People and add properties for firstName, lastName, etc... and if there is no 'People' table, one is created with the fields: 'first_name', 'last_name'. if i remove any property, that column is dropped. I would prefer to not have to manage the tables and FK relationships independantly of the application. (grails gives you the ability to set specific field types, sizes, etc..but defaults to certain types/sizes for 'Integer', 'String', etc...) I see a package RedBeanPHP, but cannot get it working (due to my knowledge limit on it) with the other LIght framework I am testing out. Thanks. Cake 2 : Any sort of automatic schema creation from models? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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