zend-db

Zend_Db: Adapter suddenly is null!

邮差的信 提交于 2019-12-11 06:46:38
问题 I'm using Zend_Db in one of my projects. Now I have the problem, that suddenly during the code execution, the variable $_db in Zend_Db_Adapter_Abstract is null. (shown by var_dump($this); in my DbTable_xx class). It seems like the adapter is set to null somewhere during the script execution. How can that happen? Unfortunately the project is too complex to post some code here... I'm getting this error (while executing the find($primary) method on Zend_Db_Adapter_Abstract): Fatal error: Call to

No default adapters in Zend unless I add them explicitly. Is this a feature or a bug?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 06:18:18
问题 If I dont put the default adapter explicitly in the bootstrap file, the Zend_DB_Tables does not have default adapters. I am getting: Exception information: Message: No adapter found for Application_Model_MyModel When I put in bootstrap: protected function _initDb(){ //this returns NULL //Zend_Debug::dump(Zend_Db_Table::getDefaultAdapter()); $resource = $this->getPluginResource('db'); $db = $resource->getDbAdapter(); // Now it is not NULL //Zend_Debug::dump($db); Zend_Db_Table:

Zend Database Adapter - Complex MySQL Query

那年仲夏 提交于 2019-12-11 04:28:28
问题 I have defined a function in my Navigation model that executes a query, and I was wondering if there's a more "Zendy" way of generating/executing the query. The query I'm using was proposed by Bill Karwin on another thread here for setting arbitrary record order. I tried using a prepared statement, but the values in the SIGN() function got quoted. I'm using the PDO adapter for MySQL. /** * */ public function setPosition($parentId, $oldPosition, $newPosition) { $parentId = intval($parentId);

Zend Framework 2 - Annotation forms and Doctrine2 - Catchable fatal error - ObjectManager

為{幸葍}努か 提交于 2019-12-11 03:34:10
问题 I'm using Zend, Doctrine2.1 and AnnotationForms. My entity looks like this: /** * @ORM\Entity * @ORM\Table(name="myentity") * @Form\Name("myentity") * @Form\Attributes({ "class": "form-horizontal" }) * @Form\Hydrator("\DoctrineModule\Stdlib\Hydrator\DoctrineObject") */ class MyEntity { ... } When using this DoctrineObject I get the following error: Catchable fatal error: Argument 1 passed to DoctrineModule\Stdlib\Hydrator\DoctrineObject::__construct() must be an instance of Doctrine\Common

php design question - will a Helper help here?

[亡魂溺海] 提交于 2019-12-11 03:03:52
问题 I have to list several elements that are coming from a database source A and they are: team_id, team_name and team_score (translated for explanation sake). I need to loop over them, and display that information. So, I have, on the DAO side: public function listOfTeams() { $select = $this->select() ->from(array('t'=>'teams'), array('cod_team','name','score')); return $this->fetchAll($select); } On my team controller: public function listAction() { $teamsDao = new TeamsDao(); $this->view-

Using FORCE INDEX with zend

时间秒杀一切 提交于 2019-12-11 02:32:45
问题 I try to find how to translate the following MySQL query into Zend Db Table Select: SELECT ColA,ColB,ColC FROM MyTable FORCE INDEX(ColA,ColB) WHERE ColA = 'val0002' AND ColB = 'val0045' i try to use something like this: $select = $dbTable->select() ->from('MyTable',array('ColA','ColB') ->forceIndex(array('ColA','ColB')) ->where("ColA = 'val0002'") ->where("ColB = 'val0045'"); I found " forceIndex(array('ColA','ColB')) " in a forum, but it does not work :( and thank you for helping me :) 回答1:

Joining tables within a model in Zend Php

人走茶凉 提交于 2019-12-11 01:23:11
问题 I understand the usage of Zend_Table and can obtain data using the Zend functions from the table associated with that class. For example I have a video table and in another table I have the association between the video and what category it is in. Im a little stumped how to active a select like the following within the framework: SELECT * FROM video,category WHERE category.category_id = 3 AND video.id = category.video_id I wish to do this within the video model which refers to the video table

'Zend_Db_Statement_Exception' with message 'Invalid bind-variable name ':1'

雨燕双飞 提交于 2019-12-10 17:43:22
问题 Good day, Background Info: Client's hosting server is being upgraded from PHP 5.2 to PHP 5.3. The client's app breaks when tested on PHP 5.3. Specifically the insert and update methods are the ones which are breaking the app. The app coded in Zend Framework v1.7.2. We have tried simply upgrading the Zend Framework core, however it seems that the previous developers made changes to the core, which causes the app to completely break when the framework has been upgraded. Problem The best

Zend_Db_Table_Row: Why do I have to use createRow()?

拜拜、爱过 提交于 2019-12-10 17:37:42
问题 I'm wondering why in Zend_Db you have to use the createRow method to get a new, empty Row object, rather than just instantiating the Row object directly. For instance, if I've extended the default classes to create my own User table and row classes, then in order to create a new row object I always have to do the following to create a new Row object: $userTable = new App_Table_User(); $userRow = $userTable->createRow(); $userRow->setName('bob'); $userRow->save(); But to me it makes more sense

Convert Zend\Db\ResultSet\HydratingResultSet to Array of Objects

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 14:20:47
问题 In my Mapper class I'm extending AbstractDbMapper from ZfcBase to fetch rows from the database. A simple example would be code like this: class MyMapper extends AbstractDbMapper { //... public function fetchAll() { $select = $this->getSelect(); return $this->select($select); // returns HydratingResultSet } } The problem is that $this->select() returns a Zend\Db\ResultSet\HydratingResultSet (containing the needed and hydrated objects). But I would like to return an array of these objects