|
Adodb Dokumentation
V5.14 8 Sept 2011
|

Öffentliche Methoden | |
| GetCommentSQL ($table, $col) | |
| in other words, we use a text area for editting. | |
| SetCommentSQL ($table, $col, $cmt) | |
| MetaTables () | |
| MetaColumns ($tab, $upper=true, $schema=false) | |
| MetaPrimaryKeys ($tab, $owner=false, $intkey=false) | |
| MetaIndexes ($table, $primary=false, $owner=false) | |
| MetaType ($t, $len=-1, $fieldobj=false) | |
| NameQuote ($name=NULL, $allowBrackets=false) | |
| TableName ($name) | |
| ExecuteSQLArray ($sql, $continueOnError=true) | |
| ActualType ($meta) | |
| CreateDatabase ($dbname, $options=false) | |
| CreateIndexSQL ($idxname, $tabname, $flds, $idxoptions=false) | |
| DropIndexSQL ($idxname, $tabname=NULL) | |
| SetSchema ($schema) | |
| AddColumnSQL ($tabname, $flds) | |
| AlterColumnSQL ($tabname, $flds, $tableflds='', $tableoptions='') | |
| RenameColumnSQL ($tabname, $oldcolumn, $newcolumn, $flds='') | |
| DropColumnSQL ($tabname, $flds, $tableflds='', $tableoptions='') | |
| DropTableSQL ($tabname) | |
| RenameTableSQL ($tabname, $newname) | |
| CreateTableSQL ($tabname, $flds, $tableoptions=array()) | |
| _GenFields ($flds, $widespacing=false) | |
| _GetSize ($ftype, $ty, $fsize, $fprec) | |
| _CreateSuffix ($fname, &$ftype, $fnotnull, $fdefault, $fautoinc, $fconstraint, $funsigned) | |
| _IndexSQL ($idxname, $tabname, $flds, $idxoptions) | |
| _DropAutoIncrement ($tabname) | |
| _TableSQL ($tabname, $lines, $pkey, $tableoptions) | |
| _Triggers ($tabname, $taboptions) | |
| _Options ($opts) | |
| _getSizePrec ($size) | |
| ChangeTableSQL ($tablename, $flds, $tableoptions=false, $dropOldFlds=false) | |
Datenfelder | |
| $connection | |
| $debug = false | |
| $dropTable = 'DROP TABLE %s' | |
| $renameTable = 'RENAME TABLE %s TO %s' | |
| $dropIndex = 'DROP INDEX %s' | |
| $addCol = ' ADD' | |
| $alterCol = ' ALTER COLUMN' | |
| $dropCol = ' DROP COLUMN' | |
| $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s' | |
| $nameRegex = '\w' | |
| $nameRegexBrackets = 'a-zA-Z0-9_\(\)' | |
| $schema = false | |
| $serverInfo = array() | |
| $autoIncrement = false | |
| $dataProvider | |
| $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME') | |
| $blobSize = 100 | |
Definiert in Zeile 164 der Datei adodb-datadict.inc.php.
| _GetSize | ( | $ | ftype, |
| $ | ty, | ||
| $ | fsize, | ||
| $ | fprec | ||
| ) |
GENERATE THE SIZE PART OF THE DATATYPE $ftype is the actual type $ty is the type defined originally in the DDL
Erneute Implementation in ADODB2_postgres, ADODB2_mssql und ADODB2_mssqlnative.
Definiert in Zeile 807 der Datei adodb-datadict.inc.php.
{
if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
$ftype .= "(".$fsize;
if (strlen($fprec)) $ftype .= ",".$fprec;
$ftype .= ')';
}
return $ftype;
}
| _Options | ( | $ | opts | ) |
Sanitize options, so that array elements with no keys are promoted to keys
Definiert in Zeile 907 der Datei adodb-datadict.inc.php.
{
if (!is_array($opts)) return array();
$newopts = array();
foreach($opts as $k => $v) {
if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
else $newopts[strtoupper($k)] = $v;
}
return $newopts;
}

| _Triggers | ( | $ | tabname, |
| $ | taboptions | ||
| ) |
GENERATE TRIGGERS IF NEEDED used when table has auto-incrementing field that is emulated using triggers
Erneute Implementation in ADODB2_oci8 und ADODB2_firebird.
Definiert in Zeile 899 der Datei adodb-datadict.inc.php.
{
return array();
}

