Welcome Guest, Not a member yet? Register   Sign In
how can codeigniter create a db schema from a model is there a plugin
#1

[eluser]Sally D[/eluser]
like I would like a database plug in that I can instantiate into a model so that it creates the sql table or tables with all the correct data types set for me, so I really would not have to use php my admin at all or even know sql to make a database. The plug in will create the db on the way I am using my data in my model.

All I would have to do is make a model and then this plug in will build my database schema based on the model so I don't have write any sql at all is that plausible


like in my models constructor I would say:

$this->load->library('db_schema','schema_set_up');

then I would have a private function that would specifiy data type and sets like this
function _schema_set_up() {
$this->db_schema->CharField('feild_name',max_length=200);
$this->db_schema->IntegerField('feild_name');

}

then at the start of a new project I can call the db_schema class to build a database from the private function that I would declare in my model
#2

[eluser]Colin Williams[/eluser]
[quote author="Raymond M" date="1216881303"]All I would have to do is make a model and then this plug in will build my database schema based on the model so I don't have write any sql at all is that plausible[/quote]

First of all, sorry, but there is no standard for defining schemas in CodeIgniter Models, so you would first need to establish one, and only then can a library be written that reads this schema and produces the proper SQL. Rails does this, as does Django, Symfony, and maybe Cake, too, but not CodeIgniter.

Second, if your only motivation is to get by with learning the least amount of tools possible, you're probably in the wrong profession. And sorry again, but an ORM-system is still not going to keep you from getting dirty with SQL. You're going to need to construct a complex, unique query eventually.

Learning SQL will take you further than having a library like you describe above.
#3

[eluser]Sally D[/eluser]
I am sorry colin but can not help but sense your smugness and I dis agree with you what if they told that to Edison hey we don't need light bulbs we can just use candles just fine instead then we would still would be in the dark.

And I don't make a living doing this. This is my hobby.
#4

[eluser]Colin Williams[/eluser]
Didn't want to come across as smug, just realistic. And I understand that it's just a hobby for you. I started the same way. I'm not sure your Edison allusion is an apt metaphor, because I don't think he developed a framework for candle light, he developed a new form of illumination entirely. You weren't talking about inventing a new candle, you just don't care to learn how to light one.

But the crux of my reply stands that there is no standard way of defining schemas in CI Models. And there's no library to interpret any schema. Perfect opportunity for someone to introduce one. I would consider it, but I'm just fine with CI's ActiveRecord and the occasional SQL command.

EDIT:

Then again, search the Wiki for Rapyd. I think it is a fairly solid ORM solution, if I remember correctly. Seemed to kind of stand alongside CI rather than incorporate with it, but I never actually used it, so no final word.
#5

[eluser]Sally D[/eluser]
well I am thinking of developing a method that returns return a schema array to a database utility builder class

function return_schema() {

return array('CharField'=>array('feild_name'=>'name of feild','length'=>'length of feild');

}

then I can list the attributes that I want in a multidimensional array and then I would return that array to a database constructor utility that will build and it will contruct the database for me with out using another app to build the db for me.

and then I can create a front end to keep track of my projects and apps that I create with for CI and delete them all on this front end CI project

Colin I understand your smugness now thanks does this all make sense or am I tripping
#6

[eluser]Randy Casburn[/eluser]
@raymond -- The short answer is "No - it doesn't exist in CI natively"

Randy
======================================
P.S - My perception of your rebuke of Colin:

You compared:

1) Your display of outwardly wanting to avoiding gaining knowledge (re-read your first post)

TO (your second post)

2) One of the World's greatest inventors, an American, who lived by the credo that knowledge was a gift that must be gathered up at every opportunity regardless of the lengths at which one must go to gain it.

I take great exception this comparison. Edison's famous quotes such as "10,000 attempts...not failures" are a testament to his will to try and experiment and try again.
=====================

What we have from you is a testament that you aren't willing to try to learn SQL, that you don't "want to know SQL", "so I don't have to write any sql". My perception is what it is and I doubt you change it.

====================

Colin was just being realistic.
#7

[eluser]Colin Williams[/eluser]
Sounds like you've got something cooking there. March on and good luck. Something dead simple, straight-forward, and that doesn't impact the normal flow of CI is the type of thing this community craves, so keep that in mind.
#8

[eluser]Randy Casburn[/eluser]
@raymond -- Before you go to all that trouble, have you actually looked at the DB_Forge class?

I mean, before you go and rewrite the whole thing. You might as well look at it.

http://ellislab.com/codeigniter/user-gui...forge.html

Randy

============

@Colin -- ( make a note: Randy is nice even when he doesn't like somebody :wow: )
#9

[eluser]Colin Williams[/eluser]
[quote author="Randy Casburn" date="1216896115"]@Colin -- ( make a note: Randy is nice even when he doesn't like somebody :wow: )[/quote]

What, am I not always nice? Maybe my wife actually has a point... And, just for the record, I like everyone here, whether they want to learn anything or not.
#10

[eluser]Randy Casburn[/eluser]
Geeze -- that came out wrong. That was all suppose to be SELF DEPRECATING. You know about me. I didn't me you at all man. I was being mean. Not you.

Forums stink.

Good night.




Theme © iAndrew 2016 - Forum software by © MyBB