PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/sgl/includes/model/generated/PaisGen.class.php

http://logisticsouth.googlecode.com/
PHP | 1771 lines | 907 code | 263 blank | 601 comment | 149 complexity | fc205634439df00413d5fa32690ba48a MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * The abstract PaisGen class defined here is
  4. * code-generated and contains all the basic CRUD-type functionality as well as
  5. * basic methods to handle relationships and index-based loading.
  6. *
  7. * To use, you should use the Pais subclass which
  8. * extends this PaisGen class.
  9. *
  10. * Because subsequent re-code generations will overwrite any changes to this
  11. * file, you should leave this file unaltered to prevent yourself from losing
  12. * any information or code changes. All customizations should be done by
  13. * overriding existing or implementing new methods, properties and variables
  14. * in the Pais class.
  15. *
  16. * @package My QCubed Application
  17. * @subpackage GeneratedDataObjects
  18. * @property-read integer $IdPAIS the value for intIdPAIS (Read-Only PK)
  19. * @property string $Nombre the value for strNombre
  20. * @property-read Importacion $_ImportacionAsPAISOrigen the value for the private _objImportacionAsPAISOrigen (Read-Only) if set due to an expansion on the IMPORTACION.PAIS_Origen reverse relationship
  21. * @property-read Importacion[] $_ImportacionAsPAISOrigenArray the value for the private _objImportacionAsPAISOrigenArray (Read-Only) if set due to an ExpandAsArray on the IMPORTACION.PAIS_Origen reverse relationship
  22. * @property-read Importacion $_ImportacionAsPAISDestino the value for the private _objImportacionAsPAISDestino (Read-Only) if set due to an expansion on the IMPORTACION.PAIS_Destino reverse relationship
  23. * @property-read Importacion[] $_ImportacionAsPAISDestinoArray the value for the private _objImportacionAsPAISDestinoArray (Read-Only) if set due to an ExpandAsArray on the IMPORTACION.PAIS_Destino reverse relationship
  24. * @property-read Proveedor $_ProveedorAsPAISIdPAIS the value for the private _objProveedorAsPAISIdPAIS (Read-Only) if set due to an expansion on the PROVEEDOR.PAIS_idPAIS reverse relationship
  25. * @property-read Proveedor[] $_ProveedorAsPAISIdPAISArray the value for the private _objProveedorAsPAISIdPAISArray (Read-Only) if set due to an ExpandAsArray on the PROVEEDOR.PAIS_idPAIS reverse relationship
  26. * @property-read Transporte $_TransporteAsPAISIdPAIS the value for the private _objTransporteAsPAISIdPAIS (Read-Only) if set due to an expansion on the TRANSPORTE.PAIS_idPAIS reverse relationship
  27. * @property-read Transporte[] $_TransporteAsPAISIdPAISArray the value for the private _objTransporteAsPAISIdPAISArray (Read-Only) if set due to an ExpandAsArray on the TRANSPORTE.PAIS_idPAIS reverse relationship
  28. * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
  29. */
  30. class PaisGen extends QBaseClass implements IteratorAggregate {
  31. ///////////////////////////////////////////////////////////////////////
  32. // PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
  33. ///////////////////////////////////////////////////////////////////////
  34. /**
  35. * Protected member variable that maps to the database PK Identity column PAIS.idPAIS
  36. * @var integer intIdPAIS
  37. */
  38. protected $intIdPAIS;
  39. const IdPAISDefault = null;
  40. /**
  41. * Protected member variable that maps to the database column PAIS.nombre
  42. * @var string strNombre
  43. */
  44. protected $strNombre;
  45. const NombreMaxLength = 45;
  46. const NombreDefault = null;
  47. /**
  48. * Private member variable that stores a reference to a single ImportacionAsPAISOrigen object
  49. * (of type Importacion), if this Pais object was restored with
  50. * an expansion on the IMPORTACION association table.
  51. * @var Importacion _objImportacionAsPAISOrigen;
  52. */
  53. private $_objImportacionAsPAISOrigen;
  54. /**
  55. * Private member variable that stores a reference to an array of ImportacionAsPAISOrigen objects
  56. * (of type Importacion[]), if this Pais object was restored with
  57. * an ExpandAsArray on the IMPORTACION association table.
  58. * @var Importacion[] _objImportacionAsPAISOrigenArray;
  59. */
  60. private $_objImportacionAsPAISOrigenArray = array();
  61. /**
  62. * Private member variable that stores a reference to a single ImportacionAsPAISDestino object
  63. * (of type Importacion), if this Pais object was restored with
  64. * an expansion on the IMPORTACION association table.
  65. * @var Importacion _objImportacionAsPAISDestino;
  66. */
  67. private $_objImportacionAsPAISDestino;
  68. /**
  69. * Private member variable that stores a reference to an array of ImportacionAsPAISDestino objects
  70. * (of type Importacion[]), if this Pais object was restored with
  71. * an ExpandAsArray on the IMPORTACION association table.
  72. * @var Importacion[] _objImportacionAsPAISDestinoArray;
  73. */
  74. private $_objImportacionAsPAISDestinoArray = array();
  75. /**
  76. * Private member variable that stores a reference to a single ProveedorAsPAISIdPAIS object
  77. * (of type Proveedor), if this Pais object was restored with
  78. * an expansion on the PROVEEDOR association table.
  79. * @var Proveedor _objProveedorAsPAISIdPAIS;
  80. */
  81. private $_objProveedorAsPAISIdPAIS;
  82. /**
  83. * Private member variable that stores a reference to an array of ProveedorAsPAISIdPAIS objects
  84. * (of type Proveedor[]), if this Pais object was restored with
  85. * an ExpandAsArray on the PROVEEDOR association table.
  86. * @var Proveedor[] _objProveedorAsPAISIdPAISArray;
  87. */
  88. private $_objProveedorAsPAISIdPAISArray = array();
  89. /**
  90. * Private member variable that stores a reference to a single TransporteAsPAISIdPAIS object
  91. * (of type Transporte), if this Pais object was restored with
  92. * an expansion on the TRANSPORTE association table.
  93. * @var Transporte _objTransporteAsPAISIdPAIS;
  94. */
  95. private $_objTransporteAsPAISIdPAIS;
  96. /**
  97. * Private member variable that stores a reference to an array of TransporteAsPAISIdPAIS objects
  98. * (of type Transporte[]), if this Pais object was restored with
  99. * an ExpandAsArray on the TRANSPORTE association table.
  100. * @var Transporte[] _objTransporteAsPAISIdPAISArray;
  101. */
  102. private $_objTransporteAsPAISIdPAISArray = array();
  103. /**
  104. * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
  105. * columns from the run-time database query result for this object). Used by InstantiateDbRow and
  106. * GetVirtualAttribute.
  107. * @var string[] $__strVirtualAttributeArray
  108. */
  109. protected $__strVirtualAttributeArray = array();
  110. /**
  111. * Protected internal member variable that specifies whether or not this object is Restored from the database.
  112. * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
  113. * @var bool __blnRestored;
  114. */
  115. protected $__blnRestored;
  116. ///////////////////////////////
  117. // PROTECTED MEMBER OBJECTS
  118. ///////////////////////////////
  119. /**
  120. * Initialize each property with default values from database definition
  121. */
  122. public function Initialize()
  123. {
  124. $this->intIdPAIS = Pais::IdPAISDefault;
  125. $this->strNombre = Pais::NombreDefault;
  126. }
  127. ///////////////////////////////
  128. // CLASS-WIDE LOAD AND COUNT METHODS
  129. ///////////////////////////////
  130. /**
  131. * Static method to retrieve the Database object that owns this class.
  132. * @return QDatabaseBase reference to the Database object that can query this class
  133. */
  134. public static function GetDatabase() {
  135. return QApplication::$Database[1];
  136. }
  137. /**
  138. * Load a Pais from PK Info
  139. * @param integer $intIdPAIS
  140. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  141. * @return Pais
  142. */
  143. public static function Load($intIdPAIS, $objOptionalClauses = null) {
  144. // Use QuerySingle to Perform the Query
  145. return Pais::QuerySingle(
  146. QQ::AndCondition(
  147. QQ::Equal(QQN::Pais()->IdPAIS, $intIdPAIS)
  148. ),
  149. $objOptionalClauses
  150. );
  151. }
  152. /**
  153. * Load all Paises
  154. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  155. * @return Pais[]
  156. */
  157. public static function LoadAll($objOptionalClauses = null) {
  158. if (func_num_args() > 1) {
  159. throw new QCallerException("LoadAll must be called with an array of optional clauses as a single argument");
  160. }
  161. // Call Pais::QueryArray to perform the LoadAll query
  162. try {
  163. return Pais::QueryArray(QQ::All(), $objOptionalClauses);
  164. } catch (QCallerException $objExc) {
  165. $objExc->IncrementOffset();
  166. throw $objExc;
  167. }
  168. }
  169. /**
  170. * Count all Paises
  171. * @return int
  172. */
  173. public static function CountAll() {
  174. // Call Pais::QueryCount to perform the CountAll query
  175. return Pais::QueryCount(QQ::All());
  176. }
  177. ///////////////////////////////
  178. // QCUBED QUERY-RELATED METHODS
  179. ///////////////////////////////
  180. /**
  181. * Internally called method to assist with calling Qcubed Query for this class
  182. * on load methods.
  183. * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
  184. * @param QQCondition $objConditions any conditions on the query, itself
  185. * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
  186. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
  187. * @param boolean $blnCountOnly only select a rowcount
  188. * @return string the query statement
  189. */
  190. protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
  191. // Get the Database Object for this Class
  192. $objDatabase = Pais::GetDatabase();
  193. // Create/Build out the QueryBuilder object with Pais-specific SELET and FROM fields
  194. $objQueryBuilder = new QQueryBuilder($objDatabase, 'PAIS');
  195. Pais::GetSelectFields($objQueryBuilder);
  196. $objQueryBuilder->AddFromItem('PAIS');
  197. // Set "CountOnly" option (if applicable)
  198. if ($blnCountOnly)
  199. $objQueryBuilder->SetCountOnlyFlag();
  200. // Apply Any Conditions
  201. if ($objConditions)
  202. try {
  203. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  204. } catch (QCallerException $objExc) {
  205. $objExc->IncrementOffset();
  206. throw $objExc;
  207. }
  208. // Iterate through all the Optional Clauses (if any) and perform accordingly
  209. if ($objOptionalClauses) {
  210. if ($objOptionalClauses instanceof QQClause)
  211. $objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
  212. else if (is_array($objOptionalClauses))
  213. foreach ($objOptionalClauses as $objClause)
  214. $objClause->UpdateQueryBuilder($objQueryBuilder);
  215. else
  216. throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
  217. }
  218. // Get the SQL Statement
  219. $strQuery = $objQueryBuilder->GetStatement();
  220. // Prepare the Statement with the Query Parameters (if applicable)
  221. if ($mixParameterArray) {
  222. if (is_array($mixParameterArray)) {
  223. if (count($mixParameterArray))
  224. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  225. // Ensure that there are no other Unresolved Named Parameters
  226. if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
  227. throw new QCallerException('Unresolved named parameters in the query');
  228. } else
  229. throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
  230. }
  231. // Return the Objects
  232. return $strQuery;
  233. }
  234. /**
  235. * Static Qcubed Query method to query for a single Pais object.
  236. * Uses BuildQueryStatment to perform most of the work.
  237. * @param QQCondition $objConditions any conditions on the query, itself
  238. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  239. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  240. * @return Pais the queried object
  241. */
  242. public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  243. // Get the Query Statement
  244. try {
  245. $strQuery = Pais::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  246. } catch (QCallerException $objExc) {
  247. $objExc->IncrementOffset();
  248. throw $objExc;
  249. }
  250. // Perform the Query, Get the First Row, and Instantiate a new Pais object
  251. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  252. // Do we have to expand anything?
  253. if ($objQueryBuilder->ExpandAsArrayNodes) {
  254. $objToReturn = array();
  255. while ($objDbRow = $objDbResult->GetNextRow()) {
  256. $objItem = Pais::InstantiateDbRow($objDbRow, null, $objQueryBuilder->ExpandAsArrayNodes, $objToReturn, $objQueryBuilder->ColumnAliasArray);
  257. if ($objItem)
  258. $objToReturn[] = $objItem;
  259. }
  260. if (count($objToReturn)) {
  261. // Since we only want the object to return, lets return the object and not the array.
  262. return $objToReturn[0];
  263. } else {
  264. return null;
  265. }
  266. } else {
  267. // No expands just return the first row
  268. $objDbRow = $objDbResult->GetNextRow();
  269. if(null === $objDbRow)
  270. return null;
  271. return Pais::InstantiateDbRow($objDbRow, null, null, null, $objQueryBuilder->ColumnAliasArray);
  272. }
  273. }
  274. /**
  275. * Static Qcubed Query method to query for an array of Pais objects.
  276. * Uses BuildQueryStatment to perform most of the work.
  277. * @param QQCondition $objConditions any conditions on the query, itself
  278. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  279. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  280. * @return Pais[] the queried objects as an array
  281. */
  282. public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  283. // Get the Query Statement
  284. try {
  285. $strQuery = Pais::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  286. } catch (QCallerException $objExc) {
  287. $objExc->IncrementOffset();
  288. throw $objExc;
  289. }
  290. // Perform the Query and Instantiate the Array Result
  291. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  292. return Pais::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  293. }
  294. /**
  295. * Static Qcubed Query method to query for a count of Pais objects.
  296. * Uses BuildQueryStatment to perform most of the work.
  297. * @param QQCondition $objConditions any conditions on the query, itself
  298. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  299. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  300. * @return integer the count of queried objects as an integer
  301. */
  302. public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  303. // Get the Query Statement
  304. try {
  305. $strQuery = Pais::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
  306. } catch (QCallerException $objExc) {
  307. $objExc->IncrementOffset();
  308. throw $objExc;
  309. }
  310. // Perform the Query and return the row_count
  311. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  312. // Figure out if the query is using GroupBy
  313. $blnGrouped = false;
  314. if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
  315. if ($objClause instanceof QQGroupBy) {
  316. $blnGrouped = true;
  317. break;
  318. }
  319. }
  320. if ($blnGrouped)
  321. // Groups in this query - return the count of Groups (which is the count of all rows)
  322. return $objDbResult->CountRows();
  323. else {
  324. // No Groups - return the sql-calculated count(*) value
  325. $strDbRow = $objDbResult->FetchRow();
  326. return QType::Cast($strDbRow[0], QType::Integer);
  327. }
  328. }
  329. public static function QueryArrayCached(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null, $blnForceUpdate = false) {
  330. // Get the Database Object for this Class
  331. $objDatabase = Pais::GetDatabase();
  332. $strQuery = Pais::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  333. $objCache = new QCache('qquery/pais', $strQuery);
  334. $cacheData = $objCache->GetData();
  335. if (!$cacheData || $blnForceUpdate) {
  336. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  337. $arrResult = Pais::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  338. $objCache->SaveData(serialize($arrResult));
  339. } else {
  340. $arrResult = unserialize($cacheData);
  341. }
  342. return $arrResult;
  343. }
  344. /**
  345. * Updates a QQueryBuilder with the SELECT fields for this Pais
  346. * @param QQueryBuilder $objBuilder the Query Builder object to update
  347. * @param string $strPrefix optional prefix to add to the SELECT fields
  348. */
  349. public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
  350. if ($strPrefix) {
  351. $strTableName = $strPrefix;
  352. $strAliasPrefix = $strPrefix . '__';
  353. } else {
  354. $strTableName = 'PAIS';
  355. $strAliasPrefix = '';
  356. }
  357. $objBuilder->AddSelectItem($strTableName, 'idPAIS', $strAliasPrefix . 'idPAIS');
  358. $objBuilder->AddSelectItem($strTableName, 'nombre', $strAliasPrefix . 'nombre');
  359. }
  360. ///////////////////////////////
  361. // INSTANTIATION-RELATED METHODS
  362. ///////////////////////////////
  363. /**
  364. * Instantiate a Pais from a Database Row.
  365. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  366. * is calling this Pais::InstantiateDbRow in order to perform
  367. * early binding on referenced objects.
  368. * @param DatabaseRowBase $objDbRow
  369. * @param string $strAliasPrefix
  370. * @param string $strExpandAsArrayNodes
  371. * @param QBaseClass $arrPreviousItem
  372. * @param string[] $strColumnAliasArray
  373. * @return Pais
  374. */
  375. public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $arrPreviousItems = null, $strColumnAliasArray = array()) {
  376. // If blank row, return null
  377. if (!$objDbRow) {
  378. return null;
  379. }
  380. // See if we're doing an array expansion on the previous item
  381. $strAlias = $strAliasPrefix . 'idPAIS';
  382. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  383. if (($strExpandAsArrayNodes) && is_array($arrPreviousItems) && count($arrPreviousItems)) {
  384. foreach ($arrPreviousItems as $objPreviousItem) {
  385. if ($objPreviousItem->intIdPAIS == $objDbRow->GetColumn($strAliasName, 'Integer')) {
  386. // We are. Now, prepare to check for ExpandAsArray clauses
  387. $blnExpandedViaArray = false;
  388. if (!$strAliasPrefix)
  389. $strAliasPrefix = 'PAIS__';
  390. // Expanding reverse references: ImportacionAsPAISOrigen
  391. $strAlias = $strAliasPrefix . 'importacionaspaisorigen__TRANSPORTE_idTRANSPORTE';
  392. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  393. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  394. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  395. if ($intPreviousChildItemCount = count($objPreviousItem->_objImportacionAsPAISOrigenArray)) {
  396. $objPreviousChildItems = $objPreviousItem->_objImportacionAsPAISOrigenArray;
  397. $objChildItem = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisorigen__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
  398. if ($objChildItem) {
  399. $objPreviousItem->_objImportacionAsPAISOrigenArray[] = $objChildItem;
  400. }
  401. } else {
  402. $objPreviousItem->_objImportacionAsPAISOrigenArray[] = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisorigen__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  403. }
  404. $blnExpandedViaArray = true;
  405. }
  406. // Expanding reverse references: ImportacionAsPAISDestino
  407. $strAlias = $strAliasPrefix . 'importacionaspaisdestino__TRANSPORTE_idTRANSPORTE';
  408. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  409. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  410. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  411. if ($intPreviousChildItemCount = count($objPreviousItem->_objImportacionAsPAISDestinoArray)) {
  412. $objPreviousChildItems = $objPreviousItem->_objImportacionAsPAISDestinoArray;
  413. $objChildItem = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisdestino__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
  414. if ($objChildItem) {
  415. $objPreviousItem->_objImportacionAsPAISDestinoArray[] = $objChildItem;
  416. }
  417. } else {
  418. $objPreviousItem->_objImportacionAsPAISDestinoArray[] = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisdestino__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  419. }
  420. $blnExpandedViaArray = true;
  421. }
  422. // Expanding reverse references: ProveedorAsPAISIdPAIS
  423. $strAlias = $strAliasPrefix . 'proveedoraspaisidpais__idPROVEEDOR';
  424. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  425. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  426. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  427. if ($intPreviousChildItemCount = count($objPreviousItem->_objProveedorAsPAISIdPAISArray)) {
  428. $objPreviousChildItems = $objPreviousItem->_objProveedorAsPAISIdPAISArray;
  429. $objChildItem = Proveedor::InstantiateDbRow($objDbRow, $strAliasPrefix . 'proveedoraspaisidpais__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
  430. if ($objChildItem) {
  431. $objPreviousItem->_objProveedorAsPAISIdPAISArray[] = $objChildItem;
  432. }
  433. } else {
  434. $objPreviousItem->_objProveedorAsPAISIdPAISArray[] = Proveedor::InstantiateDbRow($objDbRow, $strAliasPrefix . 'proveedoraspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  435. }
  436. $blnExpandedViaArray = true;
  437. }
  438. // Expanding reverse references: TransporteAsPAISIdPAIS
  439. $strAlias = $strAliasPrefix . 'transporteaspaisidpais__idTRANSPORTE';
  440. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  441. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  442. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  443. if ($intPreviousChildItemCount = count($objPreviousItem->_objTransporteAsPAISIdPAISArray)) {
  444. $objPreviousChildItems = $objPreviousItem->_objTransporteAsPAISIdPAISArray;
  445. $objChildItem = Transporte::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transporteaspaisidpais__', $strExpandAsArrayNodes, $objPreviousChildItems, $strColumnAliasArray);
  446. if ($objChildItem) {
  447. $objPreviousItem->_objTransporteAsPAISIdPAISArray[] = $objChildItem;
  448. }
  449. } else {
  450. $objPreviousItem->_objTransporteAsPAISIdPAISArray[] = Transporte::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transporteaspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  451. }
  452. $blnExpandedViaArray = true;
  453. }
  454. // Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
  455. if ($blnExpandedViaArray) {
  456. return false;
  457. } else if ($strAliasPrefix == 'PAIS__') {
  458. $strAliasPrefix = null;
  459. }
  460. }
  461. }
  462. }
  463. // Create a new instance of the Pais object
  464. $objToReturn = new Pais();
  465. $objToReturn->__blnRestored = true;
  466. $strAliasName = array_key_exists($strAliasPrefix . 'idPAIS', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'idPAIS'] : $strAliasPrefix . 'idPAIS';
  467. $objToReturn->intIdPAIS = $objDbRow->GetColumn($strAliasName, 'Integer');
  468. $strAliasName = array_key_exists($strAliasPrefix . 'nombre', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'nombre'] : $strAliasPrefix . 'nombre';
  469. $objToReturn->strNombre = $objDbRow->GetColumn($strAliasName, 'VarChar');
  470. if (isset($arrPreviousItems) && is_array($arrPreviousItems)) {
  471. foreach ($arrPreviousItems as $objPreviousItem) {
  472. if ($objToReturn->IdPAIS != $objPreviousItem->IdPAIS) {
  473. continue;
  474. }
  475. if (array_diff($objPreviousItem->_objImportacionAsPAISOrigenArray, $objToReturn->_objImportacionAsPAISOrigenArray) != null) {
  476. continue;
  477. }
  478. if (array_diff($objPreviousItem->_objImportacionAsPAISDestinoArray, $objToReturn->_objImportacionAsPAISDestinoArray) != null) {
  479. continue;
  480. }
  481. if (array_diff($objPreviousItem->_objProveedorAsPAISIdPAISArray, $objToReturn->_objProveedorAsPAISIdPAISArray) != null) {
  482. continue;
  483. }
  484. if (array_diff($objPreviousItem->_objTransporteAsPAISIdPAISArray, $objToReturn->_objTransporteAsPAISIdPAISArray) != null) {
  485. continue;
  486. }
  487. // complete match - all primary key columns are the same
  488. return null;
  489. }
  490. }
  491. // Instantiate Virtual Attributes
  492. foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
  493. $strVirtualPrefix = $strAliasPrefix . '__';
  494. $strVirtualPrefixLength = strlen($strVirtualPrefix);
  495. if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
  496. $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
  497. }
  498. // Prepare to Check for Early/Virtual Binding
  499. if (!$strAliasPrefix)
  500. $strAliasPrefix = 'PAIS__';
  501. // Check for ImportacionAsPAISOrigen Virtual Binding
  502. $strAlias = $strAliasPrefix . 'importacionaspaisorigen__TRANSPORTE_idTRANSPORTE';
  503. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  504. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  505. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  506. $objToReturn->_objImportacionAsPAISOrigenArray[] = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisorigen__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  507. else
  508. $objToReturn->_objImportacionAsPAISOrigen = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisorigen__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  509. }
  510. // Check for ImportacionAsPAISDestino Virtual Binding
  511. $strAlias = $strAliasPrefix . 'importacionaspaisdestino__TRANSPORTE_idTRANSPORTE';
  512. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  513. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  514. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  515. $objToReturn->_objImportacionAsPAISDestinoArray[] = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisdestino__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  516. else
  517. $objToReturn->_objImportacionAsPAISDestino = Importacion::InstantiateDbRow($objDbRow, $strAliasPrefix . 'importacionaspaisdestino__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  518. }
  519. // Check for ProveedorAsPAISIdPAIS Virtual Binding
  520. $strAlias = $strAliasPrefix . 'proveedoraspaisidpais__idPROVEEDOR';
  521. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  522. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  523. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  524. $objToReturn->_objProveedorAsPAISIdPAISArray[] = Proveedor::InstantiateDbRow($objDbRow, $strAliasPrefix . 'proveedoraspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  525. else
  526. $objToReturn->_objProveedorAsPAISIdPAIS = Proveedor::InstantiateDbRow($objDbRow, $strAliasPrefix . 'proveedoraspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  527. }
  528. // Check for TransporteAsPAISIdPAIS Virtual Binding
  529. $strAlias = $strAliasPrefix . 'transporteaspaisidpais__idTRANSPORTE';
  530. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  531. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  532. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  533. $objToReturn->_objTransporteAsPAISIdPAISArray[] = Transporte::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transporteaspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  534. else
  535. $objToReturn->_objTransporteAsPAISIdPAIS = Transporte::InstantiateDbRow($objDbRow, $strAliasPrefix . 'transporteaspaisidpais__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  536. }
  537. return $objToReturn;
  538. }
  539. /**
  540. * Instantiate an array of Paises from a Database Result
  541. * @param DatabaseResultBase $objDbResult
  542. * @param string $strExpandAsArrayNodes
  543. * @param string[] $strColumnAliasArray
  544. * @return Pais[]
  545. */
  546. public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
  547. $objToReturn = array();
  548. if (!$strColumnAliasArray)
  549. $strColumnAliasArray = array();
  550. // If blank resultset, then return empty array
  551. if (!$objDbResult)
  552. return $objToReturn;
  553. // Load up the return array with each row
  554. if ($strExpandAsArrayNodes) {
  555. $objToReturn = array();
  556. while ($objDbRow = $objDbResult->GetNextRow()) {
  557. $objItem = Pais::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objToReturn, $strColumnAliasArray);
  558. if ($objItem) {
  559. $objToReturn[] = $objItem;
  560. }
  561. }
  562. } else {
  563. while ($objDbRow = $objDbResult->GetNextRow())
  564. $objToReturn[] = Pais::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
  565. }
  566. return $objToReturn;
  567. }
  568. ///////////////////////////////////////////////////
  569. // INDEX-BASED LOAD METHODS (Single Load and Array)
  570. ///////////////////////////////////////////////////
  571. /**
  572. * Load a single Pais object,
  573. * by IdPAIS Index(es)
  574. * @param integer $intIdPAIS
  575. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  576. * @return Pais
  577. */
  578. public static function LoadByIdPAIS($intIdPAIS, $objOptionalClauses = null) {
  579. return Pais::QuerySingle(
  580. QQ::AndCondition(
  581. QQ::Equal(QQN::Pais()->IdPAIS, $intIdPAIS)
  582. ),
  583. $objOptionalClauses
  584. );
  585. }
  586. ////////////////////////////////////////////////////
  587. // INDEX-BASED LOAD METHODS (Array via Many to Many)
  588. ////////////////////////////////////////////////////
  589. //////////////////////////
  590. // SAVE, DELETE AND RELOAD
  591. //////////////////////////
  592. /**
  593. * Save this Pais
  594. * @param bool $blnForceInsert
  595. * @param bool $blnForceUpdate
  596. * @return int
  597. */
  598. public function Save($blnForceInsert = false, $blnForceUpdate = false) {
  599. // Get the Database Object for this Class
  600. $objDatabase = Pais::GetDatabase();
  601. $mixToReturn = null;
  602. try {
  603. if ((!$this->__blnRestored) || ($blnForceInsert)) {
  604. // Perform an INSERT query
  605. $objDatabase->NonQuery('
  606. INSERT INTO `PAIS` (
  607. `nombre`
  608. ) VALUES (
  609. ' . $objDatabase->SqlVariable($this->strNombre) . '
  610. )
  611. ');
  612. // Update Identity column and return its value
  613. $mixToReturn = $this->intIdPAIS = $objDatabase->InsertId('PAIS', 'idPAIS');
  614. } else {
  615. // Perform an UPDATE query
  616. // First checking for Optimistic Locking constraints (if applicable)
  617. // Perform the UPDATE query
  618. $objDatabase->NonQuery('
  619. UPDATE
  620. `PAIS`
  621. SET
  622. `nombre` = ' . $objDatabase->SqlVariable($this->strNombre) . '
  623. WHERE
  624. `idPAIS` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  625. ');
  626. }
  627. } catch (QCallerException $objExc) {
  628. $objExc->IncrementOffset();
  629. throw $objExc;
  630. }
  631. // Update __blnRestored and any Non-Identity PK Columns (if applicable)
  632. $this->__blnRestored = true;
  633. // Return
  634. return $mixToReturn;
  635. }
  636. /**
  637. * Delete this Pais
  638. * @return void
  639. */
  640. public function Delete() {
  641. if ((is_null($this->intIdPAIS)))
  642. throw new QUndefinedPrimaryKeyException('Cannot delete this Pais with an unset primary key.');
  643. // Get the Database Object for this Class
  644. $objDatabase = Pais::GetDatabase();
  645. // Perform the SQL Query
  646. $objDatabase->NonQuery('
  647. DELETE FROM
  648. `PAIS`
  649. WHERE
  650. `idPAIS` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '');
  651. }
  652. /**
  653. * Delete all Paises
  654. * @return void
  655. */
  656. public static function DeleteAll() {
  657. // Get the Database Object for this Class
  658. $objDatabase = Pais::GetDatabase();
  659. // Perform the Query
  660. $objDatabase->NonQuery('
  661. DELETE FROM
  662. `PAIS`');
  663. }
  664. /**
  665. * Truncate PAIS table
  666. * @return void
  667. */
  668. public static function Truncate() {
  669. // Get the Database Object for this Class
  670. $objDatabase = Pais::GetDatabase();
  671. // Perform the Query
  672. $objDatabase->NonQuery('
  673. TRUNCATE `PAIS`');
  674. }
  675. /**
  676. * Reload this Pais from the database.
  677. * @return void
  678. */
  679. public function Reload() {
  680. // Make sure we are actually Restored from the database
  681. if (!$this->__blnRestored)
  682. throw new QCallerException('Cannot call Reload() on a new, unsaved Pais object.');
  683. // Reload the Object
  684. $objReloaded = Pais::Load($this->intIdPAIS);
  685. // Update $this's local variables to match
  686. $this->strNombre = $objReloaded->strNombre;
  687. }
  688. ////////////////////
  689. // PUBLIC OVERRIDERS
  690. ////////////////////
  691. /**
  692. * Override method to perform a property "Get"
  693. * This will get the value of $strName
  694. *
  695. * @param string $strName Name of the property to get
  696. * @return mixed
  697. */
  698. public function __get($strName) {
  699. switch ($strName) {
  700. ///////////////////
  701. // Member Variables
  702. ///////////////////
  703. case 'IdPAIS':
  704. /**
  705. * Gets the value for intIdPAIS (Read-Only PK)
  706. * @return integer
  707. */
  708. return $this->intIdPAIS;
  709. case 'Nombre':
  710. /**
  711. * Gets the value for strNombre
  712. * @return string
  713. */
  714. return $this->strNombre;
  715. ///////////////////
  716. // Member Objects
  717. ///////////////////
  718. ////////////////////////////
  719. // Virtual Object References (Many to Many and Reverse References)
  720. // (If restored via a "Many-to" expansion)
  721. ////////////////////////////
  722. case '_ImportacionAsPAISOrigen':
  723. /**
  724. * Gets the value for the private _objImportacionAsPAISOrigen (Read-Only)
  725. * if set due to an expansion on the IMPORTACION.PAIS_Origen reverse relationship
  726. * @return Importacion
  727. */
  728. return $this->_objImportacionAsPAISOrigen;
  729. case '_ImportacionAsPAISOrigenArray':
  730. /**
  731. * Gets the value for the private _objImportacionAsPAISOrigenArray (Read-Only)
  732. * if set due to an ExpandAsArray on the IMPORTACION.PAIS_Origen reverse relationship
  733. * @return Importacion[]
  734. */
  735. return (array) $this->_objImportacionAsPAISOrigenArray;
  736. case '_ImportacionAsPAISDestino':
  737. /**
  738. * Gets the value for the private _objImportacionAsPAISDestino (Read-Only)
  739. * if set due to an expansion on the IMPORTACION.PAIS_Destino reverse relationship
  740. * @return Importacion
  741. */
  742. return $this->_objImportacionAsPAISDestino;
  743. case '_ImportacionAsPAISDestinoArray':
  744. /**
  745. * Gets the value for the private _objImportacionAsPAISDestinoArray (Read-Only)
  746. * if set due to an ExpandAsArray on the IMPORTACION.PAIS_Destino reverse relationship
  747. * @return Importacion[]
  748. */
  749. return (array) $this->_objImportacionAsPAISDestinoArray;
  750. case '_ProveedorAsPAISIdPAIS':
  751. /**
  752. * Gets the value for the private _objProveedorAsPAISIdPAIS (Read-Only)
  753. * if set due to an expansion on the PROVEEDOR.PAIS_idPAIS reverse relationship
  754. * @return Proveedor
  755. */
  756. return $this->_objProveedorAsPAISIdPAIS;
  757. case '_ProveedorAsPAISIdPAISArray':
  758. /**
  759. * Gets the value for the private _objProveedorAsPAISIdPAISArray (Read-Only)
  760. * if set due to an ExpandAsArray on the PROVEEDOR.PAIS_idPAIS reverse relationship
  761. * @return Proveedor[]
  762. */
  763. return (array) $this->_objProveedorAsPAISIdPAISArray;
  764. case '_TransporteAsPAISIdPAIS':
  765. /**
  766. * Gets the value for the private _objTransporteAsPAISIdPAIS (Read-Only)
  767. * if set due to an expansion on the TRANSPORTE.PAIS_idPAIS reverse relationship
  768. * @return Transporte
  769. */
  770. return $this->_objTransporteAsPAISIdPAIS;
  771. case '_TransporteAsPAISIdPAISArray':
  772. /**
  773. * Gets the value for the private _objTransporteAsPAISIdPAISArray (Read-Only)
  774. * if set due to an ExpandAsArray on the TRANSPORTE.PAIS_idPAIS reverse relationship
  775. * @return Transporte[]
  776. */
  777. return (array) $this->_objTransporteAsPAISIdPAISArray;
  778. case '__Restored':
  779. return $this->__blnRestored;
  780. default:
  781. try {
  782. return parent::__get($strName);
  783. } catch (QCallerException $objExc) {
  784. $objExc->IncrementOffset();
  785. throw $objExc;
  786. }
  787. }
  788. }
  789. /**
  790. * Override method to perform a property "Set"
  791. * This will set the property $strName to be $mixValue
  792. *
  793. * @param string $strName Name of the property to set
  794. * @param string $mixValue New value of the property
  795. * @return mixed
  796. */
  797. public function __set($strName, $mixValue) {
  798. switch ($strName) {
  799. ///////////////////
  800. // Member Variables
  801. ///////////////////
  802. case 'Nombre':
  803. /**
  804. * Sets the value for strNombre
  805. * @param string $mixValue
  806. * @return string
  807. */
  808. try {
  809. return ($this->strNombre = QType::Cast($mixValue, QType::String));
  810. } catch (QCallerException $objExc) {
  811. $objExc->IncrementOffset();
  812. throw $objExc;
  813. }
  814. ///////////////////
  815. // Member Objects
  816. ///////////////////
  817. default:
  818. try {
  819. return parent::__set($strName, $mixValue);
  820. } catch (QCallerException $objExc) {
  821. $objExc->IncrementOffset();
  822. throw $objExc;
  823. }
  824. }
  825. }
  826. /**
  827. * Lookup a VirtualAttribute value (if applicable). Returns NULL if none found.
  828. * @param string $strName
  829. * @return string
  830. */
  831. public function GetVirtualAttribute($strName) {
  832. if (array_key_exists($strName, $this->__strVirtualAttributeArray))
  833. return $this->__strVirtualAttributeArray[$strName];
  834. return null;
  835. }
  836. ///////////////////////////////
  837. // ASSOCIATED OBJECTS' METHODS
  838. ///////////////////////////////
  839. // Related Objects' Methods for ImportacionAsPAISOrigen
  840. //-------------------------------------------------------------------
  841. /**
  842. * Gets all associated ImportacionsAsPAISOrigen as an array of Importacion objects
  843. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  844. * @return Importacion[]
  845. */
  846. public function GetImportacionAsPAISOrigenArray($objOptionalClauses = null) {
  847. if ((is_null($this->intIdPAIS)))
  848. return array();
  849. try {
  850. return Importacion::LoadArrayByPAISOrigen($this->intIdPAIS, $objOptionalClauses);
  851. } catch (QCallerException $objExc) {
  852. $objExc->IncrementOffset();
  853. throw $objExc;
  854. }
  855. }
  856. /**
  857. * Counts all associated ImportacionsAsPAISOrigen
  858. * @return int
  859. */
  860. public function CountImportacionsAsPAISOrigen() {
  861. if ((is_null($this->intIdPAIS)))
  862. return 0;
  863. return Importacion::CountByPAISOrigen($this->intIdPAIS);
  864. }
  865. /**
  866. * Associates a ImportacionAsPAISOrigen
  867. * @param Importacion $objImportacion
  868. * @return void
  869. */
  870. public function AssociateImportacionAsPAISOrigen(Importacion $objImportacion) {
  871. if ((is_null($this->intIdPAIS)))
  872. throw new QUndefinedPrimaryKeyException('Unable to call AssociateImportacionAsPAISOrigen on this unsaved Pais.');
  873. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  874. throw new QUndefinedPrimaryKeyException('Unable to call AssociateImportacionAsPAISOrigen on this Pais with an unsaved Importacion.');
  875. // Get the Database Object for this Class
  876. $objDatabase = Pais::GetDatabase();
  877. // Perform the SQL Query
  878. $objDatabase->NonQuery('
  879. UPDATE
  880. `IMPORTACION`
  881. SET
  882. `PAIS_Origen` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  883. WHERE
  884. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  885. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . '
  886. ');
  887. }
  888. /**
  889. * Unassociates a ImportacionAsPAISOrigen
  890. * @param Importacion $objImportacion
  891. * @return void
  892. */
  893. public function UnassociateImportacionAsPAISOrigen(Importacion $objImportacion) {
  894. if ((is_null($this->intIdPAIS)))
  895. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this unsaved Pais.');
  896. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  897. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this Pais with an unsaved Importacion.');
  898. // Get the Database Object for this Class
  899. $objDatabase = Pais::GetDatabase();
  900. // Perform the SQL Query
  901. $objDatabase->NonQuery('
  902. UPDATE
  903. `IMPORTACION`
  904. SET
  905. `PAIS_Origen` = null
  906. WHERE
  907. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  908. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . ' AND
  909. `PAIS_Origen` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  910. ');
  911. }
  912. /**
  913. * Unassociates all ImportacionsAsPAISOrigen
  914. * @return void
  915. */
  916. public function UnassociateAllImportacionsAsPAISOrigen() {
  917. if ((is_null($this->intIdPAIS)))
  918. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this unsaved Pais.');
  919. // Get the Database Object for this Class
  920. $objDatabase = Pais::GetDatabase();
  921. // Perform the SQL Query
  922. $objDatabase->NonQuery('
  923. UPDATE
  924. `IMPORTACION`
  925. SET
  926. `PAIS_Origen` = null
  927. WHERE
  928. `PAIS_Origen` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  929. ');
  930. }
  931. /**
  932. * Deletes an associated ImportacionAsPAISOrigen
  933. * @param Importacion $objImportacion
  934. * @return void
  935. */
  936. public function DeleteAssociatedImportacionAsPAISOrigen(Importacion $objImportacion) {
  937. if ((is_null($this->intIdPAIS)))
  938. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this unsaved Pais.');
  939. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  940. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this Pais with an unsaved Importacion.');
  941. // Get the Database Object for this Class
  942. $objDatabase = Pais::GetDatabase();
  943. // Perform the SQL Query
  944. $objDatabase->NonQuery('
  945. DELETE FROM
  946. `IMPORTACION`
  947. WHERE
  948. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  949. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . ' AND
  950. `PAIS_Origen` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  951. ');
  952. }
  953. /**
  954. * Deletes all associated ImportacionsAsPAISOrigen
  955. * @return void
  956. */
  957. public function DeleteAllImportacionsAsPAISOrigen() {
  958. if ((is_null($this->intIdPAIS)))
  959. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISOrigen on this unsaved Pais.');
  960. // Get the Database Object for this Class
  961. $objDatabase = Pais::GetDatabase();
  962. // Perform the SQL Query
  963. $objDatabase->NonQuery('
  964. DELETE FROM
  965. `IMPORTACION`
  966. WHERE
  967. `PAIS_Origen` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  968. ');
  969. }
  970. // Related Objects' Methods for ImportacionAsPAISDestino
  971. //-------------------------------------------------------------------
  972. /**
  973. * Gets all associated ImportacionsAsPAISDestino as an array of Importacion objects
  974. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  975. * @return Importacion[]
  976. */
  977. public function GetImportacionAsPAISDestinoArray($objOptionalClauses = null) {
  978. if ((is_null($this->intIdPAIS)))
  979. return array();
  980. try {
  981. return Importacion::LoadArrayByPAISDestino($this->intIdPAIS, $objOptionalClauses);
  982. } catch (QCallerException $objExc) {
  983. $objExc->IncrementOffset();
  984. throw $objExc;
  985. }
  986. }
  987. /**
  988. * Counts all associated ImportacionsAsPAISDestino
  989. * @return int
  990. */
  991. public function CountImportacionsAsPAISDestino() {
  992. if ((is_null($this->intIdPAIS)))
  993. return 0;
  994. return Importacion::CountByPAISDestino($this->intIdPAIS);
  995. }
  996. /**
  997. * Associates a ImportacionAsPAISDestino
  998. * @param Importacion $objImportacion
  999. * @return void
  1000. */
  1001. public function AssociateImportacionAsPAISDestino(Importacion $objImportacion) {
  1002. if ((is_null($this->intIdPAIS)))
  1003. throw new QUndefinedPrimaryKeyException('Unable to call AssociateImportacionAsPAISDestino on this unsaved Pais.');
  1004. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  1005. throw new QUndefinedPrimaryKeyException('Unable to call AssociateImportacionAsPAISDestino on this Pais with an unsaved Importacion.');
  1006. // Get the Database Object for this Class
  1007. $objDatabase = Pais::GetDatabase();
  1008. // Perform the SQL Query
  1009. $objDatabase->NonQuery('
  1010. UPDATE
  1011. `IMPORTACION`
  1012. SET
  1013. `PAIS_Destino` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  1014. WHERE
  1015. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  1016. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . '
  1017. ');
  1018. }
  1019. /**
  1020. * Unassociates a ImportacionAsPAISDestino
  1021. * @param Importacion $objImportacion
  1022. * @return void
  1023. */
  1024. public function UnassociateImportacionAsPAISDestino(Importacion $objImportacion) {
  1025. if ((is_null($this->intIdPAIS)))
  1026. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this unsaved Pais.');
  1027. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  1028. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this Pais with an unsaved Importacion.');
  1029. // Get the Database Object for this Class
  1030. $objDatabase = Pais::GetDatabase();
  1031. // Perform the SQL Query
  1032. $objDatabase->NonQuery('
  1033. UPDATE
  1034. `IMPORTACION`
  1035. SET
  1036. `PAIS_Destino` = null
  1037. WHERE
  1038. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  1039. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . ' AND
  1040. `PAIS_Destino` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  1041. ');
  1042. }
  1043. /**
  1044. * Unassociates all ImportacionsAsPAISDestino
  1045. * @return void
  1046. */
  1047. public function UnassociateAllImportacionsAsPAISDestino() {
  1048. if ((is_null($this->intIdPAIS)))
  1049. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this unsaved Pais.');
  1050. // Get the Database Object for this Class
  1051. $objDatabase = Pais::GetDatabase();
  1052. // Perform the SQL Query
  1053. $objDatabase->NonQuery('
  1054. UPDATE
  1055. `IMPORTACION`
  1056. SET
  1057. `PAIS_Destino` = null
  1058. WHERE
  1059. `PAIS_Destino` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  1060. ');
  1061. }
  1062. /**
  1063. * Deletes an associated ImportacionAsPAISDestino
  1064. * @param Importacion $objImportacion
  1065. * @return void
  1066. */
  1067. public function DeleteAssociatedImportacionAsPAISDestino(Importacion $objImportacion) {
  1068. if ((is_null($this->intIdPAIS)))
  1069. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this unsaved Pais.');
  1070. if ((is_null($objImportacion->TRANSPORTEIdTRANSPORTE)) || (is_null($objImportacion->LICENCIAIdLICENCIA)))
  1071. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this Pais with an unsaved Importacion.');
  1072. // Get the Database Object for this Class
  1073. $objDatabase = Pais::GetDatabase();
  1074. // Perform the SQL Query
  1075. $objDatabase->NonQuery('
  1076. DELETE FROM
  1077. `IMPORTACION`
  1078. WHERE
  1079. `TRANSPORTE_idTRANSPORTE` = ' . $objDatabase->SqlVariable($objImportacion->TRANSPORTEIdTRANSPORTE) . ' AND
  1080. `LICENCIA_idLICENCIA` = ' . $objDatabase->SqlVariable($objImportacion->LICENCIAIdLICENCIA) . ' AND
  1081. `PAIS_Destino` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  1082. ');
  1083. }
  1084. /**
  1085. * Deletes all associated ImportacionsAsPAISDestino
  1086. * @return void
  1087. */
  1088. public function DeleteAllImportacionsAsPAISDestino() {
  1089. if ((is_null($this->intIdPAIS)))
  1090. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateImportacionAsPAISDestino on this unsaved Pais.');
  1091. // Get the Database Object for this Class
  1092. $objDatabase = Pais::GetDatabase();
  1093. // Perform the SQL Query
  1094. $objDatabase->NonQuery('
  1095. DELETE FROM
  1096. `IMPORTACION`
  1097. WHERE
  1098. `PAIS_Destino` = ' . $objDatabase->SqlVariable($this->intIdPAIS) . '
  1099. ');
  1100. }
  1101. // Related Objects' Methods for ProveedorAsPAISIdPAIS
  1102. //-------------------------------------------------------------------
  1103. /**
  1104. * Gets all associated ProveedorsAsPAISIdPAIS as an array of Proveedor objects
  1105. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1106. * @return Proveedor[]
  1107. */
  1108. public function GetProveedorAsPAISIdPAISArray($objOptionalClauses = null) {
  1109. if ((is_null($this->intIdPAIS)))
  1110. return array();
  1111. try {
  1112. return Proveedor::LoadArrayByPAISIdPAIS($this->intIdPAIS, $objOptionalClauses);
  1113. } catch (QCallerException $objExc) {

Large files files are truncated, but you can click here to view the full file