3 * @desc The Abstract Data Objects series
5 * @author Marius Orcsik <marius.orcsik@gmail.com>
16 protected $id, // public to allow debugging outside the class
22 * @desc function to implement get_ | set_ virtual methods
24 * @param string $method
28 * @see http://www.ibm.com/developerworks/xml/library/os-php-flexobj/ by Jack Herrington <jherr@pobox.com>
30 function __call ( $method, $args) {
31 $diff = $this->get_members();
32 $all = get_object_vars($this);
34 if ( preg_match( '/set_(.*)/', $method, $found ) ) {
35 // check for fields with $found[1] name
36 if ( array_key_exists( $found[1], $diff) ) {
37 $this->fields
[$found[1]]->setValue($args[0]);
39 // check for obj members with $found[1] name
40 } elseif (array_key_exists( $found[1], $all)){
41 $this->$found[1] = $args[0];
44 } else if ( preg_match( '/get_(.*)/', $method, $found ) ) {
45 if ( array_key_exists( $found[1], $diff ) ) {
46 return $this->fields
[$found[1]]->getValue();
47 } elseif (array_key_exists( $found[1], $all)){
48 return $this->$found[1];
55 * @desc A function to implement a virtual getter member of the class
60 * @see http://www.ibm.com/developerworks/xml/library/os-php-flexobj/ by Jack Herrington <jherr@pobox.com>
62 function __get ( $key ) {
63 return $this->fields
[$key];
67 * @desc A function to implement a virtual setter member for this class
73 * @see http://www.ibm.com/developerworks/xml/library/os-php-flexobj/ by Jack Herrington <jherr@pobox.com>
75 function __set ( $key, $value ) {
77 array_key_exists ($key, $this->get_members()) /*&&
78 $this->isValidMember($this->fields[$key])*/
80 $this->fields
[$key]->set_value ($value);
83 $this->fields
[$key] = new tdoAbstractField ($key, $this->alias
);
84 $this->fields
[$key]->set_value ($value);
88 public function __construct(&$db) {
92 $this->instantiateMembers();
95 public function __destruct() {}
98 * gets the members we consider table fields
100 * @return array ('fieldName' => tdoAbstractField)
102 public function &get_members () {
103 return $this->fields
;
107 * checks if a field is a valid member of the current object
109 * @param tdoAbstractField $incMember
112 public function isValidMember ($incMember) {
114 ! ($incMember instanceof tdoAbstractField
) ||
115 // this prevents an error in php > 5.2 object comparison
116 ! in_array ($incMember, $this->get_members() /*/, true/**/)
124 * instantiating the object's members
126 public function instantiateMembers () {
127 foreach ($this->get_members() as $key => $field) {
128 if ( is_int ($key) && is_string ($field) ) {
129 $this->fields
[$field] = new tdoAbstractField ($field, $this->alias
);
131 // FIXME: this is so bad :D - it implies that the primary key must be the first field containing _id :D
132 if (stristr ($field,'_id') && !isset ($this->id
) && $this->isValidMember ($this->fields
[$field])) {
133 $this->id
= &$this->fields
[$field];
135 unset ($this->fields
[$key]);
139 $this->wheres
= array();
142 $this->refers
= array();
145 * setting the table's index field
147 * @param tdoAbstractField $obj
149 public function set_index (&$obj) {
150 if ($this->isValidMember($obj)) {
152 $this->id
->flags
= PRIMARY
;
157 * setting an alias for the table in case of joins.
158 * this method also sets the alias on all the fields of the current object
160 * @param string $alias
162 public function set_alias ($alias) {
163 foreach ($this->get_members() as $field){
164 if ($field->table
== $this->alias
) {
165 $field->table
= 't'.$alias;
168 $this->alias
= 't'.$alias;
172 * For adding custom sql functions for certain fields
174 * @param string $modif
175 * @param tdoAbstractField $field
177 public function set_fieldModifier ($modif, &$field) {
178 if ($this->isValidMember ($field) && stristr ($modif, '%'))
179 $field->set_modifier ($modif);
183 * method used in join cases to add the joined object's fields
186 * @param array ('fieldName' => tdoAbstractField) $incArr
188 public function addFields (&$incArr) {
189 if (is_array($incArr)) {
190 foreach ($incArr as $fieldName => $field) {
191 $this->fields
[$fieldName] = $field;
197 * Based on field values, we get the _first_ row in the table that matches
199 * TODO: maybe we can have a function that returns _all_ the rows that match
203 public function buildObj () {
204 $sql = $this->buildSql(1);
205 $this->db
->query( $sql );
207 $arr = $this->db
->getAssoc();
208 if (is_array($arr)) {
209 foreach ($arr as $field => $var) {
210 $this->fields
[$field]->set_value ($var);
218 * Gets the row in the table for $id
223 public function get ($id) {
224 $id = $this->db
->escape($id);
226 $this->instantiateMembers();
228 $this->id
->set_value ($id);
232 * Returns the last id of the table
233 * OBS: this assumes that we didn't delete any rows from the table.
237 public function getLastInsertedId() {
238 $sql = $this->db
->_SELECT ($this->id
->name
);
239 $sql .= $this->db
->_FROM ($this->name
);
241 $this->addOrder($this->id
, false);
242 // $orders[] = array($this->id->name, false);
244 $sql .= $this->db
->_ORDER($this->outputOrders());
247 $this->db
->query ($sql);
248 return $this->db
->getScalar();
252 * encapsulating the $this->db->escape() method
254 * @param mixed $value
257 public function escape ($value) {
258 if (is_numeric ($value)) {
261 return '"'.$this->db
->escape ($value).'"';
265 * inserting into the database
266 * TODO: multiple inserts to use with loadFromArray
270 public function insert () {
271 $sql = 'INSERT INTO '.$this->name
;
275 $f = $this->get_members();
277 foreach ($f as $fieldName => $field) {
278 if ($this->isValidMember ($field) && ($field != $this->id
) && !is_null ($field->value
)) {
279 $value = $this->escape ($field->value
);
281 $fieldStr.= (!empty ($fieldStr) ?
', ' : ' ') . $fieldName;
282 $valueStr.= (!empty ($valueStr) ?
', ' : ' ') . $value;
286 $sql.= ' ('.$fieldStr.') VALUES ('.$valueStr.')';
288 $this->db
->query($sql);
290 return $this->getLastInsertedId();
294 public function update ($id = null) {
296 $id = $this->id
->value
;
300 throw new Exception('Cannot update record in table '.$this->name
.' because an id hasn\'t been provided');
304 $sql = $this->db
->_UPDATE (array ($this->name
,$this->alias
) );
306 if (is_array ($this->refers
) && !empty ($this->refers
)){
307 $this->refers
= array_reverse ($this->refers
);
309 foreach ($this->refers
as $ref)
313 $sql .= $this->db
->_SET();
315 $fields = $this->get_members();
317 foreach ($fields as $fieldName => $field) {
318 if (($field instanceof tdoAbstractField
) && $field != $this->id
) { // TODO: make a more real check for field is an id
319 $value = $field->value
;
322 if ((isset($value) && !is_null($value))) {
323 $sql.= $field->table
.'.'.$fieldName.' = '.$this->escape ($value).', ';
327 $sql = substr ($sql, 0, -2);
329 $sql.= $this->db
->_WHERE($this->alias
.'.'.$this->id
->name
.' = '.$this->escape($id));
331 $this->db
->query($sql);
336 public function replace ( $id = null ) {
338 $id = $this->id
->value
;
340 // var_dump ($this, 'repl');die;
342 if (!isset($id) ||
!$this->idExists( $id ) ) {
343 return $this->insert ();
345 return $this->update ($id);
349 // TODO: make this the same way the find first method works
350 public function delete ($id = null) {
351 if ($id == null && empty($this->wheres
) && !empty($this->id
->value
)) {
352 $this->addWhere($this->id
, '=', $this->id
->value
);
355 if (empty($this->wheres
)) {
359 $temp = $this->alias
;
360 $this->set_alias(null);
362 // var_dump($this->wheres);die;
363 $sql = 'DELETE FROM '.$this->name
.' WHERE '; //$this->id->name.' = '.$this->escape($value).' LIMIT 1';
364 $sql.= $this->outputWheres();
365 // echo $this->outputWheres(false);die;
366 $affRows = $this->db
->query($sql);
368 $this->set_alias($temp);
372 public function reset () {
373 foreach ($this->fields
as $key => $field) {
374 if ($field instanceof tdoAbstractField
) {
375 $this->fields
[$key] = new tdoAbstractField($key, $this->alias
);
379 $this->wheres
= array();
380 $this->groups
= array();
381 $this->orders
= array();
382 $this->refers
= array();
386 public function idExists ($id = null) {
388 $id = $this->id
->value
;
393 $this->id
->set_modifier ('COUNT (%s)');
395 $sql = $this->db
->_SELECT ($this->id
).
396 $this->db
->_FROM ($this->name
).
397 $this->db
->_WHERE ($this->id
->name
.' = '.$this->escape($id));
399 $this->db
->query($sql);
401 if ($this->db
->getScalar())
407 protected function outputFieldList () {
409 $f = $this->get_members();
411 foreach ($f as $fieldName => $field) {
412 if ($this->isValidMember ($field)) {
414 if (!is_null ($field->modifier
)) {
415 // i replaced str_replace ('%s', $curField, '%s', $curField)
416 // as sometimes I might need it for something else than %s
417 $fields .= sprintf ($field->modifier
, (!is_null ($field->table
) ?
$field->table
. '.' : '') . $field->name
) .
418 $this->db
->_AS($field->name
) . ', ';
419 } elseif ( !$field->inWhere ()) {
420 $fields .= (!is_null ($field->table
) ?
$field->table
.'.' : '') . $field->name
. ', ';
423 // $fields .= $curField;
425 throw new Exception ($fieldName . ' is not a valid member of ' . get_class($this));
429 return substr ($fields,0,-2);//$fields;
432 protected function outputWheres ($bIW = true) {
433 return implode ($this->db
->_AND(), $this->wheres
);
436 protected function outputGroups () {
439 $f = $this->get_members();
440 foreach ($f as $field)
441 if (!is_null ($field->group
) )
442 $groups .= (!empty($groups) ?
', ' : '') . $field->name
;
447 protected function outputOrders () {
449 $f = $this->get_members();
450 foreach ($f as $field)
451 if (!is_null($field->order
)) {
452 $orders .= (!empty($orders) ?
', ': '').$field->name
.($field->order
== true ?
' ASC' : ' DESC');
457 protected function outputRefers () {
460 if (is_array($this->refers
) && !empty($this->refers
)){
461 $this->refers
= array_reverse($this->refers
);
462 foreach ($this->refers
as $ref)
469 protected function buildInherentWheres () {
470 $diff = $this->get_members();
471 // let's hope this doesn't break stuff.
472 // it's needed when we use more queries on the same instance of the object :D
474 if (is_array ($diff)) {
475 foreach ($diff as $fieldName => $field) {
476 if ( $this->isValidMember ($field) && $field->value
!= null) {
477 $this->addWhere ($field, '=', $this->escape($field->value
));
479 // throw new Exception($fieldName . ' is not a valid member of ' . get_class($this));
484 if (empty($this->wheres
)) {
486 $this->wheres
[] = new tdoAbstractClause($t);
489 // var_dump($this->wheres);
492 * function to add an abstract clause to the current object if it doesn't exist
494 * @param tdoAbstractField|tdoAbstractClause $field1
495 * @param string $condition
496 * @param string $field2
498 public function addWhere (&$field1, $condition = null, $field2 = null) {
499 if (($field1 instanceof tdoAbstractClause
) && ($condition == null ||
$field2 == null)) {
502 $w = new tdoAbstractClause ($field1, $condition, $field2);
504 // this might generate an infinite recursion error on some PHP > 5.2 due to object comparison
505 if (!in_array ($w, $this->wheres
/*, true */))
506 $this->wheres
[] = &$w;
509 public function addOrder (&$orderField, $asc = true) {
510 if (!($orderField instanceof tdoAbstractField
) && is_string ($orderField)) {
511 $orderField = &$this->fields
[$orderField];
513 if ($this->isValidMember ($orderField))
514 $orderField->set_order ($asc);
517 public function addGroup (&$groupField) {
518 if (!($groupField instanceof tdoAbstractField
) && is_string ($groupField)) {
519 $groupField = &$this->fields
[$groupField];
521 if (($groupField instanceof tdoAbstractField
)) {
522 $groupField->set_group (true);
527 * building a normal SELECT query
533 private function buildSql($start = 0, $end = 0) {
534 $sql = $this->db
->_SELECT($this->outputFieldList()). ' FROM '.$this->name
.' AS '.$this->alias
.' ';
536 $this->buildInherentWheres(); // will it work
538 $sql .= $this->outputRefers();
540 $sql .= $this->db
->_WHERE($this->outputWheres());// add LIMITS
542 $sql .= $this->db
->_GROUP($this->outputGroups());
544 $sql .= $this->db
->_ORDER($this->outputOrders());
547 $sql .= $this->db
->_LIMIT($start, $end);
552 public function find ($start = 0, $count = 0) {
553 $result = $this->db
->query ($this->buildSql(), $start, $count);
557 public function findFirst () {
558 $this->buildInherentWheres();
560 $this->db
->query($this->buildSql(), 0, 1);
561 $row = $this->db
->getAssoc();
563 foreach ($row as $field => $value){
564 $this->fields
[$field]->value
= $value;
568 public function getArray ($start = 0, $count = 0, $orderBy = null) {
569 $this->buildInherentWheres ();
571 $sql = $this->buildSql ($start, $count, $orderBy);
573 $this->db
->query ($sql);
574 return $this->db
->getArray();
577 public function getCount() {
578 $this->set_fieldModifier('COUNT(%s)', $this->id
);
579 $this->db
->query($this->buildSql());
580 return $this->db
->getScalar();
583 public function getVector() {
584 // I really don't see why we need this. ?
588 * Function to load the values of current object from an array
589 * of type field_name => field_value
590 * If strict is false, the current object can have fields that are not already
591 * present in $this->fields[]
593 * @param array $valArray
594 * @param bool $strict
596 public function loadFromArray ($valArray, $strict = true) {
597 foreach ($valArray as $fieldName => $value) {
598 if (array_key_exists ($fieldName, $this->fields
)) {
599 $this->fields
[$fieldName]->set_value($value);
600 } elseif (!strinct
) {
601 // if the field name is not in the field list of the current object
602 // it means that the valArray object is got from an JOIN sql
603 $this->fields
[$fieldName] = new tdoAbstractField($field,'j1');
604 $this->fields
[$fieldName]->set_value ($value);
610 * FIXME: make it work when composing with the same object
612 * @param tdoAbstract $incOb
615 private function composeObj ($incOb) {
616 if (!($incOb instanceof tdoAbstract
))
618 $refs = count($this->refers
);
620 foreach ($incOb->refers
as $alias => $ref) {
623 $this->refers
[$tAl] = $ref;//str_replace(array($alias, $aliases[$alias][1]), array($tAl, $aliases[$alias][2]), $ref);
624 $this->refers
[$tAl]->set_state($tAl);
629 * Function to execute a join between two tdoAbstract objects
631 * @param string $jType
632 * @param tdoAbstractField $thisJField
633 * @param tdoAbstract $incOb
634 * @param tdoAbstractField $incObJField
637 public function joinWith ($jType = null, &$thisJField = null, &$incOb = null, &$incObJField = null) {
639 !tdoAbstractJoin
::isValidType($jType) ||
640 !$this->isValidMember ($thisJField)
645 $this->composeObj ($incOb);
647 $tAl = (count($this->refers
));
649 trigger_error('Join aborted for table '.$this->name
.': Too many tables; MySQL can only use 61 tables in a join', E_USER_NOTICE
);
652 $incOb->set_alias($tAl);
654 if($thisJField == null ||
!($thisJField instanceof tdoAbstractField
))
655 $thisJField = $this->id
;
657 if($incObJField == null ||
!($incObJField instanceof tdoAbstractField
))
658 $incObJField = $incOb->id
;
660 $this->refers
[$tAl] = new tdoAbstractJoin ($jType, $this, $incOb, $thisJField, $incObJField, $tAl);
661 $this->refers
[$tAl]->set_state ($tAl);
666 * function to dump a <type>Sql
667 * problem with the field types. :D
669 * @param tdoAbstract $obj
671 static public function dumpSchema ($obj) {
672 if ($obj instanceof tdoAbstract)
673 throw new Exception('Can\'t generate sql dump');
675 $sql = 'CREATE TABLE '. $obj->name . ' (';
677 foreach ($obj->getFields() as $fieldName => $data) {
678 $sql .= $fieldName.' '.$data[0].', ';
687 * class to abstract a where clause in a SQL query
688 * TODO: add possibility of complex wheres: (t1 condition1 OR|AND|XOR t2.condition2)
689 * TODO: abstract the condition part of a where clause - currently string based :D
691 class tdoAbstractClause
{
692 protected $subject, $predicate, $predicative;
695 * initializing a WHERE|ON clause
697 * @param tdoAbstractClause|tdoAbstractField $subject
698 * @param string $predicate
699 * @param tdoAbstractClause|tdoAbstractField|null $complement
701 public function __construct ($subject, $predicate = null, $predicative = null) {
702 if ($subject == 1 && $predicate == null && $predicative == null) {
703 $this->subject
= '1';
704 $this->predicate
= '';
705 $this->predicative
= '';
709 if (($subject instanceof tdoAbstractField
) ||
($subject instanceof tdoAbstractClause
)) {
710 $this->subject
= &$subject;
712 $subject->set_where
= true;
714 $this->predicative
= &$predicative;
716 if ($this->validPredicative ($predicate))
717 $this->predicate
= $predicate;
721 $this->predicate
= '';
722 $this->predicative
= '';
727 public function __destruct () {}
729 public function __toString () {
730 // var_dump($this->subject, $this->predicate, $this->predicative);
732 if ($this->subject
instanceof tdoAbstractClause
) {
733 $subStr = (string)$this->subject
;
734 } elseif ($this->subject
instanceof tdoAbstractField
) {
735 // without $this->subject->table != 't' we have a bug in the delete op
736 $subStr = ($this->subject
->table
!= 't' ?
$this->subject
->table
.'.': '').$this->subject
->name
;
737 } elseif ($this->subject
== '1') {
738 return $this->subject
;
743 if (is_null($this->predicative
)) {
744 if ($this->validPredicative($this->predicate
)) {
748 } elseif (is_numeric($this->predicative
)) {
749 $preStr = $this->predicative
;
750 } elseif (is_string($this->predicative
)) {
751 $preStr = $this->predicative
;
753 if ($this->predicate
== 'LIKE') {
754 $preStr = '%'.$this->predicate
.'%';
757 $preStr = (stripos($preStr, '"') !== 0 ?
'"'.$preStr.'"' : $preStr);//'"'.$preStr.'"';
758 } elseif (is_array($this->predicative
)) {
759 $preStr = '("'.implode('", "',$this->predicative
).'")';
760 } elseif ($this->predicative
instanceof tdoAbstractfield
) {
761 $preStr = ($this->predicative
->table
!= 't' ?
$this->predicative
->table
.'.': '').$this->predicative
->name
;
762 } elseif ($this->predicative
instanceof tdoAbstractClause
) {
764 $preStr = $this->predicative
;
767 $retStr = $subStr.' '.$this->predicate
.' '.$preStr;
768 if (($this->subject
instanceof tdoAbstractClause
) && ($this->predicative
instanceof tdoAbstractClause
))
769 return '('.$retStr.')';
774 private function validPredicative ($predicate) {
775 // need to find a way to abstract these
776 // $validPredicates = array (
791 if ($this->predicative
instanceof tdoAbstractClause
) {
792 // we'll have Subject AND|OR|XOR Predicative
793 $validPredicates = array (
800 } elseif (($this->predicative
instanceof tdoAbstractField
) ||
is_numeric($this->predicative
)) {
801 // we'll have Subject =|!= Predicative
802 $validPredicates = array (
810 } elseif (is_array($this->predicative
)) {
811 $validPredicates = array (
815 } elseif (is_string($this->predicative
)) {
816 $validPredicates = array (
825 } elseif (is_null($this->predicative
)) {
826 $validPredicates = array (
832 return in_array($predicate, $validPredicates);
834 // if (in_array($predicate, $validPredicates) && (($predicative instanceof tdoAbstractClause) || ($predicative instanceof tdoAbstractField)))
840 class tdoAbstractJoin
{
841 static public $validTypes = array (
856 public function __construct ($type, &$lt, &$rt, &$lf, &$rf, $state) {
857 if ($rt instanceof tdoAbstract ||
858 $lt instanceof tdoAbstract
860 $this->leftTable
= &$lt;
861 $this->rightTable
= &$rt;
863 if (tdoAbstractJoin
::isValidType($type))
867 $lf instanceof tdoAbstractField
&&
868 $rf instanceof tdoAbstractField
870 $this->rightField
= &$rf;
871 $this->leftField
= &$lf;
874 $this->state
= $state;
877 $this->composeFields ();
878 $this->composeWheres ();
882 public function __destruct () {}
884 public function __toString() {
885 $lAlias = $this->leftTable
->get_alias();
886 return (string)$this->type
.' JOIN '.$this->rightTable
->get_name().
887 ' AS t'.$this->state
.' ON '.(isset($lAlias) ?
$lAlias : $this->leftTable
->get_name()).
888 '.'.$this->leftField
->name
.
889 ' = t'.$this->state
.'.'.$this->rightField
->name
.' ';
893 * Will compose the $rightTable and $leftTable fields
896 public function composeFields () {
897 $leftFields = $this->leftTable
->get_members();
899 $this->rightTable
->set_alias($this->state
);
900 $rightFields = $this->rightTable
->get_members();
903 $this->leftTable
->addFields($rightFields);
907 * Will compose the $rightTable and $leftTable WHERE clauses
910 public function composeWheres () {
911 if (!is_array($this->leftTable
->wheres
))
912 $this->leftTable
->wheres
= array();
913 if (!is_array($this->rightTable
->wheres
))
914 $this->rightTable
->wheres
= array();
916 // var_dump($this->rightTable->wheres, $this->leftTable );die;
917 foreach ($this->rightTable
->wheres
as $where) {
918 $this->leftTable
->addWhere ($where);
920 $this->leftTable
->wheres
= &array_merge($this->rightTable
->wheres
, $this->leftTable
->wheres
);
923 public function set_state ($st) {
927 static public function isValidType ($inc) {
928 if (in_array($inc, tdoAbstractJoin
::$validTypes))
935 define ('PRIMARY', 2);
936 define ('UNIQUE', 4);
937 define ('FULLTEXT', 8);
939 class tdoAbstractField
{
940 static public $validTypes = array (
950 protected $name, $type, $flags, $value, $table, $modifier = null, $order = null, $group = null, $where = false;
952 public function __construct ($incName, $incTable, $incType='INT', $incFlags=0) {
953 $this->name
= $incName;
954 $this->table
= $incTable;
955 $this->type
= $incType;
956 $this->flags
= $incFlags;
959 public function __set ( $key, $value ) {
960 if ( array_key_exists ($key, get_object_vars($this)) ) {
961 $this->$key = $value;
963 // if ($key == 'where')
966 if ( is_null ($this->type
) )
974 public function __get ( $key ) {
978 public function __call ( $method, $args) {
979 $all = get_object_vars($this);
981 if ( preg_match( '/set_(.*)/', $method, $found ) ) {
982 if (array_key_exists( $found[1], $all)){
983 $this->$found[1] = $args[0];
986 } elseif ( preg_match( '/get_(.*)/', $method, $found ) ) {
987 if (array_key_exists( $found[1], $all)){
988 return $this->$found[1];
994 public function __destruct () {}
996 public function __toString () {
997 return (string)$this->value
;
1000 // public function inWhere () {
1001 // return $this->where;
1004 static public function isValidType ($inc) {
1005 if (in_array($inc, tdoAbstractField
::$validTypes)){
1011 public function set_modifier ($modif) {
1012 // if (stristr($modif, '%'))
1013 $this->modifier
= $modif;
1016 public function set_value ($value) {
1017 $this->value
= $value;
1020 public function set_group ($true = true) {
1021 $this->group
= (bool)$true;
1024 public function set_order ($asc = true) {
1025 $this->order
= (bool)$asc;
1028 public function isIndex() {
1029 return (($this->flags
& INDEX
) == INDEX
);
1032 public function isPrimary() {
1033 return (($this->flags
& PRIMARY
) == PRIMARY
);
1036 public function isFullText() {
1037 return (($this->flags
& FULLTEXT
) == FULLTEXT
);
1039 public function isUnique () {
1040 return (($this->flags
& UNIQUE
) == UNIQUE
);
1042 public function setType () {
1043 $incValue = $this->value
;
1045 if (is_int($incValue)) {
1046 $this->type
= 'INT';
1047 } elseif (is_float($incValue)) {
1048 $this->type
= 'FLOAT';
1049 } elseif (is_string($incValue)) {
1050 if (strtotime($this->value
)){
1051 $this->type
= 'DATE';
1052 }elseif (strlen($incValue) > 255)
1053 $this->type
= 'TEXT';
1055 $this->type
= 'VARCHAR';