| ActualType | ( | $ | meta | ) |
Returns the actual type given a character code.
C: varchar X: CLOB (character large object) or largest varchar size if CLOB is not supported C2: Multibyte varchar X2: Multibyte CLOB
B: BLOB (binary large object)
D: Date T: Date-time L: Integer field suitable for storing booleans (0 or 1) I: Integer F: Floating point number N: Numeric or decimal number
Erneute Implementation in ADODB2_postgres, ADODB2_mssql, ADODB2_mssqlnative, ADODB2_mysql, ADODB2_oci8, ADODB2_sybase, ADODB2_sqlite, ADODB2_sapdb, ADODB2_access, ADODB2_generic, ADODB2_ibase, ADODB2_informix, ADODB2_db2 und ADODB2_firebird.
Definiert in Zeile 407 der Datei adodb-datadict.inc.php.
{
return $meta;
}
| AlterColumnSQL | ( | $ | tabname, |
| $ | flds, | ||
| $ | tableflds = '', |
||
| $ | tableoptions = '' |
||
| ) |
Change the definition of one column
As some DBM's can't do that on there own, you need to supply the complete defintion of the new table, to allow, recreating the table and copying the content over to the new table
| string | $tabname | table-name |
| string | $flds | column-name and type for the changed column |
| string | $tableflds,='' | complete defintion of the new table, eg. for postgres, default '' |
| array/string | $tableoptions='' options for the new table see CreateTableSQL, default '' |
Erneute Implementation in ADODB2_postgres.
Definiert in Zeile 483 der Datei adodb-datadict.inc.php.
{
$tabname = $this->TableName ($tabname);
$sql = array();
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
$alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
foreach($lines as $v) {
$sql[] = $alter . $v;
}
if (is_array($idxs)) {
foreach($idxs as $idx => $idxdef) {
$sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']);
$sql = array_merge($sql, $sql_idxs);
}
}
return $sql;
}
| ChangeTableSQL | ( | $ | tablename, |
| $ | flds, | ||
| $ | tableoptions = false, |
||
| $ | dropOldFlds = false |
||
| ) |
"Florian Buzin [ easywe ]" <florian.buzin::easywe.de>
This function changes/adds new fields to your table. You don't have to know if the col is new or not. It will check on its own.
Definiert in Zeile 939 der Datei adodb-datadict.inc.php.
{
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false);
// check table exists
$save_handler = $this->connection->raiseErrorFn;
$this->connection->raiseErrorFn = '';
$cols = $this->MetaColumns($tablename);
$this->connection->raiseErrorFn = $save_handler;
if (isset($savem)) $this->connection->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if ( empty($cols)) {
return $this->CreateTableSQL($tablename, $flds, $tableoptions);
}
if (is_array($flds)) {
// Cycle through the update fields, comparing
// existing fields to fields to update.
// if the Metatype and size is exactly the
// same, ignore - by Mark Newham
$holdflds = array();
foreach($flds as $k=>$v) {
if ( isset($cols[$k]) && is_object($cols[$k]) ) {
// If already not allowing nulls, then don't change
$obj = $cols[$k];
if (isset($obj->not_null) && $obj->not_null)
$v = str_replace('NOT NULL','',$v);
if (isset($obj->auto_increment) && $obj->auto_increment && empty($v['AUTOINCREMENT']))
$v = str_replace('AUTOINCREMENT','',$v);
$c = $cols[$k];
$ml = $c->max_length;
$mt = $this->MetaType($c->type,$ml);
if (isset($c->scale)) $sc = $c->scale;
else $sc = 99; // always force change if scale not known.
if ($sc == -1) $sc = false;
list($fsize, $fprec) = $this->_getSizePrec($v['SIZE']);
if ($ml == -1) $ml = '';
if ($mt == 'X') $ml = $v['SIZE'];
if (($mt != $v['TYPE']) || ($ml != $fsize || $sc != $fprec) || (isset($v['AUTOINCREMENT']) && $v['AUTOINCREMENT'] != $obj->auto_increment)) {
$holdflds[$k] = $v;
}
} else {
$holdflds[$k] = $v;
}
}
$flds = $holdflds;
}
// already exists, alter table instead
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
$alter = 'ALTER TABLE ' . $this->TableName($tablename);
$sql = array();
foreach ( $lines as $id => $v ) {
if ( isset($cols[$id]) && is_object($cols[$id]) ) {
$flds = Lens_ParseArgs($v,',');
// We are trying to change the size of the field, if not allowed, simply ignore the request.
// $flds[1] holds the type, $flds[2] holds the size -postnuke addition
if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)
&& (isset($flds[0][2]) && is_numeric($flds[0][2]))) {
if ($this->debug) ADOConnection::outp(sprintf("<h3>%s cannot be changed to %s currently</h3>", $flds[0][0], $flds[0][1]));
#echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>";
continue;
}
$sql[] = $alter . $this->alterCol . ' ' . $v;
} else {
$sql[] = $alter . $this->addCol . ' ' . $v;
}
}
if ($dropOldFlds) {
foreach ( $cols as $id => $v )
if ( !isset($lines[$id]) )
$sql[] = $alter . $this->dropCol . ' ' . $v->name;
}
return $sql;
}

