1

I always used Application_Model_DbTable to work with database, but I used MySql. I configured my application.ini like this:

resources.db.adapter = PDO_MYSQL 
resources.db.params.host = localhost
resources.db.params.username = admin    
resources.db.params.password = 12345
resources.db.params.dbname = daedu
resources.db.params.charset = utf8

and used standart functions of dbtable such as fetchAll or insert. How to have same result, but with PostgreSQL?

I've installed PostgreSQL and through pgAdmin III I already made database and tables. The problem is how to connect it to Zend using db-table?

I configured it like this:

resources.db.adapter = PDO_PGSQL 
resources.db.params.host = localhost
resources.db.params.port = 5432
resources.db.params.username = postgres 
resources.db.params.password = 12345
resources.db.params.dbname = postgres
resources.db.params.charset = utf8

I work with it through dbtable like this:

class Application_Model_DbTable_Postrgres extends Zend_Db_Table_Abstract
{
    protected $_name = 'postgres';

    public function insert(){
        $data = array(
            'name' => "dan"
        );

        $this->insert($data);
    }
}

in Controller:

$f = new Application_Model_DbTable_Postrgres();
$f->insert();

but page doesnot open (error is: net::ERR_EMPTY_RESPONSE) and there is no new insert in table, when I try to fetchAll in db table, I get application error.

2 Answers 2

1
resources.db.adapter = PDO_PGSQL

You'll need to have PDO_PGSQL installed.

Sign up to request clarification or add additional context in comments.

Comments

1

Solved the problem! How? I turned on the development mode in public/index.php file:

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

The error was shown that there is not Prymary Key in my table. I added it with SQl and threr it is! Everything works! So this way of connecting Zend to PostgreSQL is fully right!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.