]> wagnertech.de Git - projects.git/blob - verleihnix/Verleihnix/impl/data/build/classes/propel/om/BaseMedium.php
verleihnix komplett eingescheckt
[projects.git] / verleihnix / Verleihnix / impl / data / build / classes / propel / om / BaseMedium.php
1 <?php
2
3
4 /**
5  * Base class that represents a row from the 'medium' table.
6  *
7  *
8  *
9  * @package    propel.generator.propel.om
10  */
11 abstract class BaseMedium extends BaseObject implements Persistent
12 {
13     /**
14      * Peer class name
15      */
16     const PEER = 'MediumPeer';
17
18     /**
19      * The Peer class.
20      * Instance provides a convenient way of calling static methods on a class
21      * that calling code may not be able to identify.
22      * @var        MediumPeer
23      */
24     protected static $peer;
25
26     /**
27      * The flag var to prevent infinite loop in deep copy
28      * @var       boolean
29      */
30     protected $startCopy = false;
31
32     /**
33      * The value for the id field.
34      * @var        int
35      */
36     protected $id;
37
38     /**
39      * The value for the mod field.
40      * @var        int
41      */
42     protected $mod;
43
44     /**
45      * The value for the autor field.
46      * @var        string
47      */
48     protected $autor;
49
50     /**
51      * The value for the titel field.
52      * @var        string
53      */
54     protected $titel;
55
56     /**
57      * The value for the eigentumer field.
58      * @var        string
59      */
60     protected $eigentumer;
61
62     /**
63      * The value for the zz_bei field.
64      * @var        string
65      */
66     protected $zz_bei;
67
68     /**
69      * The value for the kommentar field.
70      * @var        string
71      */
72     protected $kommentar;
73
74     /**
75      * The value for the class_key field.
76      * @var        int
77      */
78     protected $class_key;
79
80     /**
81      * Flag to prevent endless save loop, if this object is referenced
82      * by another object which falls in this transaction.
83      * @var        boolean
84      */
85     protected $alreadyInSave = false;
86
87     /**
88      * Flag to prevent endless validation loop, if this object is referenced
89      * by another object which falls in this transaction.
90      * @var        boolean
91      */
92     protected $alreadyInValidation = false;
93
94     /**
95      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
96      * @var        boolean
97      */
98     protected $alreadyInClearAllReferencesDeep = false;
99
100     /**
101      * Get the [id] column value.
102      *
103      * @return int
104      */
105     public function getId()
106     {
107
108         return $this->id;
109     }
110
111     /**
112      * Get the [mod] column value.
113      *
114      * @return int
115      */
116     public function getMod()
117     {
118
119         return $this->mod;
120     }
121
122     /**
123      * Get the [autor] column value.
124      *
125      * @return string
126      */
127     public function getAutor()
128     {
129
130         return $this->autor;
131     }
132
133     /**
134      * Get the [titel] column value.
135      *
136      * @return string
137      */
138     public function getTitel()
139     {
140
141         return $this->titel;
142     }
143
144     /**
145      * Get the [eigentumer] column value.
146      *
147      * @return string
148      */
149     public function getEigentumer()
150     {
151
152         return $this->eigentumer;
153     }
154
155     /**
156      * Get the [zz_bei] column value.
157      *
158      * @return string
159      */
160     public function getZzBei()
161     {
162
163         return $this->zz_bei;
164     }
165
166     /**
167      * Get the [kommentar] column value.
168      *
169      * @return string
170      */
171     public function getKommentar()
172     {
173
174         return $this->kommentar;
175     }
176
177     /**
178      * Get the [class_key] column value.
179      *
180      * @return int
181      */
182     public function getClassKey()
183     {
184
185         return $this->class_key;
186     }
187
188     /**
189      * Set the value of [id] column.
190      *
191      * @param  int $v new value
192      * @return Medium The current object (for fluent API support)
193      */
194     public function setId($v)
195     {
196         if ($v !== null && is_numeric($v)) {
197             $v = (int) $v;
198         }
199
200         if ($this->id !== $v) {
201             $this->id = $v;
202             $this->modifiedColumns[] = MediumPeer::ID;
203         }
204
205
206         return $this;
207     } // setId()
208
209     /**
210      * Set the value of [mod] column.
211      *
212      * @param  int $v new value
213      * @return Medium The current object (for fluent API support)
214      */
215     public function setMod($v)
216     {
217         if ($v !== null && is_numeric($v)) {
218             $v = (int) $v;
219         }
220
221         if ($this->mod !== $v) {
222             $this->mod = $v;
223             $this->modifiedColumns[] = MediumPeer::MOD;
224         }
225
226
227         return $this;
228     } // setMod()
229
230     /**
231      * Set the value of [autor] column.
232      *
233      * @param  string $v new value
234      * @return Medium The current object (for fluent API support)
235      */
236     public function setAutor($v)
237     {
238         if ($v !== null) {
239             $v = (string) $v;
240         }
241
242         if ($this->autor !== $v) {
243             $this->autor = $v;
244             $this->modifiedColumns[] = MediumPeer::AUTOR;
245         }
246
247
248         return $this;
249     } // setAutor()
250
251     /**
252      * Set the value of [titel] column.
253      *
254      * @param  string $v new value
255      * @return Medium The current object (for fluent API support)
256      */
257     public function setTitel($v)
258     {
259         if ($v !== null) {
260             $v = (string) $v;
261         }
262
263         if ($this->titel !== $v) {
264             $this->titel = $v;
265             $this->modifiedColumns[] = MediumPeer::TITEL;
266         }
267
268
269         return $this;
270     } // setTitel()
271
272     /**
273      * Set the value of [eigentumer] column.
274      *
275      * @param  string $v new value
276      * @return Medium The current object (for fluent API support)
277      */
278     public function setEigentumer($v)
279     {
280         if ($v !== null) {
281             $v = (string) $v;
282         }
283
284         if ($this->eigentumer !== $v) {
285             $this->eigentumer = $v;
286             $this->modifiedColumns[] = MediumPeer::EIGENTUMER;
287         }
288
289
290         return $this;
291     } // setEigentumer()
292
293     /**
294      * Set the value of [zz_bei] column.
295      *
296      * @param  string $v new value
297      * @return Medium The current object (for fluent API support)
298      */
299     public function setZzBei($v)
300     {
301         if ($v !== null) {
302             $v = (string) $v;
303         }
304
305         if ($this->zz_bei !== $v) {
306             $this->zz_bei = $v;
307             $this->modifiedColumns[] = MediumPeer::ZZ_BEI;
308         }
309
310
311         return $this;
312     } // setZzBei()
313
314     /**
315      * Set the value of [kommentar] column.
316      *
317      * @param  string $v new value
318      * @return Medium The current object (for fluent API support)
319      */
320     public function setKommentar($v)
321     {
322         if ($v !== null) {
323             $v = (string) $v;
324         }
325
326         if ($this->kommentar !== $v) {
327             $this->kommentar = $v;
328             $this->modifiedColumns[] = MediumPeer::KOMMENTAR;
329         }
330
331
332         return $this;
333     } // setKommentar()
334
335     /**
336      * Set the value of [class_key] column.
337      *
338      * @param  int $v new value
339      * @return Medium The current object (for fluent API support)
340      */
341     public function setClassKey($v)
342     {
343         if ($v !== null && is_numeric($v)) {
344             $v = (int) $v;
345         }
346
347         if ($this->class_key !== $v) {
348             $this->class_key = $v;
349             $this->modifiedColumns[] = MediumPeer::CLASS_KEY;
350         }
351
352
353         return $this;
354     } // setClassKey()
355
356     /**
357      * Indicates whether the columns in this object are only set to default values.
358      *
359      * This method can be used in conjunction with isModified() to indicate whether an object is both
360      * modified _and_ has some values set which are non-default.
361      *
362      * @return boolean Whether the columns in this object are only been set with default values.
363      */
364     public function hasOnlyDefaultValues()
365     {
366         // otherwise, everything was equal, so return true
367         return true;
368     } // hasOnlyDefaultValues()
369
370     /**
371      * Hydrates (populates) the object variables with values from the database resultset.
372      *
373      * An offset (0-based "start column") is specified so that objects can be hydrated
374      * with a subset of the columns in the resultset rows.  This is needed, for example,
375      * for results of JOIN queries where the resultset row includes columns from two or
376      * more tables.
377      *
378      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
379      * @param int $startcol 0-based offset column which indicates which resultset column to start with.
380      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
381      * @return int             next starting column
382      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
383      */
384     public function hydrate($row, $startcol = 0, $rehydrate = false)
385     {
386         try {
387
388             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
389             $this->mod = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
390             $this->autor = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
391             $this->titel = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
392             $this->eigentumer = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
393             $this->zz_bei = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
394             $this->kommentar = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
395             $this->class_key = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
396             $this->resetModified();
397
398             $this->setNew(false);
399
400             if ($rehydrate) {
401                 $this->ensureConsistency();
402             }
403             $this->postHydrate($row, $startcol, $rehydrate);
404
405             return $startcol + 8; // 8 = MediumPeer::NUM_HYDRATE_COLUMNS.
406
407         } catch (Exception $e) {
408             throw new PropelException("Error populating Medium object", $e);
409         }
410     }
411
412     /**
413      * Checks and repairs the internal consistency of the object.
414      *
415      * This method is executed after an already-instantiated object is re-hydrated
416      * from the database.  It exists to check any foreign keys to make sure that
417      * the objects related to the current object are correct based on foreign key.
418      *
419      * You can override this method in the stub class, but you should always invoke
420      * the base method from the overridden method (i.e. parent::ensureConsistency()),
421      * in case your model changes.
422      *
423      * @throws PropelException
424      */
425     public function ensureConsistency()
426     {
427
428     } // ensureConsistency
429
430     /**
431      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
432      *
433      * This will only work if the object has been saved and has a valid primary key set.
434      *
435      * @param boolean $deep (optional) Whether to also de-associated any related objects.
436      * @param PropelPDO $con (optional) The PropelPDO connection to use.
437      * @return void
438      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
439      */
440     public function reload($deep = false, PropelPDO $con = null)
441     {
442         if ($this->isDeleted()) {
443             throw new PropelException("Cannot reload a deleted object.");
444         }
445
446         if ($this->isNew()) {
447             throw new PropelException("Cannot reload an unsaved object.");
448         }
449
450         if ($con === null) {
451             $con = Propel::getConnection(MediumPeer::DATABASE_NAME, Propel::CONNECTION_READ);
452         }
453
454         // We don't need to alter the object instance pool; we're just modifying this instance
455         // already in the pool.
456
457         $stmt = MediumPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
458         $row = $stmt->fetch(PDO::FETCH_NUM);
459         $stmt->closeCursor();
460         if (!$row) {
461             throw new PropelException('Cannot find matching row in the database to reload object values.');
462         }
463         $this->hydrate($row, 0, true); // rehydrate
464
465         if ($deep) {  // also de-associate any related objects?
466
467         } // if (deep)
468     }
469
470     /**
471      * Removes this object from datastore and sets delete attribute.
472      *
473      * @param PropelPDO $con
474      * @return void
475      * @throws PropelException
476      * @throws Exception
477      * @see        BaseObject::setDeleted()
478      * @see        BaseObject::isDeleted()
479      */
480     public function delete(PropelPDO $con = null)
481     {
482         if ($this->isDeleted()) {
483             throw new PropelException("This object has already been deleted.");
484         }
485
486         if ($con === null) {
487             $con = Propel::getConnection(MediumPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
488         }
489
490         $con->beginTransaction();
491         try {
492             $deleteQuery = MediumQuery::create()
493                 ->filterByPrimaryKey($this->getPrimaryKey());
494             $ret = $this->preDelete($con);
495             if ($ret) {
496                 $deleteQuery->delete($con);
497                 $this->postDelete($con);
498                 $con->commit();
499                 $this->setDeleted(true);
500             } else {
501                 $con->commit();
502             }
503         } catch (Exception $e) {
504             $con->rollBack();
505             throw $e;
506         }
507     }
508
509     /**
510      * Persists this object to the database.
511      *
512      * If the object is new, it inserts it; otherwise an update is performed.
513      * All modified related objects will also be persisted in the doSave()
514      * method.  This method wraps all precipitate database operations in a
515      * single transaction.
516      *
517      * @param PropelPDO $con
518      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
519      * @throws PropelException
520      * @throws Exception
521      * @see        doSave()
522      */
523     public function save(PropelPDO $con = null)
524     {
525         if ($this->isDeleted()) {
526             throw new PropelException("You cannot save an object that has been deleted.");
527         }
528
529         if ($con === null) {
530             $con = Propel::getConnection(MediumPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
531         }
532
533         $con->beginTransaction();
534         $isInsert = $this->isNew();
535         try {
536             $ret = $this->preSave($con);
537             if ($isInsert) {
538                 $ret = $ret && $this->preInsert($con);
539             } else {
540                 $ret = $ret && $this->preUpdate($con);
541             }
542             if ($ret) {
543                 $affectedRows = $this->doSave($con);
544                 if ($isInsert) {
545                     $this->postInsert($con);
546                 } else {
547                     $this->postUpdate($con);
548                 }
549                 $this->postSave($con);
550                 MediumPeer::addInstanceToPool($this);
551             } else {
552                 $affectedRows = 0;
553             }
554             $con->commit();
555
556             return $affectedRows;
557         } catch (Exception $e) {
558             $con->rollBack();
559             throw $e;
560         }
561     }
562
563     /**
564      * Performs the work of inserting or updating the row in the database.
565      *
566      * If the object is new, it inserts it; otherwise an update is performed.
567      * All related objects are also updated in this method.
568      *
569      * @param PropelPDO $con
570      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
571      * @throws PropelException
572      * @see        save()
573      */
574     protected function doSave(PropelPDO $con)
575     {
576         $affectedRows = 0; // initialize var to track total num of affected rows
577         if (!$this->alreadyInSave) {
578             $this->alreadyInSave = true;
579
580             if ($this->isNew() || $this->isModified()) {
581                 // persist changes
582                 if ($this->isNew()) {
583                     $this->doInsert($con);
584                 } else {
585                     $this->doUpdate($con);
586                 }
587                 $affectedRows += 1;
588                 $this->resetModified();
589             }
590
591             $this->alreadyInSave = false;
592
593         }
594
595         return $affectedRows;
596     } // doSave()
597
598     /**
599      * Insert the row in the database.
600      *
601      * @param PropelPDO $con
602      *
603      * @throws PropelException
604      * @see        doSave()
605      */
606     protected function doInsert(PropelPDO $con)
607     {
608         $modifiedColumns = array();
609         $index = 0;
610
611         $this->modifiedColumns[] = MediumPeer::ID;
612         if (null !== $this->id) {
613             throw new PropelException('Cannot insert a value for auto-increment primary key (' . MediumPeer::ID . ')');
614         }
615
616          // check the columns in natural order for more readable SQL queries
617         if ($this->isColumnModified(MediumPeer::ID)) {
618             $modifiedColumns[':p' . $index++]  = '`id`';
619         }
620         if ($this->isColumnModified(MediumPeer::MOD)) {
621             $modifiedColumns[':p' . $index++]  = '`mod`';
622         }
623         if ($this->isColumnModified(MediumPeer::AUTOR)) {
624             $modifiedColumns[':p' . $index++]  = '`autor`';
625         }
626         if ($this->isColumnModified(MediumPeer::TITEL)) {
627             $modifiedColumns[':p' . $index++]  = '`titel`';
628         }
629         if ($this->isColumnModified(MediumPeer::EIGENTUMER)) {
630             $modifiedColumns[':p' . $index++]  = '`eigentumer`';
631         }
632         if ($this->isColumnModified(MediumPeer::ZZ_BEI)) {
633             $modifiedColumns[':p' . $index++]  = '`zz_bei`';
634         }
635         if ($this->isColumnModified(MediumPeer::KOMMENTAR)) {
636             $modifiedColumns[':p' . $index++]  = '`kommentar`';
637         }
638         if ($this->isColumnModified(MediumPeer::CLASS_KEY)) {
639             $modifiedColumns[':p' . $index++]  = '`class_key`';
640         }
641
642         $sql = sprintf(
643             'INSERT INTO `medium` (%s) VALUES (%s)',
644             implode(', ', $modifiedColumns),
645             implode(', ', array_keys($modifiedColumns))
646         );
647
648         try {
649             $stmt = $con->prepare($sql);
650             foreach ($modifiedColumns as $identifier => $columnName) {
651                 switch ($columnName) {
652                     case '`id`':
653                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
654                         break;
655                     case '`mod`':
656                         $stmt->bindValue($identifier, $this->mod, PDO::PARAM_INT);
657                         break;
658                     case '`autor`':
659                         $stmt->bindValue($identifier, $this->autor, PDO::PARAM_STR);
660                         break;
661                     case '`titel`':
662                         $stmt->bindValue($identifier, $this->titel, PDO::PARAM_STR);
663                         break;
664                     case '`eigentumer`':
665                         $stmt->bindValue($identifier, $this->eigentumer, PDO::PARAM_STR);
666                         break;
667                     case '`zz_bei`':
668                         $stmt->bindValue($identifier, $this->zz_bei, PDO::PARAM_STR);
669                         break;
670                     case '`kommentar`':
671                         $stmt->bindValue($identifier, $this->kommentar, PDO::PARAM_STR);
672                         break;
673                     case '`class_key`':
674                         $stmt->bindValue($identifier, $this->class_key, PDO::PARAM_INT);
675                         break;
676                 }
677             }
678             $stmt->execute();
679         } catch (Exception $e) {
680             Propel::log($e->getMessage(), Propel::LOG_ERR);
681             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
682         }
683
684         try {
685             $pk = $con->lastInsertId();
686         } catch (Exception $e) {
687             throw new PropelException('Unable to get autoincrement id.', $e);
688         }
689         $this->setId($pk);
690
691         $this->setNew(false);
692     }
693
694     /**
695      * Update the row in the database.
696      *
697      * @param PropelPDO $con
698      *
699      * @see        doSave()
700      */
701     protected function doUpdate(PropelPDO $con)
702     {
703         $selectCriteria = $this->buildPkeyCriteria();
704         $valuesCriteria = $this->buildCriteria();
705         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
706     }
707
708     /**
709      * Array of ValidationFailed objects.
710      * @var        array ValidationFailed[]
711      */
712     protected $validationFailures = array();
713
714     /**
715      * Gets any ValidationFailed objects that resulted from last call to validate().
716      *
717      *
718      * @return array ValidationFailed[]
719      * @see        validate()
720      */
721     public function getValidationFailures()
722     {
723         return $this->validationFailures;
724     }
725
726     /**
727      * Validates the objects modified field values and all objects related to this table.
728      *
729      * If $columns is either a column name or an array of column names
730      * only those columns are validated.
731      *
732      * @param mixed $columns Column name or an array of column names.
733      * @return boolean Whether all columns pass validation.
734      * @see        doValidate()
735      * @see        getValidationFailures()
736      */
737     public function validate($columns = null)
738     {
739         $res = $this->doValidate($columns);
740         if ($res === true) {
741             $this->validationFailures = array();
742
743             return true;
744         }
745
746         $this->validationFailures = $res;
747
748         return false;
749     }
750
751     /**
752      * This function performs the validation work for complex object models.
753      *
754      * In addition to checking the current object, all related objects will
755      * also be validated.  If all pass then <code>true</code> is returned; otherwise
756      * an aggregated array of ValidationFailed objects will be returned.
757      *
758      * @param array $columns Array of column names to validate.
759      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise.
760      */
761     protected function doValidate($columns = null)
762     {
763         if (!$this->alreadyInValidation) {
764             $this->alreadyInValidation = true;
765             $retval = null;
766
767             $failureMap = array();
768
769
770             if (($retval = MediumPeer::doValidate($this, $columns)) !== true) {
771                 $failureMap = array_merge($failureMap, $retval);
772             }
773
774
775
776             $this->alreadyInValidation = false;
777         }
778
779         return (!empty($failureMap) ? $failureMap : true);
780     }
781
782     /**
783      * Retrieves a field from the object by name passed in as a string.
784      *
785      * @param string $name name
786      * @param string $type The type of fieldname the $name is of:
787      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
788      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
789      *               Defaults to BasePeer::TYPE_PHPNAME
790      * @return mixed Value of field.
791      */
792     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
793     {
794         $pos = MediumPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
795         $field = $this->getByPosition($pos);
796
797         return $field;
798     }
799
800     /**
801      * Retrieves a field from the object by Position as specified in the xml schema.
802      * Zero-based.
803      *
804      * @param int $pos position in xml schema
805      * @return mixed Value of field at $pos
806      */
807     public function getByPosition($pos)
808     {
809         switch ($pos) {
810             case 0:
811                 return $this->getId();
812                 break;
813             case 1:
814                 return $this->getMod();
815                 break;
816             case 2:
817                 return $this->getAutor();
818                 break;
819             case 3:
820                 return $this->getTitel();
821                 break;
822             case 4:
823                 return $this->getEigentumer();
824                 break;
825             case 5:
826                 return $this->getZzBei();
827                 break;
828             case 6:
829                 return $this->getKommentar();
830                 break;
831             case 7:
832                 return $this->getClassKey();
833                 break;
834             default:
835                 return null;
836                 break;
837         } // switch()
838     }
839
840     /**
841      * Exports the object as an array.
842      *
843      * You can specify the key type of the array by passing one of the class
844      * type constants.
845      *
846      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
847      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
848      *                    Defaults to BasePeer::TYPE_PHPNAME.
849      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
850      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
851      *
852      * @return array an associative array containing the field names (as keys) and field values
853      */
854     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array())
855     {
856         if (isset($alreadyDumpedObjects['Medium'][$this->getPrimaryKey()])) {
857             return '*RECURSION*';
858         }
859         $alreadyDumpedObjects['Medium'][$this->getPrimaryKey()] = true;
860         $keys = MediumPeer::getFieldNames($keyType);
861         $result = array(
862             $keys[0] => $this->getId(),
863             $keys[1] => $this->getMod(),
864             $keys[2] => $this->getAutor(),
865             $keys[3] => $this->getTitel(),
866             $keys[4] => $this->getEigentumer(),
867             $keys[5] => $this->getZzBei(),
868             $keys[6] => $this->getKommentar(),
869             $keys[7] => $this->getClassKey(),
870         );
871         $virtualColumns = $this->virtualColumns;
872         foreach ($virtualColumns as $key => $virtualColumn) {
873             $result[$key] = $virtualColumn;
874         }
875
876
877         return $result;
878     }
879
880     /**
881      * Sets a field from the object by name passed in as a string.
882      *
883      * @param string $name peer name
884      * @param mixed $value field value
885      * @param string $type The type of fieldname the $name is of:
886      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
887      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
888      *                     Defaults to BasePeer::TYPE_PHPNAME
889      * @return void
890      */
891     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
892     {
893         $pos = MediumPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
894
895         $this->setByPosition($pos, $value);
896     }
897
898     /**
899      * Sets a field from the object by Position as specified in the xml schema.
900      * Zero-based.
901      *
902      * @param int $pos position in xml schema
903      * @param mixed $value field value
904      * @return void
905      */
906     public function setByPosition($pos, $value)
907     {
908         switch ($pos) {
909             case 0:
910                 $this->setId($value);
911                 break;
912             case 1:
913                 $this->setMod($value);
914                 break;
915             case 2:
916                 $this->setAutor($value);
917                 break;
918             case 3:
919                 $this->setTitel($value);
920                 break;
921             case 4:
922                 $this->setEigentumer($value);
923                 break;
924             case 5:
925                 $this->setZzBei($value);
926                 break;
927             case 6:
928                 $this->setKommentar($value);
929                 break;
930             case 7:
931                 $this->setClassKey($value);
932                 break;
933         } // switch()
934     }
935
936     /**
937      * Populates the object using an array.
938      *
939      * This is particularly useful when populating an object from one of the
940      * request arrays (e.g. $_POST).  This method goes through the column
941      * names, checking to see whether a matching key exists in populated
942      * array. If so the setByName() method is called for that column.
943      *
944      * You can specify the key type of the array by additionally passing one
945      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
946      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
947      * The default key type is the column's BasePeer::TYPE_PHPNAME
948      *
949      * @param array  $arr     An array to populate the object from.
950      * @param string $keyType The type of keys the array uses.
951      * @return void
952      */
953     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
954     {
955         $keys = MediumPeer::getFieldNames($keyType);
956
957         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
958         if (array_key_exists($keys[1], $arr)) $this->setMod($arr[$keys[1]]);
959         if (array_key_exists($keys[2], $arr)) $this->setAutor($arr[$keys[2]]);
960         if (array_key_exists($keys[3], $arr)) $this->setTitel($arr[$keys[3]]);
961         if (array_key_exists($keys[4], $arr)) $this->setEigentumer($arr[$keys[4]]);
962         if (array_key_exists($keys[5], $arr)) $this->setZzBei($arr[$keys[5]]);
963         if (array_key_exists($keys[6], $arr)) $this->setKommentar($arr[$keys[6]]);
964         if (array_key_exists($keys[7], $arr)) $this->setClassKey($arr[$keys[7]]);
965     }
966
967     /**
968      * Build a Criteria object containing the values of all modified columns in this object.
969      *
970      * @return Criteria The Criteria object containing all modified values.
971      */
972     public function buildCriteria()
973     {
974         $criteria = new Criteria(MediumPeer::DATABASE_NAME);
975
976         if ($this->isColumnModified(MediumPeer::ID)) $criteria->add(MediumPeer::ID, $this->id);
977         if ($this->isColumnModified(MediumPeer::MOD)) $criteria->add(MediumPeer::MOD, $this->mod);
978         if ($this->isColumnModified(MediumPeer::AUTOR)) $criteria->add(MediumPeer::AUTOR, $this->autor);
979         if ($this->isColumnModified(MediumPeer::TITEL)) $criteria->add(MediumPeer::TITEL, $this->titel);
980         if ($this->isColumnModified(MediumPeer::EIGENTUMER)) $criteria->add(MediumPeer::EIGENTUMER, $this->eigentumer);
981         if ($this->isColumnModified(MediumPeer::ZZ_BEI)) $criteria->add(MediumPeer::ZZ_BEI, $this->zz_bei);
982         if ($this->isColumnModified(MediumPeer::KOMMENTAR)) $criteria->add(MediumPeer::KOMMENTAR, $this->kommentar);
983         if ($this->isColumnModified(MediumPeer::CLASS_KEY)) $criteria->add(MediumPeer::CLASS_KEY, $this->class_key);
984
985         return $criteria;
986     }
987
988     /**
989      * Builds a Criteria object containing the primary key for this object.
990      *
991      * Unlike buildCriteria() this method includes the primary key values regardless
992      * of whether or not they have been modified.
993      *
994      * @return Criteria The Criteria object containing value(s) for primary key(s).
995      */
996     public function buildPkeyCriteria()
997     {
998         $criteria = new Criteria(MediumPeer::DATABASE_NAME);
999         $criteria->add(MediumPeer::ID, $this->id);
1000
1001         return $criteria;
1002     }
1003
1004     /**
1005      * Returns the primary key for this object (row).
1006      * @return int
1007      */
1008     public function getPrimaryKey()
1009     {
1010         return $this->getId();
1011     }
1012
1013     /**
1014      * Generic method to set the primary key (id column).
1015      *
1016      * @param  int $key Primary key.
1017      * @return void
1018      */
1019     public function setPrimaryKey($key)
1020     {
1021         $this->setId($key);
1022     }
1023
1024     /**
1025      * Returns true if the primary key for this object is null.
1026      * @return boolean
1027      */
1028     public function isPrimaryKeyNull()
1029     {
1030
1031         return null === $this->getId();
1032     }
1033
1034     /**
1035      * Sets contents of passed object to values from current object.
1036      *
1037      * If desired, this method can also make copies of all associated (fkey referrers)
1038      * objects.
1039      *
1040      * @param object $copyObj An object of Medium (or compatible) type.
1041      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1042      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1043      * @throws PropelException
1044      */
1045     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1046     {
1047         $copyObj->setMod($this->getMod());
1048         $copyObj->setAutor($this->getAutor());
1049         $copyObj->setTitel($this->getTitel());
1050         $copyObj->setEigentumer($this->getEigentumer());
1051         $copyObj->setZzBei($this->getZzBei());
1052         $copyObj->setKommentar($this->getKommentar());
1053         $copyObj->setClassKey($this->getClassKey());
1054         if ($makeNew) {
1055             $copyObj->setNew(true);
1056             $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1057         }
1058     }
1059
1060     /**
1061      * Makes a copy of this object that will be inserted as a new row in table when saved.
1062      * It creates a new object filling in the simple attributes, but skipping any primary
1063      * keys that are defined for the table.
1064      *
1065      * If desired, this method can also make copies of all associated (fkey referrers)
1066      * objects.
1067      *
1068      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1069      * @return Medium Clone of current object.
1070      * @throws PropelException
1071      */
1072     public function copy($deepCopy = false)
1073     {
1074         // we use get_class(), because this might be a subclass
1075         $clazz = get_class($this);
1076         $copyObj = new $clazz();
1077         $this->copyInto($copyObj, $deepCopy);
1078
1079         return $copyObj;
1080     }
1081
1082     /**
1083      * Returns a peer instance associated with this om.
1084      *
1085      * Since Peer classes are not to have any instance attributes, this method returns the
1086      * same instance for all member of this class. The method could therefore
1087      * be static, but this would prevent one from overriding the behavior.
1088      *
1089      * @return MediumPeer
1090      */
1091     public function getPeer()
1092     {
1093         if (self::$peer === null) {
1094             self::$peer = new MediumPeer();
1095         }
1096
1097         return self::$peer;
1098     }
1099
1100     /**
1101      * Clears the current object and sets all attributes to their default values
1102      */
1103     public function clear()
1104     {
1105         $this->id = null;
1106         $this->mod = null;
1107         $this->autor = null;
1108         $this->titel = null;
1109         $this->eigentumer = null;
1110         $this->zz_bei = null;
1111         $this->kommentar = null;
1112         $this->class_key = null;
1113         $this->alreadyInSave = false;
1114         $this->alreadyInValidation = false;
1115         $this->alreadyInClearAllReferencesDeep = false;
1116         $this->clearAllReferences();
1117         $this->resetModified();
1118         $this->setNew(true);
1119         $this->setDeleted(false);
1120     }
1121
1122     /**
1123      * Resets all references to other model objects or collections of model objects.
1124      *
1125      * This method is a user-space workaround for PHP's inability to garbage collect
1126      * objects with circular references (even in PHP 5.3). This is currently necessary
1127      * when using Propel in certain daemon or large-volume/high-memory operations.
1128      *
1129      * @param boolean $deep Whether to also clear the references on all referrer objects.
1130      */
1131     public function clearAllReferences($deep = false)
1132     {
1133         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
1134             $this->alreadyInClearAllReferencesDeep = true;
1135
1136             $this->alreadyInClearAllReferencesDeep = false;
1137         } // if ($deep)
1138
1139     }
1140
1141     /**
1142      * return the string representation of this object
1143      *
1144      * @return string
1145      */
1146     public function __toString()
1147     {
1148         return (string) $this->exportTo(MediumPeer::DEFAULT_STRING_FORMAT);
1149     }
1150
1151     /**
1152      * return true is the object is in saving state
1153      *
1154      * @return boolean
1155      */
1156     public function isAlreadyInSave()
1157     {
1158         return $this->alreadyInSave;
1159     }
1160
1161 }