diff options
Diffstat (limited to 'shared/classes/0sql_row_obj.php')
-rw-r--r-- | shared/classes/0sql_row_obj.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/shared/classes/0sql_row_obj.php b/shared/classes/0sql_row_obj.php index d625071..8e13a3a 100644 --- a/shared/classes/0sql_row_obj.php +++ b/shared/classes/0sql_row_obj.php @@ -111,7 +111,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up self::$table_cache[$this->table]=get_class($this); } } - // Initializes this class based in the sql table given by $this->table + // Initializes this class based on the sql table given by $this->table // TODO should be static (5.3.0) private function init_from_create() { $c=self::sql_query('SHOW CREATE TABLE `'.$this->table.'`')->fetchColumn(1); @@ -330,7 +330,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up // 1. Primary key // 2. Numeric key // 3. Misc. key - // 4. Multi key + // TODO support multi-column unique keys function sql_id() { if (isset($this->primary_key)) { $id=count($this->primary_key)>1?'(':''; @@ -353,7 +353,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up } // If no argument is given, returns whether this object represents a row that is currently in the database. // If an argument that evaluates to false is given, clears the db_values array, causing it to be known as not in the db. - // if an argument that evaluates to true is given, fills the db_values array with values fromt the values array. + // if an argument that evaluates to true is given, fills the db_values array with values from the values array. function is_in_db() { if (func_num_args() == 0) { // db_values being populated indicates that it is in the database @@ -383,13 +383,13 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up $i=1; $rows=array(); foreach ($this->columns as $name => $col) { - // TODO for the , at EOL, this checks for PRIMARY KEY to indicate that there should be an extra $rows[]="\t".'`'.$name.'` '.$col->describe(); } if (isset($this->primary_key)) { $rows[]="\t".'PRIMARY KEY (`'.implode('`, `', $this->primary_key).'`)'; } foreach ($this->columns as $name => $col) { + // TODO support multi-column unique keys if ($col->unique && is_string($col->unique)) { $rows[]="\t".' UNIQUE KEY `'.$col->unique.'` (`'.$col->unique.'`)'; } @@ -398,6 +398,7 @@ abstract class sql_row_obj { // If the name of this class changes, it must be up $q.=')'; return $q; } + // Returns PHP code to define this class with the description of the SQL table already set up function to_php() { $r="class ".get_class($this)." extends ".get_parent_class($this)." {\n\tprotected \$table='".$this->table."', "; if (isset($this->primary_key)) { |