R::addDatabase problem

346 views
Skip to first unread message

bill

unread,
May 6, 2012, 12:21:51 AM5/6/12
to redbeanphp
Hi everyone,

I am trying to connect to a new database using:

R::addDatabase('wo','mysql:newDB','root','',TRUE);
R::selectDatabase('wo');
$sql='SELECT * FROM listings' ;
$records=R::getAll($sql);

I am getting the following error:

Fatal error: Uncaught [3D000] - SQLSTATE[3D000]: Invalid catalog name:
1046 No database selected thrown in C:\wamp\www\ionauth1\application
\third_party\rb.php on line 105.

What am I doing wrong?

Thank you,

Bill

Justin DeMaris

unread,
May 7, 2012, 8:56:12 AM5/7/12
to redbeanphp
Hey Bill,

Maybe a silly question, but does the "wo" database exist already? I
don't think RedBean will auto create a new database like that, as much
as it does magic with tables.

~ Justin

k c

unread,
May 7, 2012, 5:37:41 PM5/7/12
to redbe...@googlegroups.com
Thanks Justin,

It does.

I got it working with the following line:

 R::addDatabase('wo','mysql:host=localhost;dbname=newDB'','root','',TRUE);

Thanks,

Bill

--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To post to this group, send email to redbe...@googlegroups.com.
To unsubscribe from this group, send email to redbeanorm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redbeanorm?hl=en.


abhi

unread,
Jan 8, 2014, 2:15:58 AM1/8/14
to redbe...@googlegroups.com
R::addDatabase('wo','mysql:host=localhost;dbname=newDB'','root','',TRUE); i tried this but 



<?php
include('config.php');
R::setup("mysql:host=localhost;dbname=floreterp",'root','');
$param = "*";
$cond =  " id = 7 ";
$res = $obj->selectCustomize(state,$param,$cond);
echo "<pre>";
var_dump($res);
echo "hello";
R::addDatabase('erpserver','mysql:host=localhost;dbname=newDB','root','',TRUE);
// R::addDatabase("mysql:host=localhost;dbname=erpserver",'root','',TRUE);
$var = R::selectDatabase('erpserver');
if($var){
echo "db selected";
}
else{
echo ":P";
}
$par = "*";
$con = "id = 42";
$ans = $obj->selectCustomize(sub_group,$par,$con);
echo "<pre>";
var_dump($ans);
?>



but for me it is saying 


Fatal error:  Uncaught exception 'PDOException' with message 'Could not connect to database (newDB).' in C:\xampp\htdocs\floreterp\rb.php:196
Stack trace:
#0 C:\xampp\htdocs\floreterp\rb.php(243): RedBean_Driver_PDO->connect()
#1 C:\xampp\htdocs\floreterp\rb.php(276): RedBean_Driver_PDO->runQuery('SELECT * FROM p...', Array)
#2 C:\xampp\htdocs\floreterp\rb.php(1421): RedBean_Driver_PDO->GetAll('SELECT * FROM p...', Array)
#3 C:\xampp\htdocs\floreterp\rb.php(6089): RedBean_Adapter_DBAdapter->get('SELECT * FROM p...', Array)
#4 C:\xampp\htdocs\floreterp\rb.php(6022): RedBean_Facade::query('get', 'SELECT * FROM p...', Array)
#5 C:\xampp\htdocs\floreterp\config.php(30): RedBean_Facade::getAll('SELECT * FROM p...')
#6 C:\xampp\htdocs\floreterp\test.php(21): db->selectCustomize('product_sub_gro...', '*', 'id = 42')
#7 {main} 
  thrown in C:\xampp\htdocs\floreterp\rb.php on line 196

m new to redbean .... help me  :) 

Василий Заздравных

unread,
Jan 9, 2014, 1:27:15 AM1/9/14
to redbe...@googlegroups.com
The error here:


R::addDatabase('wo','mysql:host=localhost;dbname=newDB'','root','',TRUE);

dbname=wo

If 'wo' is the database name.

        R::addDatabase('wo','mysql:host=localhost;dbname=wo','user_name','password',true);
        R::selectDatabase('wot');

 Will work :)

Reply all
Reply to author
Forward
0 new messages