Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]


Deprecated: Function gmstrftime() is deprecated in /home/mikespub/www/list.php on line 509
Date Directory [filter] File(s) [view] Author [filter]
10 Aug 2002 16:56:33postnuke_official/html/includespnTableDDL.php,1.2,1.3John Robeson
 cleaned up a little and added a simple database creation function.. needs to be fleshed out..

Update of /home/cvsroot/postnuke_official/html/includes
In directory ns7.hostnuke.net:/tmp/cvs-serv831/html/includes

Modified Files:
	pnTableDDL.php 
Log Message:
cleaned up a little and added a simple database creation function.. needs to be fleshed out..


Index: pnTableDDL.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/includes/pnTableDDL.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pnTableDDL.php	4 Aug 2002 20:17:28 -0000	1.2
--- pnTableDDL.php	10 Aug 2002 16:56:31 -0000	1.3
***************
*** 24,35 ****
  // ----------------------------------------------------------------------
  
! /*
!  * Public Functions:
!  *   
!  * pnDBCreateTable ( $table, $fields, <$db_type> )
!  * pnDBCreateIndex ( $table, $index, <$db_type> )
!  * pnDBDropTable ( $table, <$db_type> )
!  * 
   */
  
  /*
--- 24,57 ----
  // ----------------------------------------------------------------------
  
! /**
!  * Create a database
!  *
!  * @access private
!  * @param dbname database name
!  * @param dbtype database type
!  * @returns pnMySQLCreateDB
!  * @return MySQL create database function
   */
+ function pnDBCreateDB($dbname, $dbtype='')
+ {
+     //perform validations on input arguments
+     if (empty($dbname)){ 
+         return FALSE;
+     }
+     
+     if (empty($dbtype)) {
+         $dbtype = pnConfigGetVar('dbtype');
+     }
+ 
+     switch($dbtype) {
+         case 'mysql':
+             $sql = 'CREATE DATABASE '.$dbname;
+             break;
+         // Other DBs go here
+         default:
+             $sql = FALSE;
+     }
+     return $sql;    
+ }
  
  /*
***************
*** 47,51 ****
  );  */
  
! function pnDBAlterTable($args, $dbtype="") {
  
      // perform validations on input arguments
--- 69,89 ----
  );  */
  
! /**
!  * Alter database table
!  *
!  * @access public
!  * @param args['table'] the table to alter
!  * @param args['command'] command to perform on table(add,modify,drop,rename)
!  * @param args['field_name'] field to alter
!  * @param args['new_field_name'] new field name
!  * @param args['type'] field type
!  * @param args['null'] null or not
!  * @param args['increment'] auto incrementing files
!  * @param args['primary_key'] primary key          
!  * @returns sql
!  * @return generated sql
!  */
! function pnDBAlterTable($args, $dbtype='')
! {
  
      // perform validations on input arguments
***************
*** 69,112 ****
  }
  
- function pnMySQLAlterTable($args) {
  
-     switch ($args['command']) {
-         case 'add':
-             if (empty($args['field'])) return FALSE;
-             $sql = 'ALTER TABLE '.$args['table'].' ADD ';
-             $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args));
-             if ($args['first'] == TRUE) {
-                 $sql .= ' FIRST';
-             } elseif (!empty($args['after_field'])) {
-                 $sql .= ' AFTER '.$args['after_field'];
-             }
-             break;
-         case 'modify':
-             if (empty($args['field'])) return FALSE;
-             $sql = 'ALTER TABLE '.$args['table'].' CHANGE ';
-             $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args));
-             break;
-         case 'drop':
-             if (empty($args['field'])) return FALSE;
-             $sql = 'ALTER TABLE '.$args['table'].' DROP COLUMN '.$args['field'];
-             break;
-         case 'rename':
-             if (empty($args['new_name'])) return FALSE;
-             $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name'];
-             break;
-         default:
-             $sql = FALSE;
-     }
-     return $sql;
- } 
  
  /**
   * generate the SQL to create a table
   * @param table the physical table name 
   * @param fields an array containing the fields to create
   * @returns data|false
   * @return the generated SQL statement, or false on failure
   */
! function pnDBCreateTable($table, $fields, $dbtype="") {
  
      // perform validations on input arguments
--- 107,124 ----
  }
  
  
  
  /**
   * generate the SQL to create a table
+  *
+  * @access public
   * @param table the physical table name 
   * @param fields an array containing the fields to create
+  * @param dbtype database type
   * @returns data|false
   * @return the generated SQL statement, or false on failure
   */
! function pnDBCreateTable($table, $fields, $dbtype='')
! {
  
      // perform validations on input arguments
***************
*** 121,134 ****
      switch($dbtype) {
          case 'mysql':
!             $sql_statement = pnMySQLCreateTable($table,$fields);
              break;
          case 'postgresql':
!             $sql_statement = pnPostgreSQLCreateTable($table,$fields);        
              break;       
          // Other DBs go here
          default:
!             $sql_statement = FALSE;
      }
!     return $sql_statement;    
  }
  
