Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8166889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:02:07+00:00 2026-06-06T20:02:07+00:00

in my zf application i have base model class Application_Model, which connects to db

  • 0

in my zf application i have base model class Application_Model, which connects to db and stores connection in registry.
part of code:

$db = Zend_Db::factory($registry['config']->$databaseAlias->db->adapter, $registry['config']->$databaseAlias->db->config->toArray());
        $db -> query('SET NAMES ' . $registry['config']->$databaseAlias->db->config->setnames);
        $db -> setFetchMode(Zend_Db::FETCH_OBJ);
        Zend_Registry::set('db', array($databaseAlias=>$db));

if mysql server is shut down, $db -> query('SET NAMES ' . $registry['config']->$databaseAlias->db->config->setnames); throws exception. that’s not what i want.
actualy i want to check somehow, if my database dead – do some actions;
is there any way to do so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:02:09+00:00Added an answer on June 6, 2026 at 8:02 pm

    You could throw a try/catch around the db call, and if it gets into the catch, do the actions you want

    try
    {
        $db = Zend_Db::factory(
            $registry['config']->$databaseAlias->db->adapter,
            $registry['config']->$databaseAlias->db->config->toArray()
        );
        $db -> query('SET NAMES ' . $registry['config']->$databaseAlias->db->config->setnames);
        $db -> setFetchMode(Zend_Db::FETCH_OBJ);
        Zend_Registry::set('db', array($databaseAlias=>$db));
    } catch( \Exception $e ) {
        // Database query failed, do logic here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my console application have an abstract Factory class Listener which contains code for
I have a model in my rails application which is class Person < ActiveRecord::Base
I'm putting together an MVC application where I have created a base Model which
I am creating an ASP.NET MVC3 application using NHIBERNATE. I have a base class
I have a code base that has been used as an ASP.Net web application.
I have an abstract base class in my application. I want to provide an
I have a django application which has one main table/model which references various 'lookup'
I have Rails application (Redmine) and I have created next working code which close
We have developed map base application. We have implemented multi-threading for display data on
We have a large code base in MFC and VB. A few applications are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.