-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using separate directory for relation tests
- Loading branch information
phalcon
committed
Jul 6, 2013
1 parent
b8c343e
commit cab7c46
Showing
15 changed files
with
394 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* Deles | ||
* | ||
* Deles is "parts" in danish | ||
*/ | ||
class Deles extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'parts'; | ||
} | ||
|
||
public function columnMap() | ||
{ | ||
return array( | ||
'id' => 'code', | ||
'name' => 'theName', | ||
); | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('code', 'RobottersDeles', 'delesCode', array( | ||
'foreignKey' => array( | ||
'message' => 'Deles cannot be deleted because is referenced by a Robotter' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
class Parts extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('id', 'RobotsParts', 'parts_id', array( | ||
'foreignKey' => array( | ||
'message' => 'Parts cannot be deleted because is referenced by a Robot' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
class Robots extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('id', 'RobotsParts', 'robots_id', array( | ||
'foreignKey' => true | ||
)); | ||
$this->hasManyToMany('id', 'RobotsParts', 'robots_id', 'parts_id', 'Parts', 'id'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
class RobotsParts extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function initialize() | ||
{ | ||
$this->belongsTo('parts_id', 'Parts', 'id', array( | ||
'foreignKey' => true | ||
)); | ||
$this->belongsTo('robots_id', 'Robots', 'id', array( | ||
'foreignKey' => array( | ||
'message' => 'The robot code does not exist' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/** | ||
* Robotters | ||
* | ||
* "robotters" is robots in danish | ||
*/ | ||
class Robotters extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'robots'; | ||
} | ||
|
||
public function columnMap() | ||
{ | ||
return array( | ||
'id' => 'code', | ||
'name' => 'theName', | ||
'type' => 'theType', | ||
'year' => 'theYear' | ||
); | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('code', 'RobottersDeles', 'robottersCode', array( | ||
'foreignKey' => true | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/** | ||
* RobottersDeles | ||
* | ||
* This model is an intermediate table for "Robotters" and "Deles" | ||
*/ | ||
class RobottersDeles extends Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'robots_parts'; | ||
} | ||
|
||
public function columnMap() | ||
{ | ||
return array( | ||
'id' => 'code', | ||
'robots_id' => 'robottersCode', | ||
'parts_id' => 'delesCode', | ||
); | ||
} | ||
|
||
public function initialize() | ||
{ | ||
|
||
$this->belongsTo('delesCode', 'Deles', 'code', array( | ||
'foreignKey' => true | ||
)); | ||
|
||
$this->belongsTo('robottersCode', 'Robotters', 'code', array( | ||
'foreignKey' => array( | ||
'message' => 'The robotters code does not exist' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
/** | ||
* Deles | ||
* | ||
* Deles is "parts" in danish | ||
*/ | ||
class Deles extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'parts'; | ||
} | ||
|
||
public function columnMap() | ||
{ | ||
return array( | ||
'id' => 'code', | ||
'name' => 'theName', | ||
); | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('code', 'Some\RobottersDeles', 'delesCode', array( | ||
'foreignKey' => array( | ||
'message' => 'Deles cannot be deleted because is referenced by a Robotter' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
class Parts extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'parts'; | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('id', 'RobotsParts', 'parts_id', array( | ||
'foreignKey' => array( | ||
'message' => 'Parts cannot be deleted because is referenced by a Robot' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
use Phalcon\Db\Column; | ||
use Phalcon\Mvc\Model\MetaData; | ||
|
||
class Products extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource(){ | ||
return 'le_products'; | ||
} | ||
|
||
public function metaData() | ||
{ | ||
return array( | ||
MetaData::MODELS_ATTRIBUTES => array( | ||
'id', 'name', 'type', 'price' | ||
), | ||
MetaData::MODELS_PRIMARY_KEY => array( | ||
'id' | ||
), | ||
MetaData::MODELS_NON_PRIMARY_KEY => array( | ||
'name', 'type', 'price' | ||
), | ||
MetaData::MODELS_NOT_NULL => array( | ||
'id', 'name', 'type', 'price' | ||
), | ||
MetaData::MODELS_DATA_TYPES => array( | ||
'id' => Column::TYPE_INTEGER, | ||
'name' => Column::TYPE_VARCHAR, | ||
'type' => Column::TYPE_VARCHAR, | ||
'price' => Column::TYPE_INTEGER | ||
), | ||
MetaData::MODELS_DATA_TYPES_NUMERIC => array( | ||
'id' => true, | ||
'price' => true, | ||
), | ||
MetaData::MODELS_IDENTITY_COLUMN => 'id', | ||
MetaData::MODELS_DATA_TYPES_BIND => array( | ||
'id' => Column::BIND_PARAM_INT, | ||
'name' => Column::BIND_PARAM_STR, | ||
'type' => Column::BIND_PARAM_STR, | ||
'price' => Column::BIND_PARAM_INT, | ||
), | ||
MetaData::MODELS_AUTOMATIC_DEFAULT_INSERT => array(), | ||
MetaData::MODELS_AUTOMATIC_DEFAULT_UPDATE => array() | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
class Robots extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'robots'; | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('id', 'Some\RobotsParts', 'robots_id', array( | ||
'foreignKey' => true | ||
)); | ||
} | ||
|
||
public function getRobotsParts($arguments=null) | ||
{ | ||
return $this->getRelated('Some\RobotsParts', $arguments); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
class RobotsParts extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'robots_parts'; | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->belongsTo('parts_id', 'Parts', 'id', array( | ||
'foreignKey' => true | ||
)); | ||
$this->belongsTo('robots_id', 'Robots', 'id', array( | ||
'foreignKey' => array( | ||
'message' => 'The robot code does not exist' | ||
) | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Some; | ||
|
||
/** | ||
* Robotters | ||
* | ||
* "robotters" is robots in danish | ||
*/ | ||
class Robotters extends \Phalcon\Mvc\Model | ||
{ | ||
|
||
public function getSource() | ||
{ | ||
return 'robots'; | ||
} | ||
|
||
public function columnMap() | ||
{ | ||
return array( | ||
'id' => 'code', | ||
'name' => 'theName', | ||
'type' => 'theType', | ||
'year' => 'theYear' | ||
); | ||
} | ||
|
||
public function initialize() | ||
{ | ||
$this->hasMany('code', 'Some\RobottersDeles', 'robottersCode', array( | ||
'foreignKey' => true | ||
)); | ||
} | ||
|
||
public function getRobottersDeles($arguments=null) | ||
{ | ||
return $this->getRelated('Some\RobottersDeles', $arguments); | ||
} | ||
|
||
} |
Oops, something went wrong.