isWriteConnect() not returning anything

28 views
Skip to first unread message

tri

unread,
Jan 13, 2012, 10:57:14 AM1/13/12
to Simple PHP Framework
hi, is there a way to check if the database is connected, if not then
use some data source such as csv?

I tried using writeConnected() and isWriteConnect() but both don't
really return true or false appropriately. Thanks.

Tyler Hall

unread,
Jan 13, 2012, 11:24:40 AM1/13/12
to simple-php...@googlegroups.com
Hi.

The Database class methods isReadConnected() and isWriteConnected() are the correct ways to test if the database is connected.

Can you give us any more details about the problem you're seeing? Both of those methods are returning true/false appropriately in my tests.

Tyler

tri

unread,
Jan 13, 2012, 12:58:16 PM1/13/12
to Simple PHP Framework
I am doing

$db = Database::getDatabase();

printr($db);
echo '<br><br><br><br><br>';
$conn = $db->writeConnect();

print_r ($conn); die;

The function does return 1 for a successful connection. However, when
the connection failed ,the function returns nothing and just display
mysql connection errors.

If connection failed, I need it to return false or 0 without throwing
these mysql error so I can write to a csv file, silently, instead.

Tyler Hall

unread,
Jan 13, 2012, 1:02:29 PM1/13/12
to simple-php...@googlegroups.com
It sounds like you need to silence the Database error notifications. To do this, edit class.config.php and change

$this->dbOnError = '<something>';

to

$this->dbOnError = '';

Setting dbOnError to an empty value will prevent the Database class from throwing an error on a failed connection.

Tyler

> --
> You received this message because you are subscribed to the Google Groups "Simple PHP Framework" group.
> To post to this group, send email to simple-php...@googlegroups.com.
> To unsubscribe from this group, send email to simple-php-frame...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-php-framework?hl=en.
>

Reply all
Reply to author
Forward
0 new messages