| CreateTableSQL | ( | $ | tabname, |
| $ | flds, | ||
| $ | tableoptions = array() |
||
| ) |
Generate the SQL to create table. Returns an array of sql strings.
Definiert in Zeile 563 der Datei adodb-datadict.inc.php.
{
list($lines,$pkey,$idxs) = $this->_GenFields($flds, true);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
$taboptions = $this->_Options($tableoptions);
$tabname = $this->TableName ($tabname);
$sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions);
// ggiunta - 2006/10/12 - KLUDGE:
// if we are on autoincrement, and table options includes REPLACE, the
// autoincrement sequence has already been dropped on table creation sql, so
// we avoid passing REPLACE to trigger creation code. This prevents
// creating sql that double-drops the sequence
if ($this->autoIncrement && isset($taboptions['REPLACE']))
unset($taboptions['REPLACE']);
$tsql = $this->_Triggers($tabname,$taboptions);
foreach($tsql as $s) $sql[] = $s;
if (is_array($idxs)) {
foreach($idxs as $idx => $idxdef) {
$sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']);
$sql = array_merge($sql, $sql_idxs);
}
}
return $sql;
}


| DropColumnSQL | ( | $ | tabname, |
| $ | flds, | ||
| $ | tableflds = '', |
||
| $ | tableoptions = '' |
||
| ) |
Drop one column
Some DBM's can't do that on there own, you need to supply the complete defintion of the new table, to allow, recreating the table and copying the content over to the new table
| string | $tabname | table-name |
| string | $flds | column-name and type for the changed column |
| string | $tableflds,='' | complete defintion of the new table, eg. for postgres, default '' |
| array/string | $tableoptions='' options for the new table see CreateTableSQL, default '' |
Erneute Implementation in ADODB2_postgres.
Definiert in Zeile 538 der Datei adodb-datadict.inc.php.
{
$tabname = $this->TableName ($tabname);
if (!is_array($flds)) $flds = explode(',',$flds);
$sql = array();
$alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' ';
foreach($flds as $v) {
$sql[] = $alter . $this->NameQuote($v);
}
return $sql;
}
| GetCommentSQL | ( | $ | table, |
| $ | col | ||
| ) |
in other words, we use a text area for editting.
any varchar/char field this size or greater is treated as a blob
Erneute Implementation in ADODB2_oci8.
Definiert in Zeile 184 der Datei adodb-datadict.inc.php.
{
return false;
}
| RenameColumnSQL | ( | $ | tabname, |
| $ | oldcolumn, | ||
| $ | newcolumn, | ||
| $ | flds = '' |
||
| ) |
Rename one column
Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql)
| string | $tabname | table-name |
| string | $oldcolumn | column-name to be renamed |
| string | $newcolumn | new column-name |
| string | $flds,='' | complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' |
Erneute Implementation in ADODB2_sqlite.
Definiert in Zeile 514 der Datei adodb-datadict.inc.php.
{
$tabname = $this->TableName ($tabname);
if ($flds) {
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
list(,$first) = each($lines);
list(,$column_def) = preg_split("/[\t ]+/",$first,2);
}
return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
}