Data loading is implemented, as mentioned on the sfDoctrine page. You
have to write the data loading in a php file. It's a file with no more
than ten lines of code. You may choose the environment, the
application, which fixture you want to load, etc. To load the data you
just write "php my_file.php". Here is an example of such a file:
<?php
define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..'));
define('SF_APP', 'main');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
sfContext::getInstance();
$data = new sfDoctrineData();
$data->setDeleteCurrentData(true);
$data-
>loadData(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures',
'test');
?>
Having a task just for that seems totally overkill so i won't write it
unless it's very easy to derive from an already existing propel task,
which is currently not the case.
As a side note, if "create_table" is set to on, all the populated
tables will be created on the fly. That is a nice replacement for the
"build-database" task.
== Olivier
On 19 mar, 02:01, Michael Hart <[EMAIL PROTECTED]> wrote:
> Aha, in that case, I believe a doctrine-load-data Pake task doesn't
> exist yet - although it looks like Joaquin Bravo has submitted a
> patch for this:
>
> http://trac.symfony-project.com/trac/ticket/1511
>
> On 19/03/2007, at 11:30 AM, Ant Cunningham wrote:
>
>
>
> > I got that part... it is mentioned in the docs... I mean a doctrine
> > counterpart to symfony propel-load-data to load actual data from a
> > fixture
> > not just the creation of the tables. Or is this included and just not
> > mentioned?
>
> > On 3/18/07 8:23 PM, "Michael Hart" <[EMAIL PROTECTED]>
> > wrote:
>
> >> Hi Ant,
>
> >> Tables are created automatically when the data class is accessed for
> >> the first time (I think this is mentioned at the end of the
> >> sfDoctrine documentation - this behaviour can be turned off too).
> >> Easiest way initially might be to create a scaffolding to see this.
>
> >> If you run in development mode, you can see the "CREATE TABLE"
> >> statements by clicking on the little database icon in the top right-
> >> hand corner of the page.
>
> >> Cheers,
>
> >> Michael
>
> >> On 19/03/2007, at 10:39 AM, Ant Cunningham wrote:
>
> >>> One more question... There doesn't appear to be a task for loading
> >>> data. Am
> >>> I missing something or is this functionality not yet incoporated?
>
> >>> Thanks
>
> >>> -ant
>
> >>> On 3/18/07 5:42 PM, "chtito" <[EMAIL PROTECTED]> wrote:
>
> >>>> I agree that it's not so clear. Here is the explanation. this code:
> >>>> myTableName:
> >>>> columns:
> >>>> myColumnName: {columnName: my_column_name, type: string(100)}
> >>>> means that you will write your (Doctrine) queries using the column
> >>>> name "myColumnName" although the real column name in the
> >>>> database is
> >>>> "my_column_name". Doctrine will translate myColumnName to
> >>>> my_column_name behind the scene, when it generates the SQL.
>
> >>>> This feature is particularly useful to come around one big doctrine
> >>>> limitation: it assumes that all tables have an "Id" primary key
> >>>> column. If your primary key has another name in the database, say
> >>>> "my_id" then you can declare your table like this:
> >>>> myTableName:
> >>>> columns:
> >>>> id: {columnName: my_id, ...}
>
> >>>> It's also useful for legacy databases where you have weird column
> >>>> names that you cannot change and still want to write meaningful
> >>>> queries.
>
> >>>> Lastly, feel free to ask for a trac account and improve the
> >>>> explanations on the sfDoctrine page. That would be greatly
> >>>> appreciated.
>
> >>>> == Olivier
>
> >>>> On 18 mar, 21:51, Ant Cunningham <[EMAIL PROTECTED]>
> >>>> wrote:
> >>>>> Im fairly new to SF in general and in fact ive just gotten used
> >>>>> to the
> >>>>> default model API with propel. Now though ive noticed that some
> >>>>> of the
> >>>>> features of Doctrine would make my life a lot easier. I thought
> >>>>> id give it a
> >>>>> try on a small project im working on. Anyhow, I sat down to write
> >>>>> my schema
> >>>>> for sfDoctrine and im quite confused by the example on the wiki.
> >>>>> If anyone
> >>>>> could shed some light on how mapping for the api works that
> >>>>> would be
> >>>>> awesome... I see things like:
>
> >>>>> myTableName:
> >>>>> columns:
> >>>>> myColumnName: {columnName: my_column_name, type: string(100)}
>
> >>>>> and things like:
>
> >>>>> myTableName:
> >>>>> columns:
> >>>>> my_column_name: string(100)
>
> >>>>> what is the significance of specifying columnName in the
> >>>>> attributes for a
> >>>>> column? Which one is used as the column name when accessing the
> >>>>> model? ie.
> >>>>> is it $myObject->get('myColumnName'); or $myObject->get
> >>>>> ('my_column_name');
> >>>>> and sfDoctrine::queryFrom('tableName')->where
> >>>>> ('TableName.myColumnName = ?',
> >>>>> $value)->execute();
> >>>>> or
> >>>>> sfDoctrine::queryFrom('tableName')->where
> >>>>> ('TableName.my_column_name = ?',
> >>>>> $value)->execute();
>
> >>>>> thanks!
>
> >>>>> -ant
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---