ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:structure:sample_usage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
v5:dictionary:structure:complex_sample [2016/04/09 21:36] – created mnewnhamv5:dictionary:structure:sample_usage [2016/04/09 21:44] mnewnham
Line 1: Line 1:
 ====== Sample Usage ====== ====== Sample Usage ======
 +This page shows the usage of the metaObjectStructure in various situations.
 +------------------------------------
 ===== Complex Example ===== ===== Complex Example =====
-he following complex example shows the additional functionality of updating indexes, as well as chaining methods+The following complex example shows the additional functionality of updating indexes, as well as chaining methods
 <code php> <code php>
 $dict = NewDataDictionary($db); $dict = NewDataDictionary($db);
Line 16: Line 18:
 $ii = $i->addIndexItemObject('COL1'); $ii = $i->addIndexItemObject('COL1');
  
-$t->addColumnObject('COL1','C(32)')->addAttribute('NOTNULL')->addAttribute(array('DEFAULT'=>'abc'));+$t->addColumnObject('COL1','C(32)') 
 +                ->addAttribute('NOTNULL') 
 +                ->addAttribute(array('DEFAULT'=>'abc'));
  
-$t->addColumnObject('COL2','I')->addAttribute('NOTNULL')->addAttribute('PRIMARY')->addAttribute('AUTO');+$t->addColumnObject('COL2','I') 
 +               ->addAttribute('NOTNULL') 
 +               ->addAttribute('PRIMARY') 
 +               ->addAttribute('AUTO');
 $t->addColumnObject('COL3','N(12.2)'); $t->addColumnObject('COL3','N(12.2)');
-$t->addColumnObject('COL4','C(64)')->addAttribute(array('CHARACTER SET'=>'"ascii"'))->addAttribute(array('COLLATE'=>'"latin1_swedish_ci"'),'mysql');+$t->addColumnObject('COL4','C(64)') 
 +              ->addAttribute(array('CHARACTER SET'=>'"ascii"')) 
 +              ->addAttribute(array('COLLATE'=>'"latin1_swedish_ci"'),'mysql');
  
 $t->addColumnObject('COL5',"ENUM('cats','dogs','fish')"); $t->addColumnObject('COL5',"ENUM('cats','dogs','fish')");
-$t->addColumnObject('COL6','T')->addAttribute('DEFTIMESTAMP');+$t->addColumnObject('COL6','T') 
 +              ->addAttribute('DEFTIMESTAMP');
  
-$t->addColumnObject('COL7','D')->addAttribute('DEFDATE');+$t->addColumnObject('COL7','D') 
 +              ->addAttribute('DEFDATE');
  
-$t->addIndexObject('COL4-INDEX')->addIndexItem('COL4')->addAttribute('ASC'); +$t->addIndexObject('COL4-INDEX') 
-$t->addIndexObject('COL4-INDEX')->addIndexItem('COL5');+              ->addIndexItem('COL4') 
 +              ->addAttribute('ASC'); 
 +$t->addIndexObject('COL4-INDEX') 
 +              ->addIndexItem('COL5');
  
 $sql = $dict->createTableSql($tabledef); $sql = $dict->createTableSql($tabledef);
Line 110: Line 124:
 $t = new metaObjectStructure($dict,'employees'); $t = new metaObjectStructure($dict,'employees');
 $sqlarray = $dict->dropTableSql($t); $sqlarray = $dict->dropTableSql($t);
 +</code>
 +
 +==== renameTableSql ====
 +=== Usage ===
 +<code php>
 +$t = new metaObjectStructure($dict,'employees');
 +$t->setNewName('new-column');
 +$sqlarray = $dict->renameTableSql($t);
 </code> </code>
  
  
v5/dictionary/structure/sample_usage.txt · Last modified: 2016/04/09 21:46 by mnewnham