/** * Converts a XML description of a SQL column into a full SQL type * * <column name="_rate" nametype="namesuffix" type="sql:decimal(16,8)" unsigned="true" null="true" default="NULL" auto_increment="100" /> * * Returns: $fulltype: 'decimal(16,8) unsigned NULL DEFAULT NULL' * @access private * * @param CBSimpleXMLElement $column * @return string|boolean Full SQL creation type or FALSE in case of error */ function _fullColumnType(&$column) { $fullType = false; if ($column->name() == 'column') { // $colName = $column->attributes( 'name' ); // $colNameType = $column->attributes( 'nametype' ); // if ( $colNameType == 'namesuffix' ) { // $colName = $colNamePrefix . $colName; // } $type = $column->attributes('type'); $unsigned = $column->attributes('unsigned'); $null = $column->attributes('null'); $default = $column->attributes('default'); $auto_increment = $column->attributes('auto_increment'); if (cbStartOfStringMatch($type, 'sql:')) { $type = trim(substr($type, 4)); // remove 'sql:' if ($type) { $notQuoted = array('int', 'float', 'tinyint', 'bigint', 'decimal', 'boolean', 'bit', 'serial', 'smallint', 'mediumint', 'double', 'year'); $isInt = false; foreach ($notQuoted as $n) { if (cbStartOfStringMatch($type, $n)) { $isInt = true; break; } } $fullType = $type; if ($unsigned == 'true') { $fullType .= ' unsigned'; } if ($null !== 'true') { $fullType .= ' NOT NULL'; } if (!in_array($type, array('text', 'blob', 'tinytext', 'mediumtext', 'longtext', 'tinyblob', 'mediumblob', 'longblob'))) { // BLOB and TEXT columns cannot have DEFAULT values. http://dev.mysql.com/doc/refman/5.0/en/blob.html if ($default !== null) { $fullType .= ' DEFAULT ' . ($isInt || $default === 'NULL' ? $default : $this->_db->Quote($default)); } elseif (!$auto_increment) { // MySQL 5.0.51a and b have a bug: they need a default value always to be able to return it correctly in SHOW COLUMNS FROM ...: if ($null === 'true') { $default = 'NULL'; } elseif ($isInt) { $default = 0; } elseif (in_array($type, array('datetime', 'date', 'time'))) { $default = $this->_db->getNullDate($type); } else { $default = ''; } $fullType .= ' DEFAULT ' . ($isInt || $default === 'NULL' ? $default : $this->_db->Quote($default)); } } if ($auto_increment) { $fullType .= ' auto_increment'; } } } } return $fullType; }
function checkin( $oid = null ) { if ( ! array_key_exists( 'checked_out', get_class_vars( strtolower( get_class( $this ) ) ) ) ) { $this->_error = "WARNING: " . strtolower( get_class( $this ) ) . " does not support checkins."; return false; } $k = $this->_tbl_key; if ( $oid !== null ) { $this->$k = $oid; } $query = "UPDATE " . $this->_db->NameQuote( $this->_tbl ) . "\n SET checked_out = 0, checked_out_time = " . $this->_db->Quote( $this->_db->getNullDate() ) . "\n WHERE " . $this->_db->NameQuote( $this->_tbl_key ) . " = " . $this->_db->Quote( $this->$k ) ; $this->_db->setQuery( $query ); return $this->_db->query(); }