1
irmtfan
Core feature: alter/change/show functionality on database (add changeField and showFields)
  • 2013/4/7 9:58

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Now we dont have any function/class in xoops to do alter/change/show functionality on database.
i suggest to add some of them ASAP in xoops 26 like this:

public function changeField($field null$structure null)
    {
        
$sql "ALTER TABLE {$this->table} CHANGE {$field} {$field} {$structure}";
        if (!
$result $this->db->queryF($sql)) {
            
xoops_error($this->db->error().''.$sql);
            return 
false;
        }
        return 
true;
    }
    public function 
showFields($field null)
    {
        
$sql "SHOW FIELDS FROM {$this->table}";
        if (isset(
$field)) {
            
$sql .= " LIKE '{$field}'";
        }
        if (!
$result $this->db->queryF($sql)) {
            
xoops_error($this->db->error().''.$sql);
            return 
false;
        }
        
$ret = array();
        while (
$myrow $this->db->fetchArray($result)) {
            
$ret[$myrow["Field"]] = $myrow;
        }
        return 
$ret;
    }


do you think it needs more functionality eg: WHERE
please discuss then we can add it to sf.net feature request.

Login

Who's Online

318 user(s) are online (121 user(s) are browsing Support Forums)


Members: 0


Guests: 318


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits