zend-db-table

zend relationships with select

为君一笑 提交于 2020-01-21 05:20:11
问题 I am new to zend. I have been asked to redevelop a website that was once written in plain PHP and put it into the zend framework. I am having a lot of trouble with database relationships, I cant seem to get my head round defining and querying relationships. I would like to find a Category. From that Category I would like to be able to find all the CategoryInfo associated with it, and be able to query/sort/limit that dataset. Here are my models. Categorys.php <?php class Default_Model

Zend Framework: How to find a table row by the value of a specified column?

此生再无相见时 提交于 2020-01-13 11:59:10
问题 I am implementing my model exactly like the quickstart guide. In my model I am trying to implement a findByToken() method. The current find() method accepts an $id parameter, but I want to find by the value of a different column. //excerpt from the quickstart guide public function find($id, Default_Model_Guestbook $guestbook) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { return; } $row = $result->current(); $guestbook->setId($row->id) ->setEmail($row->email) -

Translating a query to use Zend_Db_Select

怎甘沉沦 提交于 2020-01-12 03:49:05
问题 I'm having some problems translating this query to use ZF's Zend_Db_Select : SELECT b.id, b.title, b.description FROM memberships AS m JOIN blogs AS b ON b.id = m.blog_id WHERE m.user_id = ? ORDER BY m.created LIMIT 0, 30 (this query works and returns results) Memberships is a link table between blogs and users . It's a simple | id | blog_id | user_id | affair. Here's what I have so far: // $table = Zend_Db_Table instance, $id = a user id $select = $table->select() ->from(array('m' =>

Zend Framework and Mysql - very slow

99封情书 提交于 2020-01-10 00:28:08
问题 I am creating a web site using php, mysql and zend framework. When I try to run any sql query, page generation jumps to around 0.5 seconds. That's too high. If i turn of sql, page generation is 0.001. The amount of queries I run, doesn't really affect the page generation time (1-10 queries tested). Stays at 0.5 seconds I can't figure out, what I am doing wrong. I connect to sql in bootstrap: protected function _initDatabase () { try { $config = new Zend_Config_Ini( APPLICATION_PATH . '

VARCHAR(4) storing more characters than four

跟風遠走 提交于 2020-01-03 21:02:16
问题 I have a VARCHAR(4) column that receives data from an input that may be above 4 characters. This is okay, though, and I let MySQL naturally (or so I thought) cut off the end of the characters. Strangely enough, when I'm looking at the database row results later in PHP (Using the PDO driver), the entire string is displaying, not just the 4 characters. Weird thing is, if I do a SELECT query on the MySQL CLI, it only returns the 4 characters. Even when I do a mysqldump, only the 4 characters

VARCHAR(4) storing more characters than four

混江龙づ霸主 提交于 2020-01-03 21:02:15
问题 I have a VARCHAR(4) column that receives data from an input that may be above 4 characters. This is okay, though, and I let MySQL naturally (or so I thought) cut off the end of the characters. Strangely enough, when I'm looking at the database row results later in PHP (Using the PDO driver), the entire string is displaying, not just the 4 characters. Weird thing is, if I do a SELECT query on the MySQL CLI, it only returns the 4 characters. Even when I do a mysqldump, only the 4 characters

How do you work with a relational database in Zend Framework?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 03:51:06
问题 I'm using the zend framework to write an app and I'm having lots of problems getting my relational database models to work. I've read the quickstart and the docs several times and I'm still not sure how to do this. I post a picture of the relationships between the different tables involved to avoid having to explain everything since English is not my first language and I tend not to make myself clear when I try to explain...well complex things. The tables press_releases, social_networking,

How to change Zend_Db_Table name within a Model to insert in multiple tables

江枫思渺然 提交于 2019-12-30 05:26:34
问题 Using Zend Framework, I've created a Model to insert a record into a database. My question is, after $this->insert($data) how can I switch the active table so that I can insert a record into another table? Here's my code so far: class Model_DbTable_Foo extends Zend_Db_Table_Abstract { protected $_name = 'foo'; public function addFoo($params) { $data = array( 'foo' => $params['foo'], ); $this->insert($data); $foo_id = $this->getAdapter()->lastInsertId(); $data2 = array( 'bar' => $params['bar']

How to use Join in Zend Framework

徘徊边缘 提交于 2019-12-29 01:44:12
问题 i am using Join query in zend.. like $select = $table->select() ->from(array('e' => 'EducationHistory'), array('status_DataDictionary_id')) ->join(array('r' => 'ReportOrder'), 'e.id = r.EducationHistory_id', array('reportOrderStatusId' => 'r.status_DataDictionary_id')) ->where('r.orderBy_Organization_id = ?', 4) ->where('r.orderBy_Person_id = ?', 1) ->group('e.enrollno'); and to do that i take help from http://framework.zend.com/manual/en/zend.db.select.html but when i try to run that query

Netbeans AutoComplete Methods Zend Model Classes

我只是一个虾纸丫 提交于 2019-12-24 19:12:04
问题 I have the following models classes however netbeans 7.0.1 autocomplete doesn't work for row classes. Model Class: class Application_Model_DbTable_Payments extends Zend_Db_Table_Abstract { protected $_name = 'payments'; protected $_rowClass = 'Application_Model_Payment'; } Row Class: class Application_Model_Payment extends Zend_Db_Table_Row_Abstract { public function setIdentifier($identifier = null){ return $this->identifier = $identifier; } } Code: $paymentsModel = new Application_Model