zend-db

How does Zend\\Db in ZF2 control transactions?

可紊 提交于 2019-11-28 18:49:04
The ZF1 Zend_Db reference manual has an entire section on performing transactions. The ZF2 Zend\Db reference manual lacks any documentation on transactions. How do I perform transactions in ZF2? Example code would be helpful. The missing documentation is curious. To find out what happened, I had to dive into the API docs for Zend\Db\Adapter. It looks like beginTransaction , rollback and commit are defined in Zend\Db\Adapter\Driver\ConnectionInterface . This means that they are methods callable on every single adapter connection. Unfortunately the connection itself is rather buried. What I'm

Registering Zend Database Adapter in Registry

…衆ロ難τιáo~ 提交于 2019-11-28 14:56:30
问题 I am looking to register a reference to the main Database Adapter in the Registry during Bootstrapping so it can be used elsewhere in my site (specifically the Authorisation action). I have implemented an ugly fix where i create a Database Table object and call the getAdapter() method on it and pass through that. However, this is a bad way of doing it and I would like it to be available via the registry. Does anyone know how to do this? Any help or pointers in the right direction are

Zend_Db without Zend Framework [closed]

匆匆过客 提交于 2019-11-28 08:46:00
I want using Zend_Db without Zend_Framework. I want incorporate Zend_Db for my existing website that was not made using Zend Framework. Is it possible to use Zend_Db like this? Can you recommend good tutorial or example how to do it good? To some extent, this depends upon the web framework you are using. But, in general, the Zend_Db documentation is pretty clear in this regard. Create an adapter instance in your bootstrap. As an example: $db = Zend_Db::factory('Pdo_Mysql', array( 'host' => '127.0.0.1', 'username' => 'webuser', 'password' => 'xxxxxxxx', 'dbname' => 'test' )); If you plan to use

How do I add more than one row with Zend_Db?

走远了吗. 提交于 2019-11-28 05:25:37
I have an array with information which looks more or less like this: $data[] = array('content'=>'asd'); $data[] = array('content'=>'asdf'); And I want to add both entries into the Database. $db->insert('table', $data); does not add both entries. What am I doing wrong? Do I have to use Zend_ Db_Table? $data = array('content'=>'asdf'); $db->insert('table', $data); works of course markus I don't think Zend_Db supports insertion of multiple rows. But if you just have two rows or a little more you can just use a loop. foreach ($data as $row) { $db->insert('table', $row) } Bill Karwin , a former

How to print exact sql query in zend framework ?

不打扰是莪最后的温柔 提交于 2019-11-28 02:56:58
I have the following piece of code which i taken from model, ... $select = $this->_db->select() ->from($this->_name) ->where('shipping=?',$type) ->where('customer_id=?',$userid); echo $select; exit; // which gives exact mysql query. ..... When i use update query in zend like , $up_value = array('billing'=> '0'); $this->update($up_value,'customer_id ='.$userid.' and address_id <> '.$data['address_Id']); Here i want to know the exact mysql query. Is there any possible way to print the mysql query in zend ? kindly advice Mark Basmayor Select objects have a __toString() method in Zend Framework.

Page not found on request url in zend 2 framework application

南笙酒味 提交于 2019-11-28 02:25:15
I am newbie to zend framework and i am trying to configure the zend. I was sucessfully installed zendskeleton applicaion on window 7 and XAMPP After installation I am creating new module Album as per define in user guide. I was make all code and pages according to guide, but after that i was enable to open Album module . i got error 404 not found. here code application.config return array( 'modules' => array( 'Application','Album', ), 'module_paths' => array( './module', './vendor', ), 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), ), ); module.config return array(

connecting to two different databases with Zend Framework

你说的曾经没有我的故事 提交于 2019-11-28 00:07:27
问题 I have here a medium sized intranet site which is written entirely in Zend FW. The database for the intranet is located on another server. Now I need to extend the intranet with some new functionality. In order to do this I need to connect to another database on the same server (and same DBMS). The question is now: What is the best way to do this? Should I create a new Zend_Config object and a new Zend_Db_Adapter? Or should I use the existing one and try with the "use otherdbname;" statement

Zend Framework: How to delete a table row where multiple things are true?

亡梦爱人 提交于 2019-11-27 20:06:20
Normally, this would work for me: $db = Zend_Db_Table::getDefaultAdapter(); $where = $db->quoteInto('id = ?', $id); $db->delete('tablename', $where); but I have to match two ids. So I don't really know how to structure it. WHERE first_id = 'id1' AND second_id = 'id2' So how do I do this with the Zend Framework? To extend on Jason W's answer: Not exactly sure what the 3rd section is saying That means you can do this: $db->delete('tablename', array( 'first_id = ?' => $first_id, 'second_id = ?' => $second_id )); And the adapter will quote everything for you. I don't feel like the documentation is

Zend Enable SQL Query logging

最后都变了- 提交于 2019-11-27 18:37:22
问题 I am using this to retrieve the database connection atm. $db = Zend_Db_Table::getDefaultAdapter(); I do set this up in my config like this: resources.db.adapter = pdo_mysql resources.db.isDefaultTableAdapter = true resources.db.params.host = localhost resources.db.params.username = root resources.db.params.password = password resources.db.params.dbname = db resources.db.params.profiler.enabled = true resources.db.params.profiler.class = Zend_Db_Profiler I would like to output everything to a

Complex WHERE clause with Zend_Db using multiple AND OR operators

巧了我就是萌 提交于 2019-11-27 17:37:17
问题 I want to generate this complex WHERE clause in Zend_Db: SELECT * FROM 'products' WHERE status = 'active' AND ( attribute = 'one' OR attribute = 'two' OR [...] ) ; I've tried this: $select->from('product'); $select->where('status = ?', $status); $select->where('attribute = ?', $a1); $select->orWhere('attribute = ?', $a2); and that produced: SELECT `product`.* FROM `product` WHERE (status = 'active') AND (attribute = 'one') OR (attribute = 'two') ; I did figure out one method of making this