本文整理汇总了PHP中Zend_Db_Select::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Select::reset方法的具体用法?PHP Zend_Db_Select::reset怎么用?PHP Zend_Db_Select::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Select
的用法示例。
在下文中一共展示了Zend_Db_Select::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _saveCustomerInfo
/**
* Saving information about customer
*
* @param Mage_Log_Model_Visitor $visitor
*
* @return Mage_Log_Model_Resource_Visitor
*/
protected function _saveCustomerInfo($visitor)
{
$adapter = $this->_getWriteAdapter();
if ($visitor->getDoCustomerLogout() && ($logId = $visitor->getCustomerLogId())) {
$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_read');
$select = new Zend_Db_Select($connection);
$select->from($resource->getTableName('log/customer'));
$select->reset(Zend_Db_Select::COLUMNS);
$select->columns('login_at');
$select->where('log_id = ?', $logId);
$loginAt = $connection->fetchOne($select);
if (!$loginAt) {
return parent::_saveCustomerInfo($visitor);
}
$data = new Varien_Object(array('login_at' => $loginAt, 'logout_at' => Mage::getSingleton('core/date')->gmtDate(), 'store_id' => (int) Mage::app()->getStore()->getId()));
$bind = $this->_prepareDataForTable($data, $this->getTable('log/customer'));
$condition = array('log_id = ?' => (int) $logId);
$adapter->update($this->getTable('log/customer'), $bind, $condition);
$visitor->setDoCustomerLogout(false);
$visitor->setCustomerId(null);
$visitor->setCustomerLogId(null);
} else {
return parent::_saveCustomerInfo($visitor);
}
return $this;
}
示例2: columns
/**
* Columns
*
* @param unknown_type $name
* @param unknown_type $cond
* @return WeFlex_Db_Model
*/
public function columns($cols)
{
$this->_selector->reset(Zend_Db_Select::COLUMNS);
foreach ($cols as $col) {
$this->_selector->columns($col, null);
}
return $this;
}
示例3: _renderOrders
/**
* Render sql select orders
*
* @return Varien_Data_Collection_Db
*/
protected function _renderOrders()
{
if (!$this->_isOrdersRendered) {
$this->_select->reset(Zend_Db_Select::ORDER);
foreach ($this->_orders as $field => $direction) {
$this->_select->order(new Zend_Db_Expr($field . ' ' . $direction));
}
$this->_isOrdersRendered = true;
}
return $this;
}
示例4: alias
/**
* Alias
*
* Sets an internal alias variable that is used if, and only if, we haven't operated a method on the internal
* $_select variable. This could be changed in the future so that alias() can be called at any time regardless,
* but that is more difficult and requires a deeper understanding of Zend_Db_Select internals.
*
* @access public
* @param string $alias - The alias to use for the table.
* @return SimpleDb_List object.
*/
public function alias($alias)
{
$this->_alias = $alias;
// In order to do the alias, we have to clear the FROM.
$this->_select->reset(Zend_Db_Select::FROM)->reset(Zend_Db_Select::COLUMNS)->from(array($this->_alias => $this->tableName()), $this->_fields);
// Now, since we cleared the FROM, we should go through and re-perform all the joins that were cleared out as well.
$joinHistory = $this->_joinHistory;
// Clearing the joinHistory because it will get re-populated when we perform the joins below.
unset($this->_joinHistory);
foreach ($joinHistory as $join) {
call_user_func_array(array($this->_select, $join['function']), $join['arguments']);
}
return $this;
}
示例5: onInstall
function onInstall()
{
//
// install content areas
//
$db = $this->getDb();
$select = new Zend_Db_Select($db);
//INSERT INTO `engine4_core_content` (`content_id`, `page_id`, `type`, `name`, `parent_content_id`, `order`, `params`) VALUES
// profile page
$select->from('engine4_core_pages')->where('name = ?', 'user_profile_index')->limit(1);
$page_id = $select->query()->fetchObject()->page_id;
// forum.profile-forum-posts
// Check if it's already been placed
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'widget')->where('name = ?', 'forum.profile-forum-posts');
$info = $select->query()->fetch();
if (empty($info)) {
// container_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'container')->limit(1);
$container_id = $select->query()->fetchObject()->content_id;
// middle_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('parent_content_id = ?', $container_id)->where('type = ?', 'container')->where('name = ?', 'middle')->limit(1);
$middle_id = $select->query()->fetchObject()->content_id;
// tab_id (tab container) may not always be there
$select->reset('where')->where('type = ?', 'widget')->where('name = ?', 'core.container-tabs')->where('page_id = ?', $page_id)->limit(1);
$tab_id = $select->query()->fetchObject();
if ($tab_id && @$tab_id->content_id) {
$tab_id = $tab_id->content_id;
} else {
$tab_id = null;
}
// tab on profile
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'forum.profile-forum-posts', 'parent_content_id' => $tab_id ? $tab_id : $middle_id, 'order' => 9, 'params' => '{"title":"Forum Posts","titleCount":true}'));
}
parent::onInstall();
}
示例6: resetLimit
/**
* Resets query limit
*
* @return Bvb_Grid_Source_Zend_Select
*/
public function resetLimit()
{
$this->_select->reset('limitcount');
$this->_select->reset('limitoffset');
return $this;
}
示例7: _setWhereClause
/**
* Set WHERE clause that checks for slug existence.
* @param Zend_Db_Select $select
* @param String $slugField
* @param String $slug
* @param Garp_Model_Db $model
* @param String $lang
* @return Void
*/
protected function _setWhereClause(Zend_Db_Select &$select, $slugField, $slug, Garp_Model_Db $model, $lang = null)
{
$slugField = $model->getAdapter()->quoteIdentifier($slugField);
$select->reset(Zend_Db_Select::WHERE)->where($slugField . ' = ?', $slug);
if ($lang) {
$select->where(Garp_Model_Behavior_Translatable::LANG_COLUMN . ' = ?', $lang);
}
}
示例8: _addUserProfileContent
protected function _addUserProfileContent() {
$db = $this -> getDb();
$select = new Zend_Db_Select($db);
// profile page
$select -> from('engine4_core_pages') -> where('name = ?', 'user_profile_index') -> limit(1);
$page_id = $select -> query() -> fetchObject() -> page_id;
// video.profile-videos
// Check if it's already been placed
$select = new Zend_Db_Select($db);
$select -> from('engine4_core_content') -> where('page_id = ?', $page_id) -> where('type = ?', 'widget') -> where('name = ?', 'ynvideo.profile-videos');
$infoProfileVideos = $select -> query() -> fetch();
if (empty($infoProfileVideos)) {
$this -> _insertWidgetToProfileContent($page_id, 'ynvideo.profile-videos', '{"title":"Videos","titleCount":true}', 12);
}
// check if the profile video widget of SE video existed or not,
// it it is existed, then delete it from the user profie page
$select = new Zend_Db_Select($db);
$select -> from('engine4_core_content') -> where('page_id = ?', $page_id) -> where('type = ?', 'widget') -> where('name = ?', 'video.profile-videos');
$infoSEProfileVideos = $select -> query() -> fetch();
if (!empty($infoSEProfileVideos)) {
$db -> delete('engine4_core_content', array("content_id = {$infoSEProfileVideos['content_id']}"));
}
// video.profile-favorite-videos
// Check if it's already been placed
$select -> reset('where') -> where('page_id = ?', $page_id) -> where('type = ?', 'widget') -> where('name = ?', 'ynvideo.profile-favorite-videos');
$infoProfileFavoriteVideos = $select -> query() -> fetch();
if (empty($infoProfileFavoriteVideos)) {
$this -> _insertWidgetToProfileContent($page_id, 'ynvideo.profile-favorite-videos', '{"title":"Favorite Videos","titleCount":true}', 13);
}
// video.profile-video-playlists
// Check if it's already been placed
$select -> reset('where') -> where('page_id = ?', $page_id) -> where('type = ?', 'widget') -> where('name = ?', 'ynvideo.profile-video-playlists');
$infoProfileFavoriteVideos = $select -> query() -> fetch();
if (empty($infoProfileFavoriteVideos)) {
$this -> _insertWidgetToProfileContent($page_id, 'ynvideo.profile-video-playlists', '{"title":"Video Playlists","titleCount":true}', 14);
}
}
示例9: onInstall
function onInstall()
{
//
// install content areas
//
$db = $this->getDb();
$select = new Zend_Db_Select($db);
//INSERT INTO `engine4_core_content` (`content_id`, `page_id`, `type`, `name`, `parent_content_id`, `order`, `params`) VALUES
// profile page
$select->from('engine4_core_pages')->where('name = ?', 'user_profile_index')->limit(1);
$page_id = $select->query()->fetchObject()->page_id;
// group.profile-groups
// Check if it's already been placed
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'widget')->where('name = ?', 'group.profile-groups');
$info = $select->query()->fetch();
if (empty($info)) {
// container_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'container')->limit(1);
$container_id = $select->query()->fetchObject()->content_id;
// middle_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('parent_content_id = ?', $container_id)->where('type = ?', 'container')->where('name = ?', 'middle')->limit(1);
$middle_id = $select->query()->fetchObject()->content_id;
// tab_id (tab container) may not always be there
$select->reset('where')->where('type = ?', 'widget')->where('name = ?', 'core.container-tabs')->where('page_id = ?', $page_id)->limit(1);
$tab_id = $select->query()->fetchObject();
if ($tab_id && @$tab_id->content_id) {
$tab_id = $tab_id->content_id;
} else {
$tab_id = null;
}
// tab on profile
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-groups', 'parent_content_id' => $tab_id ? $tab_id : $middle_id, 'order' => 9, 'params' => '{"title":"Groups","titleCount":true}'));
}
//
// Group main page
//
// page
// Check if it's already been placed
$select = new Zend_Db_Select($db);
$select->from('engine4_core_pages')->where('name = ?', 'group_profile_index')->limit(1);
$info = $select->query()->fetch();
if (empty($info)) {
$db->insert('engine4_core_pages', array('name' => 'group_profile_index', 'displayname' => 'Group Profile', 'title' => 'Group Profile', 'description' => 'This is the profile for an group.', 'custom' => 0));
$page_id = $db->lastInsertId('engine4_core_pages');
// containers
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'container', 'name' => 'main', 'parent_content_id' => null, 'order' => 1, 'params' => ''));
$container_id = $db->lastInsertId('engine4_core_content');
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'container', 'name' => 'middle', 'parent_content_id' => $container_id, 'order' => 3, 'params' => ''));
$middle_id = $db->lastInsertId('engine4_core_content');
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'container', 'name' => 'left', 'parent_content_id' => $container_id, 'order' => 1, 'params' => ''));
$left_id = $db->lastInsertId('engine4_core_content');
// middle column
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'core.container-tabs', 'parent_content_id' => $middle_id, 'order' => 2, 'params' => '{"max":"6"}'));
$tab_id = $db->lastInsertId('engine4_core_content');
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-status', 'parent_content_id' => $middle_id, 'order' => 1, 'params' => ''));
// left column
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-photo', 'parent_content_id' => $left_id, 'order' => 1, 'params' => ''));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-options', 'parent_content_id' => $left_id, 'order' => 2, 'params' => ''));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-info', 'parent_content_id' => $left_id, 'order' => 3, 'params' => ''));
// tabs
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'activity.feed', 'parent_content_id' => $tab_id, 'order' => 1, 'params' => '{"title":"Updates"}'));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-members', 'parent_content_id' => $tab_id, 'order' => 2, 'params' => '{"title":"Members","titleCount":true}'));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-photos', 'parent_content_id' => $tab_id, 'order' => 3, 'params' => '{"title":"Photos","titleCount":true}'));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-discussions', 'parent_content_id' => $tab_id, 'order' => 4, 'params' => '{"title":"Discussions","titleCount":true}'));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'core.profile-links', 'parent_content_id' => $tab_id, 'order' => 5, 'params' => '{"title":"Links","titleCount":true}'));
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'group.profile-events', 'parent_content_id' => $tab_id, 'order' => 6, 'params' => '{"title":"Events","titleCount":true}'));
}
parent::onInstall();
}
示例10: find
//.........这里部分代码省略.........
}
}
// Adjust query based on returnCount
if ($returnCount) {
if (is_array($returnCount)) {
if ($subOp) {
} else {
// return count on grouped columns
foreach ($returnCount as $key => $property) {
$fieldmodifier = null;
if ($this->_mapper) {
$class = $property->getParent() ? $property->getParent()->getId() : $collection->getDataObject()->getClass();
$field = $this->_mapper->propertyToDatastoreName($class, $property->getId());
} else {
$field = $property->getId();
}
if ($property instanceof ObjectProperty) {
// join with $key if necessary
if (strstr($key, '.') !== false) {
$leftPart = substr($key, 0, strpos($key, '.'));
$intermediateProp = $collection->getDataObject()->getProperty($leftPart);
$fieldmodifier = $this->_join($intermediateProp, $table) . '.' . $field;
}
}
// limit date grouping to date part, omitting possible hour part
if ($property instanceof DateProperty) {
$fieldmodifier = "DATE({$field})";
}
$this->_select->group($fieldmodifier ? $fieldmodifier : $field);
$this->_select->columns(array($field => $fieldmodifier ? $fieldmodifier : $field));
}
}
} else {
$this->_select->reset('group');
}
} else {
$this->_select->limit($collection->getBoundaryBatch() != -1 ? $collection->getBoundaryBatch() : null, $collection->getBoundaryOffset());
/**
* Sorting part
*/
foreach ($collection->getSortings() as $sorting) {
$slUniqext = $slTable = null;
// Specific cases first
// @todo find a better way to sort on meta properties
if ($sorting[0]->getId() == ObjectUri::IDENTIFIER || $sorting[0] instanceof MetaProperty) {
$id = Backend::DEFAULT_PKEY;
$this->_select->order(new \Zend_Db_Expr($table . '.' . $id . ' ' . $sorting[1]));
continue;
} else {
if ($sorting[0] instanceof Property\CollectionProperty) {
// handling of conditions based on collection limited to withMembers() and withoutMembers()
$leftkey = $sorting[0]->getParameter('keyprop');
//$field = $property->getId();
$subSelect = $this->_ressource->select();
$subseltbl = $this->_mapper ? $this->_mapper->getDatastore($sorting[0]->getParameter('instanceof')) : $this->_getTableFromClass($sorting[0]->getParameter('instanceof'));
$subSelect->from($subseltbl, new \Zend_Db_Expr(sprintf("COUNT(%s)", $leftkey)));
$join = sprintf("%s.%s = %s", $subseltbl, $leftkey, $pkey);
$subSelect->where($join);
// $statement = $this->_buildConditionStatement(new \Zend_Db_Expr(sprintf("(%s)", $subSelect)), $condition->getClauses(), $conditionArray[1]);
$this->_select->order(new \Zend_Db_Expr('(' . $subSelect->__toString() . ') ' . $sorting[1]));
continue;
} else {
if ($sorting[0] instanceof Property\ObjectProperty) {
// find which property to sort by
if ($sorting[0]->getParameter('sorting')) {
$sprops = array_keys($sorting[0]->getParameter('sorting'));
示例11: addOrderClause
/**
* Modify the order clause to reflect the record's weight
* @param Zend_Db_Select $select
*/
public function addOrderClause(Zend_Db_Select &$select)
{
// Distill the WHERE class from the Select object
$where = $select->getPart(Zend_Db_Select::WHERE);
// Save the existing ORDER clause.
$originalOrder = $select->getPart(Zend_Db_Select::ORDER);
$select->reset(Zend_Db_Select::ORDER);
$alias = '';
if ($this->_modelAlias) {
$alias = $this->_modelAlias . '.';
}
/**
* If a registered foreign key (see self::_relationConfig) is found, this query is
* considered to be a related fetch() command, and an ORDER BY clause is added with
* the registered weight column.
*/
foreach ($where as $w) {
foreach ($this->_relationConfig as $model => $modelRelationConfig) {
if (strpos($w, $modelRelationConfig[self::FOREIGN_KEY_COLUMN_KEY]) !== false) {
$select->order($alias . $modelRelationConfig[self::WEIGHT_COLUMN_KEY] . ' DESC');
}
}
}
// Return the existing ORDER clause, only this time '<weight-column> DESC' will be in front of it
foreach ($originalOrder as $order) {
// [0] = column, [1] = direction
if (is_array($order)) {
$order = $order[0] . ' ' . $order[1];
}
$select->order($order);
}
}
示例12: onInstall
function onInstall()
{
//
// install content areas
//
$db = $this->getDb();
$select = new Zend_Db_Select($db);
// profile page
$select->from('engine4_core_pages')->where('name = ?', 'user_profile_index')->limit(1);
$page_id = $select->query()->fetchObject()->page_id;
// video.profile-videos
// Check if it's already been placed
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'widget')->where('name = ?', 'video.profile-videos');
$info = $select->query()->fetch();
if (empty($info)) {
// container_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('page_id = ?', $page_id)->where('type = ?', 'container')->limit(1);
$container_id = $select->query()->fetchObject()->content_id;
// middle_id (will always be there)
$select = new Zend_Db_Select($db);
$select->from('engine4_core_content')->where('parent_content_id = ?', $container_id)->where('type = ?', 'container')->where('name = ?', 'middle')->limit(1);
$middle_id = $select->query()->fetchObject()->content_id;
// tab_id (tab container) may not always be there
$select->reset('where')->where('type = ?', 'widget')->where('name = ?', 'core.container-tabs')->where('page_id = ?', $page_id)->limit(1);
$tab_id = $select->query()->fetchObject();
if ($tab_id && @$tab_id->content_id) {
$tab_id = $tab_id->content_id;
} else {
$tab_id = null;
}
// tab on profile
$db->insert('engine4_core_content', array('page_id' => $page_id, 'type' => 'widget', 'name' => 'video.profile-videos', 'parent_content_id' => $tab_id ? $tab_id : $middle_id, 'order' => 12, 'params' => '{"title":"Videos","titleCount":true}'));
}
// Check ffmpeg path for correctness
if (function_exists('exec') && function_exists('shell_exec')) {
// Api is not available
//$ffmpeg_path = Engine_Api::_()->getApi('settings', 'core')->video_ffmpeg_path;
$ffmpeg_path = $db->select()->from('engine4_core_settings', 'value')->where('name = ?', 'video.ffmpeg.path')->limit(1)->query()->fetchColumn(0);
$output = null;
$return = null;
if (!empty($ffmpeg_path)) {
exec($ffmpeg_path . ' -version', $output, $return);
}
// Try to auto-guess ffmpeg path if it is not set correctly
$ffmpeg_path_original = $ffmpeg_path;
if (empty($ffmpeg_path) || $return > 0 || stripos(join('', $output), 'ffmpeg') === false) {
$ffmpeg_path = null;
// Windows
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
// @todo
} else {
$output = null;
$return = null;
@exec('which ffmpeg', $output, $return);
if (0 == $return) {
$ffmpeg_path = array_shift($output);
$output = null;
$return = null;
exec($ffmpeg_path . ' -version', $output, $return);
if (0 == $return) {
$ffmpeg_path = null;
}
}
}
}
if ($ffmpeg_path != $ffmpeg_path_original) {
$count = $db->update('engine4_core_settings', array('value' => $ffmpeg_path), array('name = ?' => 'video.ffmpeg.path'));
if ($count === 0) {
try {
$db->insert('engine4_core_settings', array('value' => $ffmpeg_path, 'name' => 'video.ffmpeg.path'));
} catch (Exception $e) {
}
}
}
}
parent::onInstall();
}
示例13: _modifySearchQuery
protected function _modifySearchQuery(Zend_Db_Select &$select, $model)
{
$where = $select->getPart(Zend_Db_Select::WHERE);
if (!$where) {
return;
}
$select->reset(Zend_Db_Select::WHERE);
foreach ($where as $clause) {
// Check if it's a search query
if (stripos($clause, 'like') !== false) {
preg_match('/%.*?%/', $clause, $matches);
if (!empty($matches[0])) {
$clause = $this->_cleanClause($clause);
$clause .= ' OR ' . $this->_joinCmsSearchQuery($model, $select, $matches[0]);
}
}
// re-attach clause
$whereBoolType = $this->_determineAndOrOr($clause);
$clause = preg_replace('/(^OR|^AND)/', '', $clause);
$clause = $this->_cleanClause($clause);
if ($whereBoolType === 'OR') {
$select->orWhere($clause);
continue;
}
$select->where($clause);
}
}
示例14: _getPurchaseNumber
/**
* Calculate number of purchase from invited customers
*
* @param Zend_Db_Select $select
* @return bool|int
*/
protected function _getPurchaseNumber($select)
{
/* var $select Zend_Db_Select */
$select->reset(Zend_Db_Select::COLUMNS)->joinRight(array('o' => $this->getTable('sales/order')), 'o.customer_id = main_table.referral_id AND o.store_id = main_table.store_id', array('cnt' => 'COUNT(main_table.invitation_id)'));
return $this->getConnection()->fetchOne($select);
}
示例15: getDetailByJobId
function getDetailByJobId($jobid)
{
if ($this->isJobIdExists($jobid)) {
$select = new Zend_Db_Select($this->db);
$select->distinct();
switch ($this->db_adapter) {
case 'PDO_MYSQL':
$select->from(array('j' => 'Job'), array('JobId', 'Job', 'Name', 'Level', 'ClientId', 'StartTime' => "DATE_FORMAT(j.StartTime, '%y-%b-%d %H:%i')", 'EndTime' => "DATE_FORMAT(j.EndTime, '%y-%b-%d %H:%i')", 'SchedTime' => "DATE_FORMAT(j.SchedTime, '%y-%b-%d %H:%i')", 'VolSessionId', 'VolSessionTime', 'JobFiles', 'JobBytes', 'JobErrors', 'PoolId', 'FileSetId', 'PurgedFiles', 'JobStatus', 'Type', 'DurationTime' => 'TIMEDIFF(EndTime, StartTime)', 'PriorJobId', 'Reviewed', 'Comment'));
$select->joinLeft(array('s' => 'Status'), 'j.JobStatus = s.JobStatus', array('JobStatusLong' => 'JobStatusLong'));
break;
case 'PDO_PGSQL':
// PostgreSQL
// http://www.postgresql.org/docs/8.0/static/functions-datetime.html
$select->from(array('j' => 'Job'), array('JobId', 'Job', 'Name', 'Level', 'ClientId', 'StartTime', 'EndTime', 'SchedTime', 'VolSessionId', 'VolSessionTime', 'JobFiles', 'JobBytes', 'JobErrors', 'PoolId', 'FileSetId', 'PurgedFiles', 'JobStatus', 'Type', 'DurationTime' => '(EndTime - StartTime)', 'PriorJobId', 'Reviewed', 'Comment'));
$select->joinLeft(array('s' => 'Status'), 'j.JobStatus = s.JobStatus', array('JobStatusLong' => 'JobStatusLong'));
break;
case 'PDO_SQLITE':
// SQLite3 Documentation
// http://sqlite.org/lang_datefunc.html
// bug http://framework.zend.com/issues/browse/ZF-884
// http://sqlite.org/pragma.html
//$res = $db->query('PRAGMA short_column_names=1'); // not affected
//$res = $db->query('PRAGMA full_column_names=0'); // not affected
$select->from(array('j' => 'Job'), array('jobid' => 'JobId', 'job' => 'Job', 'name' => 'Name', 'level' => 'Level', 'clientid' => 'ClientId', 'starttime' => 'StartTime', 'endtime' => 'EndTime', 'schedtime' => 'SchedTime', 'volsessionid' => 'VolSessionId', 'volsessiontime' => 'VolSessionTime', 'jobfiles' => 'JobFiles', 'jobbytes' => 'JobBytes', 'joberrors' => 'JobErrors', 'poolid' => 'PoolId', 'filesetid' => 'FileSetId', 'purgedfiles' => 'PurgedFiles', 'jobstatus' => 'JobStatus', 'type' => 'Type', 'DurationTime' => "(strftime('%H:%M:%S',strftime('%s',EndTime) - strftime('%s',StartTime),'unixepoch'))", 'priorjobid' => 'PriorJobId', 'reviewed' => 'Reviewed', 'comment' => 'Comment'));
$select->joinLeft(array('s' => 'Status'), 'j.JobStatus = s.JobStatus', array('jobstatuslong' => 'JobStatusLong'));
break;
}
$select->joinLeft(array('c' => 'Client'), 'j.ClientId = c.ClientId', array('ClientName' => 'Name', 'ClientUName' => 'UName'));
$select->joinLeft(array('p' => 'Pool'), 'j.PoolId = p.PoolId', array('PoolName' => 'Name'));
$select->joinLeft(array('f' => 'FileSet'), 'j.FileSetId = f.FileSetId', array('FileSetName' => 'FileSet', 'FileSetCreateTime' => 'CreateTime'));
$select->joinLeft(array('sd' => 'webacula_jobdesc'), 'j.Name = sd.name_job');
$select->where("j.JobId = ?", $jobid);
//$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
$stmt = $select->query();
$aresult['job'] = $stmt->fetchAll();
$select->reset();
unset($select);
unset($stmt);
// list volumes
$select = new Zend_Db_Select($this->db);
switch ($this->db_adapter) {
case 'PDO_SQLITE':
// bug http://framework.zend.com/issues/browse/ZF-884
$select->distinct();
$select->from(array('j' => 'JobMedia'), array('mediaid' => 'MediaId'));
$select->joinInner(array('m' => 'Media'), 'j.MediaId = m.MediaId', array('volumename' => 'VolumeName'));
$select->where("j.JobId = ?", $jobid);
break;
default:
// mysql, postgresql
$select->distinct();
$select->from(array('j' => 'JobMedia'), array('MediaId'));
$select->joinInner(array('m' => 'Media'), 'j.MediaId = m.MediaId', array('VolumeName'));
$select->where("j.JobId = ?", $jobid);
}
//$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
$stmt = $select->query();
$aresult['volume'] = $stmt->fetchAll();
$select->reset();
unset($select);
unset($stmt);
return $aresult;
}
}