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
v5:dictionary:structure:sample_usage [2016/04/09 21:41] – [dropTableSql] mnewnhamv5:dictionary:structure:sample_usage [2016/04/09 21:46] (current) 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 9: Line 10:
 $t->addAttribute('ENGINE INNODB','mysql'); $t->addAttribute('ENGINE INNODB','mysql');
 $t->addColumnObject('COL1','I'); $t->addColumnObject('COL1','I');
-$t->addColumnObject('COL1','I')->addAttribute('NOTNULL');+$t->addColumnObject('COL1','I') 
 +                   ->addAttribute('NOTNULL');
  
 $c = $t->addColumnObject('COL2','C(64)'); $c = $t->addColumnObject('COL2','C(64)');
Line 17: Line 19:
 $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);
v5/dictionary/structure/sample_usage.1460230873.txt.gz · Last modified: 2017/04/21 11:29 (external edit)