| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace MGModule\DNSManager2\models\whmcs\product\configOptions;
- use MGModule\DNSManager2 as main;
- /**
- * Description of group
- * @Table(name=tblproductconfiggroups,preventUpdate,prefixed=false)
- * @author Michal Czech <michael@modulesgarden.com>
- */
- class group extends main\mgLibs\models\orm{
- private $_relatedPID = array();
- private $_configOptions = array();
-
- /**
- * @Column()
- * @var int
- */
- public $id;
-
- /**
- *
- * @Column()
- * @var string
- */
- public $name;
-
- /**
- *
- * @Column()
- * @var string
- */
- public $description;
-
- function addPID($pid)
- {
- $this->_relatedPID[] = $pid;
- }
-
- function getRelatedPIDs(){
- if(empty($this->_relatedPID))
- {
- $result = main\mgLibs\MySQL\query::select(array(
- 'pid'
- )
- , 'tblproductconfiglinks'
- ,array(
- 'gid' => $this->id
- ));
-
- while($row = $result->fetch())
- {
- $this->_relatedPID[] = $row['pid'];
- }
- }
-
- return $this->_relatedPID;
- }
-
- function save() {
- parent::save();
-
- if($this->_relatedPID)
- {
- $result = main\mgLibs\MySQL\query::select(array(
- 'pid'
- )
- , 'tblproductconfiglinks'
- ,array(
- 'gid' => $this->id
- ));
- $exists = array();
- while($row = $result->fetch())
- {
- $exists[$row['pid']] = $row['pid'];
- }
-
- foreach($this->_relatedPID as $pid)
- {
- if(!isset($exists[$pid]))
- {
- main\mgLibs\MySQL\query::insert('tblproductconfiglinks', array(
- 'pid' => $pid
- ,'gid' => $this->id
- ));
- }
- }
- }
- }
-
- function getConfigOptions(){
- if(empty($this->_configOptions))
- {
- $this->_configOptions = array();
- $result = main\mgLibs\MySQL\query::select(
- configOption::fieldDeclaration()
- , configOption::tableName()
- ,array(
- 'gid' => $this->id
- ));
- while($row = $result->fetch())
- {
- $this->_configOptions[] = new configOption($row['id'],$row);
- }
- }
-
- return $this->_configOptions;
- }
-
- }
|