| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php');
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* Create SQL for the current model.
|
|
|
15 |
*
|
|
|
16 |
* @package symfony
|
|
|
17 |
* @subpackage propel
|
|
|
18 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
19 |
* @version SVN: $Id: sfPropelBuildSqlTask.class.php 23922 2009-11-14 14:58:38Z fabien $
|
|
|
20 |
*/
|
|
|
21 |
class sfPropelBuildSqlTask extends sfPropelBaseTask
|
|
|
22 |
{
|
|
|
23 |
/**
|
|
|
24 |
* @see sfTask
|
|
|
25 |
*/
|
|
|
26 |
protected function configure()
|
|
|
27 |
{
|
|
|
28 |
$this->addOptions(array(
|
|
|
29 |
new sfCommandOption('phing-arg', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'Arbitrary phing argument'),
|
|
|
30 |
));
|
|
|
31 |
|
|
|
32 |
$this->namespace = 'propel';
|
|
|
33 |
$this->name = 'build-sql';
|
|
|
34 |
$this->briefDescription = 'Creates SQL for the current model';
|
|
|
35 |
|
|
|
36 |
$this->detailedDescription = <<<EOF
|
|
|
37 |
The [propel:build-sql|INFO] task creates SQL statements for table creation:
|
|
|
38 |
|
|
|
39 |
[./symfony propel:build-sql|INFO]
|
|
|
40 |
|
|
|
41 |
The generated SQL is optimized for the database configured in [config/propel.ini|COMMENT]:
|
|
|
42 |
|
|
|
43 |
[propel.database = mysql|INFO]
|
|
|
44 |
EOF;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* @see sfTask
|
|
|
49 |
*/
|
|
|
50 |
protected function execute($arguments = array(), $options = array())
|
|
|
51 |
{
|
|
|
52 |
$this->schemaToXML(self::DO_NOT_CHECK_SCHEMA, 'generated-');
|
|
|
53 |
$this->copyXmlSchemaFromPlugins('generated-');
|
|
|
54 |
$ret = $this->callPhing('sql', self::CHECK_SCHEMA);
|
|
|
55 |
$this->cleanup();
|
|
|
56 |
///// FIXME: must change the propel.ini based on databases.yml! as done in insert-sql
|
|
|
57 |
return !$ret;
|
|
|
58 |
}
|
|
|
59 |
}
|