mysql table naming
Posted: Tue Oct 03, 2006 10:37 am
Hi all,
Im wondering, can I have a table name with 2 words, ie. 'my table'?
Heres what I have:
The actual name of the table is 'Arabidopsis Chambers'. If I do not enclose the table name with ' ' , it throws a "no table Arabidopsis" exists. So I see it leaves off the second word "Chambers".
If I enclose it with ' ' , it then throws:
"Check the manual that corresponds to your MySQL server version for the right syntax to use near ''Arabidopsis Chambers'' at line 1".
Here is the function from my DbQuery class:
Any suggestions would be great.
Thanks
Keith
Im wondering, can I have a table name with 2 words, ie. 'my table'?
Heres what I have:
Code: Select all
$myTable = "'".$row['prod_name']."'";
$dbquery->buildSelectQuery("*", $myTable, false,'');If I enclose it with ' ' , it then throws:
"Check the manual that corresponds to your MySQL server version for the right syntax to use near ''Arabidopsis Chambers'' at line 1".
Here is the function from my DbQuery class:
Code: Select all
function buildSelectQuery($selectWhat, $table, $where, $whereParams)
{
// $selectWhat = What to select, certain fields or *
// $table = What table to select from
// $where = Check if it needs a WHERE clause - true or false
// $whereParams = What are the paramaters
// check if a WHERE statement is needed
if($where){
$this->queryString = "SELECT ".$selectWhat." FROM ".$table." WHERE ".$whereParams;
}else{
$this->queryString = "SELECT ".$selectWhat." FROM ".$table;
}
$this->result = mysql_query($this->queryString) or die("Could not connect to MySQL database from buildSelectQuery" .mysql_error());
}Thanks
Keith