[pLog-svn] r3301 - in plog/trunk: . install

Jon Daley plogworld at jon.limedaley.com
Mon May 1 20:38:54 GMT 2006


 	Ok, thanks.  I also thought that there might if an IF EXISTS for 
columns, but I haven't looked yet.


On Mon, 1 May 2006, Oscar Renalias wrote:

> You might be able to use some methods from the data dictionaries available in 
> PDb. Try with method PDbBaseDataDict::MetaColumns(). I am not quite sure what 
> sort of data it returns, but it is used by the main PDbBaseDataDict 
> ::ChangeTableSQL method to determine which columns already exist and which 
> doesn't, so it might be what you're looking for.
>
> Oscar
>
> On 29 Apr 2006, at 23:02, Jon Daley wrote:
>
>> 	Is there a better way to check to see if a column exists in a table 
>> instead of this first SELECT query?
>> 
>> On Sat, 29 Apr 2006, jondaley at devel.lifetype.net wrote:
>>> Modified: plog/trunk/wizard.php
>>> +                // check to see if we need to remove duplicates and the 
>>> id index
>>> +            $query = "SELECT id FROM ".$this->_dbPrefix."config LIMIT 1";
>>> +            $result = $this->_db->Execute($query);
>>> +                // if $result is false, id column has already been 
>>> removed
>>> +            if($result){
>>> +                $result->Close();
>>> +
>>> +                    // remove all duplicates in plog_config table
>>> +                $query = "DELETE a FROM ".$this->_dbPrefix."config a, 
>>> ".$this->_dbPrefix."config b WHERE a.id > b.id " .
>>> +                    "AND a.config_key = b.config_key";
>>> +                $result = $this->_db->Execute($query);
>>> +                if(!$result){
>>> +                    $message .= "Error removing duplicates in config 
>>> table: ".$this->_db->ErrorMsg()."<br/>";
>>> +                    $errors = true;
>>> +                }
>>> +                else{
>>> +                    $result->Close();
>>> +
>>> +                    // remove index id field, we don't need it any more!
>>> +                    $query = "ALTER TABLE ".$this->_dbPrefix."config DROP 
>>> COLUMN id";
>>> +                    $result = $this->_db->Execute($query);
>>> +                    if(!$result){
>>> +                        $message .= "Error removing old id column from 
>>> config table: ".$this->_db->ErrorMsg()."<br/>";
>>> +                        $errors = true;
>>> +                    }
>>> +                    $result->Close();
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://devel.lifetype.net/mailman/listinfo/plog-svn
>> 
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn

**************************************
Jon Daley
http://jon.limedaley.com/

It's always easy to see both sides of an issue
we are not particularly concerned about.


More information about the pLog-svn mailing list