zend-db-table

How mvc works in Zend framework

不羁的心 提交于 2019-12-12 00:33:56
问题 Thanks for previous replies.. I am trying to print Hello_world using zend framework. I wrote php file in model folder and return string value as a "Hello_world". In controller i access the value of PHP like this $value = new TextReturner(); $this->view->setValue = $value->hello_world(); . i dont know how to access the value from controller to the view php file. I am new to zend framework. I already go through the outline structure of zend framework, i dont know how to access through codings.

Zend Query Select

岁酱吖の 提交于 2019-12-11 04:19:20
问题 Hi i need to do a simple query but something is wrong. I have $name and $surname and i need to search the (possible multiple) id that rappresent that name and surname and put all the id, name and surname in a array I do this query: $result=$this->_db_table->select()->where('name=?',$name) ->where('surname=?', $surname)->query() ->fetchAll(); $array=$result->toArray(); return $array; If i use $result=$this->_db_table->fetchAll(); $array=$result->toArray(); return $array it work correctly and i

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

select queries with Zend_DB_Table

只谈情不闲聊 提交于 2019-12-10 10:49:51
问题 I have a code something like following class Application_Model_Company extends Zend_Db_Table_Abstract { protected $_name = 'companies'; private $id; private $name; private $shortName; private $description; public static function getAllCompanies() { $companyObj = new self(); $select = $companyObj->select()->order(array('name')); $rows = $companyObj->fetchAll($select); if($rows) { $companies = array(); foreach($rows as $row) { $company = new self(); $company->id = $row->id; $company->name =

How to use bind variables with Zend_Db_Table->update() in the where clause

牧云@^-^@ 提交于 2019-12-09 07:55:27
问题 If I want to use the Zend_Db_Table->update() method to update my table with data, I cannot find anyway to use bind variables in the "where" clause. The method signature is: int update($data, array|string $where) Usually you will call the method like this: $table = new Bugs(); $data = array( 'updated_on' => '2007-03-23', 'bug_status' => 'FIXED' ); $where = $table->getAdapter()->quoteInto('bug_id = ?', 1234); $table->update($data, $where); quoteInto is just going to escape the variable, not

Unable to delete a record through Zend_Db_Table_Abstract->delete()

房东的猫 提交于 2019-12-08 09:36:54
问题 I am trying to delete a record through a delete action using zend framework Model. i am still unable to figure out why its not deleting and the $model->delete() always returns zero. (0) this is my delete action code. public function deleteAction() { if ($this->getRequest()->isGet()) { $id = $this->getRequest()->getParam('id'); if (!empty($id)) { $id = $this->getRequest()->getPost('id'); $post = new Application_Model_Post(); if ($post->delete($id)) { $this->_helper->flashMessenger->addMessage(

zf2 make a join between two different databases

故事扮演 提交于 2019-12-07 07:31:09
问题 I am trying to make a join between two tables placed in different databases with Zend Framework 2. The first table is called users and is stored in the database admin The second table is called hierarchy and is stored in the database customer I load the databases adapters in global.php return array( 'admin' => array( 'driver' => 'Pdo', 'dsn' => 'mysql:dbname=admin;host=localhost', 'driver_options' => array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'' ), ), 'customer' => array(

Zend DB Selecting constants - columns that do not exist in table

旧城冷巷雨未停 提交于 2019-12-06 19:31:31
问题 I'm trying to do this query using Zend DB select but I'm not able to do so This is the sql query select shopping_id,shopping_details,"friend" as type from shopping Notice here how I'm specifying "friend" as type and friend is not a column in the shopping table. Now how do I do this in Zend. I have tried this but it gives me an error saying "sh.friend Column does not exist" $select->from(array('sh'=>'shopping'),array('shopping_id','shopping_details','"friend" as type'); Any help will be

Zend_Db_Table: Delete multiple entries

醉酒当歌 提交于 2019-12-06 10:23:45
问题 I wanted to delete some db entries and each of them has a unique ID. My current code looks so, taken from here: Zend Framework: How to delete a table row where multiple things are true? $where = array(); foreach ($IDs as $ID) { $where[] = $this->getAdapter()->quoteInto('id = ?', $ID); } $this->delete($where); This is called inside the model class extends by Zend_Db_Table_Abstract. The query looks now like that: DELETE FROM `shouts` WHERE (id = '10') AND (id = '9') AND (id = '8') That doesn't

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

让人想犯罪 __ 提交于 2019-12-05 16:03:47
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) ->setComment($row->comment) ->setCreated($row->created); } I tried doing something like this, but I don't think