PageRenderTime 95ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

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