--- 133,146 ----
      switch($dbtype) {
          case 'mysql':
!             $sql = pnMySQLCreateTable($table,$fields);
              break;
          case 'postgresql':
!             $sql = pnPostgreSQLCreateTable($table,$fields);        
              break;       
          // Other DBs go here
          default:
!             $sql = FALSE;
      }
!     return $sql;    
  }
  
***************
*** 137,140 ****
--- 149,154 ----
  /**
   * generate the SQL to delete a table
+  * 
+  * @access public
   * @param table the physical table name 
   * @param index an array containing the index name, type and fields array
***************
*** 142,149 ****
   * @return the generated SQL statement, or false on failure
   */
! function pnDBDropTable( $table, $dbtype="" ) {
  
      // perform validations on input arguments
!     if (empty($table)) return FALSE;
      
      if (empty($dbtype)) {
--- 156,166 ----
   * @return the generated SQL statement, or false on failure
   */
! function pnDBDropTable($table, $dbtype='')
! {
  
      // perform validations on input arguments
!     if (empty($table)){ 
!         return FALSE;
!     }
      
      if (empty($dbtype)) {
***************
*** 165,168 ****
--- 182,187 ----
  /**
   * generate the SQL to create a table index
+  *
+  * @access public
   * @param table the physical table name 
   * @param index an array containing the index name, type and fields array
***************
*** 171,178 ****
   * @return the generated SQL statement, or false on failure
   */
! function pnDBCreateIndex( $table, $index, $dbtype="") {
  
      // perform validations on input arguments
!     if (empty($table)) return FALSE;
      if (!is_array($index)) return FALSE;
      if (!is_array($index['fields'])) return FALSE;
--- 190,201 ----
   * @return the generated SQL statement, or false on failure
   */
! function pnDBCreateIndex($table, $index, $dbtype='')
! {
  
      // perform validations on input arguments
!     if (empty($table)){ 
!         return FALSE;
!     }
!         
      if (!is_array($index)) return FALSE;
      if (!is_array($index['fields'])) return FALSE;
***************
*** 204,215 ****
      return $sql;    
  }
   
! function pnDBDropIndex($table,$fields) {
  }
  
! // PRIVATE FUNCTIONS BELOW - do not call directly
  
  /**
!  * Private Function to generate the MySQL to create a table
   * @param table the physical table name 
   * @param fields an array containing the fields to create
--- 227,290 ----
      return $sql;    
  }
+ 
   
! /**
!  * generate the sql to drop a database index
!  *
!  * @access public
!  * @param table the physical table name
!  * @param fields to drop
!  * @returns false
!  * @return the generated SQL statement, or false on failure
!  */ 
! function pnDBDropIndex($table,$fields) 
! {
!     return false;
  }
  
! /**
!  * MySQL table alteration
!  *
!  * @access private
!  * @param $args['command'] command to perform
!  * @returns sql|false
!  * @return the generated SQL statement, or false on failure
!  */
! function pnMySQLAlterTable($args) 
! {
  
+     switch ($args['command']) {
+         case 'add':
+             if (empty($args['field'])) return FALSE;
+             $sql = 'ALTER TABLE '.$args['table'].' ADD ';
+             $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args));
+             if ($args['first'] == TRUE) {
+                 $sql .= ' FIRST';
+             } elseif (!empty($args['after_field'])) {
+                 $sql .= ' AFTER '.$args['after_field'];
+             }
+             break;
+         case 'modify':
+             if (empty($args['field'])) return FALSE;
+             $sql = 'ALTER TABLE '.$args['table'].' CHANGE ';
+             $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args));
+             break;
+         case 'drop':
+             if (empty($args['field'])) return FALSE;
+             $sql = 'ALTER TABLE '.$args['table'].' DROP COLUMN '.$args['field'];
+             break;
+         case 'rename':
+             if (empty($args['new_name'])) return FALSE;
+             $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name'];
+             break;
+         default:
+             $sql = FALSE;
+     }
+     return $sql;
+ } 
  /**
!  * MySQL create table function
!  *
!  * @access private
   * @param table the physical table name 
   * @param fields an array containing the fields to create
***************
*** 217,221 ****
   * @return the generated SQL statement, or false on failure
   */
! function pnMySQLCreateTable($table, $fields) {
      $sql_fields = array();
  
--- 292,297 ----
   * @return the generated SQL statement, or false on failure
   */
! function pnMySQLCreateTable($table, $fields)
! {
      $sql_fields = array();
  
***************
*** 229,233 ****
  }
  
! function pnMySQLColumnDefinition ($field_name,$parameters) {
      $this_field = array($field_name);
  
--- 305,319 ----
  }
  
! /**
!  * MySQL column definitions
!  *
!  * @access private
!  * @param field_name the physical table name 
!  * @param parameters array 
!  * @returns data|false
!  * @return the modified filed, or false on failure
!  */
! function pnMySQLColumnDefinition ($field_name,$parameters) 
! {
      $this_field = array($field_name);
  
***************
*** 418,422 ****
  
  /**
!  * Private Function to generate the PostgreSQL to create a table
   * @param table the physical table name 
   * @param fields an array containing the fields to create
--- 504,510 ----
  
  /**
!  * PostgreSQL generate table creation
!  *
!  * @access private
   * @param table the physical table name 
   * @param fields an array containing the fields to create


Directory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3