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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
v5:dictionary:structure:sample_usage [2016/04/09 21:38] – ↷ Page name changed from v5:dictionary:structure:complex_sample to v5:dictionary:structure:sample_usage 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. This page shows the usage of the metaObjectStructure in various situations.
 +------------------------------------
 ===== Complex Example ===== ===== Complex Example =====
 The 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
Line 17: 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 111: 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