Re: Bug? - Pear can't seem to handle hyphens in database name
| From: | Justin Patrin | Date: | Wed, 20 Apr 2005 20:23:41 +0000 |
| Subject: | Re: Bug? - Pear can't seem to handle hyphens in database name | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18835@lists.php.net to get a copy of this message | ||
On 4/19/05, Massimiliano Arione <garak@studenti.it> wrote:
> Balazs Wellisch wrote:
> > I'm trying to connect to a MS SQL database using PEAR on Windows but I keep
> > getting this error: DB Error: no database selected.
> > I confirmed that all of my connection info is set up correctly and it seems
> > that the only reason I can't connect to this database is because the db name
> > has a hyphen in it. Can anyone confirm that this is a bug in PEAR DB and is
> > there a workaround for this?
>
> I'm experiencing the same error "DB Error: no database selected", with
> no nativecode given "[nativecode=**]"
> I checked for the connection, it seems to be all right.
> I don't have hypens in db name, but I do have it in table name.
If it's in a table or column name, try using quoteIdentifier().
$col = 'some-column';
$tab = 'come-table';
$sth = $db->query('SELECT '.$db->quoteIdentifier($col).' FROM
'.$db->quoteIdentifier($tab));
Don't like typing that every time? Try using DB_DataObject which has a
handy quote_identifier option to do it automatically for you.
The same *may* help for DB selection, but I'm not sur ehow you'd use it.
>
> I'm using DB 1.7.5 with PHP 4.3.10 under Linux
>
--
Justin Patrin