Advertisement
Guest User

Untitled

a guest
May 11th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.81 KB | None | 0 0
  1. BOOTSTRAP.php
  2.  
  3. <?php
  4.  
  5. // bootstrap.php
  6.  
  7. /**
  8.  * Bootstrap Doctrine.php, register autoloader specify
  9.  * configuration attributes and load models.
  10.  */
  11.  
  12. require_once(dirname(__FILE__) . '/lib/doctrine/Doctrine.php');
  13. spl_autoload_register(array('Doctrine', 'autoload'));
  14. $manager = Doctrine_Manager::getInstance();
  15.  
  16. $dsn = 'mysql:dbname=webgame;host=127.0.0.1';
  17. $user = 'root';
  18. $password = '';
  19.  
  20. $dbh = new PDO($dsn, $user, $password);
  21. $conn = Doctrine_Manager::connection($dbh);
  22. Doctrine_Core::loadModels('models');
  23.  
  24. ?>
  25.  
  26.  
  27.  
  28.  
  29. BATTLE.php
  30.  
  31. <?php
  32. require_once('bootstrap.php');
  33.  
  34.  
  35. echo Doctrine_Core::getPath();
  36. Doctrine_Core::loadModels('/Library/WebServer/Documents/Webgame/models');
  37.  
  38. $starship = new Starship();
  39.  
  40. $q = Doctrine_Query::create()
  41.     ->from('Starship s')
  42.     ->leftJoin ('s.fleet_id f')
  43.     ->where ('s.starship_id=1');
  44.  
  45. echo $q->getSqlQuery();
  46. ?>
  47.  
  48. BASESTARSHIP.php
  49.  
  50. <?php
  51.  
  52. /**
  53.  * BaseStarship
  54.  *
  55.  * This class has been auto-generated by the Doctrine ORM Framework
  56.  *
  57.  * @property integer $starship_id
  58.  * @property string $name
  59.  * @property integer $x
  60.  * @property integer $y
  61.  * @property integer $z
  62.  * @property integer $exp
  63.  * @property integer $fleet_id
  64.  * @property Fleet $Fleet
  65.  * @property Doctrine_Collection $Weapon
  66.  *
  67.  * @package    ##PACKAGE##
  68.  * @subpackage ##SUBPACKAGE##
  69.  * @author     ##NAME## <##EMAIL##>
  70.  * @version    SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
  71.  */
  72. abstract class BaseStarship extends Doctrine_Record
  73. {
  74.     public function setTableDefinition()
  75.     {
  76.         $this->setTableName('starship');
  77.         $this->hasColumn('starship_id', 'integer', 8, array(
  78.              'type' => 'integer',
  79.              'length' => 8,
  80.              'fixed' => false,
  81.              'unsigned' => true,
  82.              'primary' => true,
  83.              'autoincrement' => true,
  84.              ));
  85.         $this->hasColumn('name', 'string', 45, array(
  86.              'type' => 'string',
  87.              'length' => 45,
  88.              'fixed' => false,
  89.              'unsigned' => false,
  90.              'primary' => false,
  91.              'notnull' => false,
  92.              'autoincrement' => false,
  93.              ));
  94.         $this->hasColumn('x', 'integer', 4, array(
  95.              'type' => 'integer',
  96.              'length' => 4,
  97.              'fixed' => false,
  98.              'unsigned' => false,
  99.              'primary' => false,
  100.              'notnull' => false,
  101.              'autoincrement' => false,
  102.              ));
  103.         $this->hasColumn('y', 'integer', 4, array(
  104.              'type' => 'integer',
  105.              'length' => 4,
  106.              'fixed' => false,
  107.              'unsigned' => false,
  108.              'primary' => false,
  109.              'notnull' => false,
  110.              'autoincrement' => false,
  111.              ));
  112.         $this->hasColumn('z', 'integer', 4, array(
  113.              'type' => 'integer',
  114.              'length' => 4,
  115.              'fixed' => false,
  116.              'unsigned' => false,
  117.              'primary' => false,
  118.              'notnull' => false,
  119.              'autoincrement' => false,
  120.              ));
  121.         $this->hasColumn('exp', 'integer', 4, array(
  122.              'type' => 'integer',
  123.              'length' => 4,
  124.              'fixed' => false,
  125.              'unsigned' => false,
  126.              'primary' => false,
  127.              'notnull' => false,
  128.              'autoincrement' => false,
  129.              ));
  130.         $this->hasColumn('fleet_id', 'integer', 8, array(
  131.              'type' => 'integer',
  132.              'length' => 8,
  133.              'fixed' => false,
  134.              'unsigned' => true,
  135.              'primary' => false,
  136.              'notnull' => false,
  137.              'autoincrement' => false,
  138.              ));
  139.     }
  140.  
  141.     public function setUp()
  142.     {
  143.         parent::setUp();
  144.         $this->hasOne('Fleet', array(
  145.              'local' => 'fleet_id',
  146.              'foreign' => 'fleet_id'));
  147.  
  148.         $this->hasMany('Weapon', array(
  149.              'local' => 'starship_id',
  150.              'foreign' => 'starship_id'));
  151.     }
  152. }
  153.  
  154. BASEFLEET.php
  155.  
  156. <?php
  157.  
  158. /**
  159.  * BaseFleet
  160.  *
  161.  * This class has been auto-generated by the Doctrine ORM Framework
  162.  *
  163.  * @property integer $fleet_id
  164.  * @property string $name
  165.  * @property integer $user_id
  166.  * @property Doctrine_Collection $Starship
  167.  *
  168.  * @package    ##PACKAGE##
  169.  * @subpackage ##SUBPACKAGE##
  170.  * @author     ##NAME## <##EMAIL##>
  171.  * @version    SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
  172.  */
  173. abstract class BaseFleet extends Doctrine_Record
  174. {
  175.     public function setTableDefinition()
  176.     {
  177.         $this->setTableName('fleet');
  178.         $this->hasColumn('fleet_id', 'integer', 8, array(
  179.              'type' => 'integer',
  180.              'length' => 8,
  181.              'fixed' => false,
  182.              'unsigned' => true,
  183.              'primary' => true,
  184.              'autoincrement' => true,
  185.              ));
  186.         $this->hasColumn('name', 'string', 45, array(
  187.              'type' => 'string',
  188.              'length' => 45,
  189.              'fixed' => false,
  190.              'unsigned' => false,
  191.              'primary' => false,
  192.              'notnull' => false,
  193.              'autoincrement' => false,
  194.              ));
  195.         $this->hasColumn('user_id', 'integer', 8, array(
  196.              'type' => 'integer',
  197.              'length' => 8,
  198.              'fixed' => false,
  199.              'unsigned' => true,
  200.              'primary' => false,
  201.              'notnull' => false,
  202.              'autoincrement' => false,
  203.              ));
  204.     }
  205.  
  206.     public function setUp()
  207.     {
  208.         parent::setUp();
  209.         $this->hasMany('Starship', array(
  210.              'local' => 'fleet_id',
  211.              'foreign' => 'fleet_id'));
  212.     }
  213. }
  214.  
  215.  
  216.  
  217. ERROR
  218.  
  219. /Library/WebServer/Documents/Webgame/lib/doctrine
  220. 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