sqlite question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I use the following to delete a column from a table:

$columns= "'col1','col2','col3','col4','col5'";
$columns=str_replace(','."'col3'",'',$columns);
$this->open_db(); //get the resource number($this->c_id)
$r=sqlite_query($this->c_id,"BEGIN");
$r=sqlite_query($this->c_id,"CREATE TEMPORARY TABLE
'backup'($columns)");
$r=sqlite_query($this->c_id,"INSERT INTO 'backup'
SELECT $columns FROM '$table_name'");
$r=sqlite_query($this->c_id,"DROP TABLE '$table_name'");
$r=sqlite_query($this->c_id,"CREATE TABLE '$table_name'($columns)");
$r=sqlite_query($this->c_id,"INSERT
INTO'$table_name' SELECT $columns FROM 'backup'");
$r=sqlite_query($this->c_id,"DROP TABLE 'backup'");
$r=sqlite_query($this->c_id,"COMMIT");
sqlite_close($this->c_id);

What happens is that 
"INSERT INTO 'backup'SELECT $columns FROM '$table_name'" 
populates the 'backup' table with
the names of the columns instead of the content of the columns. If I
unquote the columns names in $columns (col1,col2,col3...) the new table
is populated with the content, which is the correct behaviour. 
Trouble is that I prefer quoting column names in case they have more
words then one.
Same problem happened with my 'add column' function but I was able to
fix that selecting *  as opposed to $columns for populating the
temp table. 
I am pretty sure this is not sqlite behavior in console.
Any help will be appreciated, thanks.
This extension is new and probably still has bugs and undocumented features but
I've used sqlite in other applications and it kicks ass, for most web applications
anything bigger is overkill.


____
Regards, Andu Novac

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux