zend-db

Zend-framework DB: OR instead of AND operator

一笑奈何 提交于 2019-12-03 13:26:48
问题 have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE ?', '%'.$searchWord.'%') ->where('verified=1 AND activated=1'); In other words it looks like: SELECT `some_table`.* FROM `some_table` WHERE (title LIKE '%nice house%') AND (description LIKE '%nice house%') AND (verified=1 AND activated=1) If I have couple AND sentences, zend connect it through AND operator. How can I connect it with OR operator ? Cause I need: ...

How to get Column Name With Zend DB

二次信任 提交于 2019-12-03 11:32:59
How to get Column Name With Zend DB corné This is the correct answer, the older answers are wrong or outdated: $cols = $table->info(Zend_Db_Table_Abstract::COLS); $metadata = $db->describeTable($tableName); $columnNames = array_keys($metadata); http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.list-describe Paamand Previous answer applies only to version < 2. For current version of ZF (2.2) use: $table = new Zend\Db\TableGateway\TableGateway('table', $Dbadapter, new Zend\Db\TableGateway\Feature\MetadataFeature()); $columns = $table->getColumns(); http://framework.zend.com/manual

Zend Form Edit and Zend_Validate_Db_NoRecordExists

不羁岁月 提交于 2019-12-03 06:14:42
I am slowly building up my Zend skills by building some utility websites for my own use. I have been using Zend Forms and Form validation and so far have been happy that I have been understanding the Zend way of doing things. However I am a bit confused with how to use Zend_Validate_Db_NoRecordExists() in the context of an edit form and a field that maps to database column that has to be unique. For example using this simple table TABLE Test ( ID INT AUTO_INCREMENT, Data INT UNIQUE ); If I was simply adding a new row to the Table Test, I could add a validator to the Zend Form element for the

How to Use Multiple Conditions In An Update Statement With Zend_Db And QuoteInto

送分小仙女□ 提交于 2019-12-03 06:07:49
Using Zend Framework, is there a way to pass multiple conditions to an update statement using the quoteInto method? I've found some references to this problem but I'm looking for a supported way without having to extend Zend_Db or without concatenation. $db = $this->getAdapter(); $data = array('profile_value' => $form['profile_value']); $where = $db->quoteInto('user_id = ?', $form['id']) . $db->quoteInto(' AND profile_key = ?', $key); $this->update($data, $where); References http://blog.motane.lu/2009/05/21/zend_db-quoteinto-with-multiple-arguments/ http://codeaid.net/php/multiple-parameters

Zend-framework DB: OR instead of AND operator

别来无恙 提交于 2019-12-03 02:48:17
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE ?', '%'.$searchWord.'%') ->where('verified=1 AND activated=1'); In other words it looks like: SELECT `some_table`.* FROM `some_table` WHERE (title LIKE '%nice house%') AND (description LIKE '%nice house%') AND (verified=1 AND activated=1) If I have couple AND sentences, zend connect it through AND operator. How can I connect it with OR operator ? Cause I need: ...(title LIKE '%nice house%') OR (description LIKE '%nice house%')... Your help would be appreciated. $this-

How to create WHERE IN clause with Zend_Db_Select

夙愿已清 提交于 2019-12-02 17:49:06
So I am trying to accomplish something like this: SELECT * FROM table WHERE status_id IN (1,3,4); using Zend_Db_Select... can't find how to do it :( Is it at all possible? you can also use it like this: $data = array(1,3,4); $select->where('status_id IN(?)', $data); you dont need to implode array, and it's safer The first answer probably works in ZF1 but it doesn't work in Zend Framework 2: $data = array(1,3,4); $select->where('status_id IN(?)', $data); In case the Zend Framework2 I found out that you have to use: $data = array(1,3,4); $select->where(array('status_id' => $data)); Result: WHERE

how to join tables using tablegateway

雨燕双飞 提交于 2019-12-02 15:59:08
问题 How to join tables in zend3 when using tableadapter? The question is not about how to join tables in general, it is about how to do this in zend and where to place the code. Let's say I habe a *table class for example: namespace Import\Model; use RuntimeException; use Zend\Db\TableGateway\TableGatewayInterface; class ProjectTable { private $tableGateway='t_project'; public function __construct(TableGatewayInterface $tableGateway) { $this->tableGateway = $tableGateway; } public function

how to join tables using tablegateway

三世轮回 提交于 2019-12-02 10:36:28
How to join tables in zend3 when using tableadapter? The question is not about how to join tables in general, it is about how to do this in zend and where to place the code. Let's say I habe a *table class for example: namespace Import\Model; use RuntimeException; use Zend\Db\TableGateway\TableGatewayInterface; class ProjectTable { private $tableGateway='t_project'; public function __construct(TableGatewayInterface $tableGateway) { $this->tableGateway = $tableGateway; } public function fetchAll() { return $this->tableGateway->select(); } I would like to join two tables, how can I do that, ist