Posts Tagged ‘SQL’
Grouping orWhere elements in Zend Framework Zend_Db_select
Practicly each time I am working with Zend_Db_Select (with Table or without it) I am searching for how easy to group orWhere elements.
After lot’s of searching and try and error’s I have come to this code:
if (false !== $this->_customSearchKeyword) {
$searchFields = array(‘p.photo_name’, ‘p.photo_desc’);
$keywordWhere = array();
if (!empty($searchFields)) {
foreach ($searchFields as $searchField) {
$searchField = $db0->quoteIdentifier($searchField);
$keywordWhere[] = ‘(‘ . $db0->quoteInto(“$searchField = ?”,
$this->_customSearchKeyword) . ‘)’;
}
$select->where( implode(‘ OR ‘, $keywordWhere) );
}
}
I hope that would be of some help to somebody 🙂 more then me I mean
Get Microsoft Sql table list form PHP
One of the things I lost time today was how to get the list of table from Ms SQL server from PHP on Unix (Ubuntu).
I will write another post how to connect to it later, but currently what I have found is that MsSQL does not have “SHOW TABLES” command like MySQL do.
In order to get the list of table we need to send:
select name from sysobjects where xtype = ‘U’
This way we would get all of the user tables in our database.