ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:altercolumnsql

Differences

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

Link to this comparison view

Next revision
Previous revision
dictionary:altercolumnsql [2015/08/29 16:38] – created mnewnhamv5:dictionary:altercolumnsql [2016/01/13 02:06] (current) – ↷ Links adapted because of a move operation mnewnham
Line 6: Line 6:
 <WRAP right box> <WRAP right box>
 == See Also == == See Also ==
-[[dictionary:column_attributes|Column Attributes Reference]] +[[v5:dictionary:column_attributes|Column Attributes Reference]] 
 == Syntax == == Syntax ==
   array alterColumnSql(   array alterColumnSql(
Line 19: Line 19:
 The method ''alterColumnSql()'' creates the SQL statement necessary to modify an existing column on an existing table, given by ''$tableName'', with the attributes specified in the string ''$columnData''. The column must already exist in the specified table. The method ''alterColumnSql()'' creates the SQL statement necessary to modify an existing column on an existing table, given by ''$tableName'', with the attributes specified in the string ''$columnData''. The column must already exist in the specified table.
  
-The information specified in the ''$columnData'' string must conform to the [[dictionary:column_attributes|Column Attributes]] standard.+The information specified in the ''$columnData'' string must conform to the [[v5:dictionary:column_attributes|Column Attributes]] standard.
  
 ===== Limitations ==== ===== Limitations ====
Line 35: Line 35:
   * Attempting to switch the metaType of a field from say ''C'' to ''I''   * Attempting to switch the metaType of a field from say ''C'' to ''I''
  
-In order to actually modify the column, the returned array must be passed to the [[dictionary:executeSqlArray|executeSqlArray()]] method. +In order to actually modify the column, the returned array must be passed to the [[v5:dictionary:executesqlarray|executeSqlArray()]] method. 
  
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
  
 +/*
 + * create a data dictionary object, using this connection
 + */
 +$dict = NewDataDictionary($db);
 +
 +
 +$table = 'lctable';
 +$flds = 'col6 C(50)';
 +
 +$sql = $dict->alterColumnSql($table,$flds);
 +/*
 + * Sql looks like:
 +  ALTER TABLE "lctable" ALTER COLUMN "col6" SET DATA TYPE VARCHAR(50)
 + */
 +
 +/*
 + * Complete the process by executing the statement
 +*/
 +$db->startTrans();
 +$dict->executeSqlArray($sql);
 +$db->completeTrans();
 </code> </code>
  
v5/dictionary/altercolumnsql.1440859095.txt.gz · Last modified: 2017/04/21 11:29 (external edit)