Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BOOTSTRAP.php
- <?php
- // bootstrap.php
- /**
- * Bootstrap Doctrine.php, register autoloader specify
- * configuration attributes and load models.
- */
- require_once(dirname(__FILE__) . '/lib/doctrine/Doctrine.php');
- spl_autoload_register(array('Doctrine', 'autoload'));
- $manager = Doctrine_Manager::getInstance();
- $dsn = 'mysql:dbname=webgame;host=127.0.0.1';
- $user = 'root';
- $password = '';
- $dbh = new PDO($dsn, $user, $password);
- $conn = Doctrine_Manager::connection($dbh);
- Doctrine_Core::loadModels('models');
- ?>
- BATTLE.php
- <?php
- require_once('bootstrap.php');
- echo Doctrine_Core::getPath();
- Doctrine_Core::loadModels('/Library/WebServer/Documents/Webgame/models');
- $starship = new Starship();
- $q = Doctrine_Query::create()
- ->from('Starship s')
- ->leftJoin ('s.fleet_id f')
- ->where ('s.starship_id=1');
- echo $q->getSqlQuery();
- ?>
- BASESTARSHIP.php
- <?php
- /**
- * BaseStarship
- *
- * This class has been auto-generated by the Doctrine ORM Framework
- *
- * @property integer $starship_id
- * @property string $name
- * @property integer $x
- * @property integer $y
- * @property integer $z
- * @property integer $exp
- * @property integer $fleet_id
- * @property Fleet $Fleet
- * @property Doctrine_Collection $Weapon
- *
- * @package ##PACKAGE##
- * @subpackage ##SUBPACKAGE##
- * @author ##NAME## <##EMAIL##>
- * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
- */
- abstract class BaseStarship extends Doctrine_Record
- {
- public function setTableDefinition()
- {
- $this->setTableName('starship');
- $this->hasColumn('starship_id', 'integer', 8, array(
- 'type' => 'integer',
- 'length' => 8,
- 'fixed' => false,
- 'unsigned' => true,
- 'primary' => true,
- 'autoincrement' => true,
- ));
- $this->hasColumn('name', 'string', 45, array(
- 'type' => 'string',
- 'length' => 45,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('x', 'integer', 4, array(
- 'type' => 'integer',
- 'length' => 4,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('y', 'integer', 4, array(
- 'type' => 'integer',
- 'length' => 4,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('z', 'integer', 4, array(
- 'type' => 'integer',
- 'length' => 4,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('exp', 'integer', 4, array(
- 'type' => 'integer',
- 'length' => 4,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('fleet_id', 'integer', 8, array(
- 'type' => 'integer',
- 'length' => 8,
- 'fixed' => false,
- 'unsigned' => true,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- }
- public function setUp()
- {
- parent::setUp();
- $this->hasOne('Fleet', array(
- 'local' => 'fleet_id',
- 'foreign' => 'fleet_id'));
- $this->hasMany('Weapon', array(
- 'local' => 'starship_id',
- 'foreign' => 'starship_id'));
- }
- }
- BASEFLEET.php
- <?php
- /**
- * BaseFleet
- *
- * This class has been auto-generated by the Doctrine ORM Framework
- *
- * @property integer $fleet_id
- * @property string $name
- * @property integer $user_id
- * @property Doctrine_Collection $Starship
- *
- * @package ##PACKAGE##
- * @subpackage ##SUBPACKAGE##
- * @author ##NAME## <##EMAIL##>
- * @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
- */
- abstract class BaseFleet extends Doctrine_Record
- {
- public function setTableDefinition()
- {
- $this->setTableName('fleet');
- $this->hasColumn('fleet_id', 'integer', 8, array(
- 'type' => 'integer',
- 'length' => 8,
- 'fixed' => false,
- 'unsigned' => true,
- 'primary' => true,
- 'autoincrement' => true,
- ));
- $this->hasColumn('name', 'string', 45, array(
- 'type' => 'string',
- 'length' => 45,
- 'fixed' => false,
- 'unsigned' => false,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- $this->hasColumn('user_id', 'integer', 8, array(
- 'type' => 'integer',
- 'length' => 8,
- 'fixed' => false,
- 'unsigned' => true,
- 'primary' => false,
- 'notnull' => false,
- 'autoincrement' => false,
- ));
- }
- public function setUp()
- {
- parent::setUp();
- $this->hasMany('Starship', array(
- 'local' => 'fleet_id',
- 'foreign' => 'fleet_id'));
- }
- }
- ERROR
- /Library/WebServer/Documents/Webgame/lib/doctrine
- Fatal error: Uncaught exception 'Doctrine_Table_Exception' with message 'Unknown relation alias fleet_id' in /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Relation/Parser.php:237 Stack trace: #0 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Relation/Parser.php(235): Doctrine_Relation_Parser->getRelation('fleet_id', false) #1 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Table.php(1001): Doctrine_Relation_Parser->getRelation('fleet_id', true) #2 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Query.php(1726): Doctrine_Table->getRelation('fleet_id') #3 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Query/From.php(88): Doctrine_Query->load('s.fleet_id f') #4 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Query/Abstract.php(2077): Doctrine_Query_From->parse('LEFT JOIN s.fle...') #5 /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Query.php(1156): Doctrine_Query_Abstract->_processDqlQueryPart('from', Array) #6 /Library/WebServer/Documents/Webga in /Library/WebServer/Documents/Webgame/lib/doctrine/Doctrine/Relation/Parser.php on line 237
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement