本文整理汇总了PHP中Tinebase_Core::getDb方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::getDb方法的具体用法?PHP Tinebase_Core::getDb怎么用?PHP Tinebase_Core::getDb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Core
的用法示例。
在下文中一共展示了Tinebase_Core::getDb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
$this->objects['sharedContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
$_SERVER['REQUEST_URI'] = 'lars';
}
示例2: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$_SERVER['HTTP_USER_AGENT'] = 'FooBar User Agent';
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(FALSE);
$this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId())));
}
示例3: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
* @throws Tinebase_Exception_NotFound
*/
public function appendFilterSql($_select, $_backend)
{
// quote field identifier, set action and replace wildcards
$field = $this->_getQuotedFieldName($_backend);
$action = $this->_opSqlMap[$this->_operator];
$value = $this->_replaceWildcards($this->_value);
// check if group by is operator and return if this is the case
if ($this->_operator == 'group') {
$_select->group($this->_field);
}
if (in_array($this->_operator, array('in', 'notin')) && !is_array($value)) {
$value = explode(' ', $value);
}
if (is_array($value) && empty($value)) {
$_select->where('1=' . (substr($this->_operator, 0, 3) == 'not' ? '1/* empty query */' : '0/* impossible query */'));
return;
}
$where = Tinebase_Core::getDb()->quoteInto($field . $action['sqlop'], $value);
if (in_array($this->_operator, array('not', 'notin')) && $value !== '') {
$where = "( {$where} OR {$field} IS NULL)";
}
if (in_array($this->_operator, array('equals', 'contains', 'startswith', 'endswith', 'in')) && $value === '') {
$where = "( {$where} OR {$field} IS NULL)";
}
// finally append query to select object
$_select->where($where);
}
示例4: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
*/
public function appendFilterSql($_select, $_backend)
{
// prepare value
if ($this->_operator === 'equals' && empty($this->_value)) {
// @see 0009362: allow to filter for empty datetimes
$operator = 'isnull';
$value = array($this->_value);
} else {
$operator = $this->_operator;
$value = $this->_getDateValues($operator, $this->_value);
if (!is_array($value)) {
// NOTE: (array) null is an empty array
$value = array($value);
}
}
// quote field identifier
$field = $this->_getQuotedFieldName($_backend);
$db = Tinebase_Core::getDb();
$dbCommand = Tinebase_Backend_Sql_Command::factory($db);
// append query to select object
foreach ((array) $this->_opSqlMap[$operator]['sqlop'] as $num => $operator) {
if (isset($value[$num]) || array_key_exists($num, $value)) {
if (get_parent_class($this) === 'Tinebase_Model_Filter_Date' || in_array($operator, array('isnull', 'notnull'))) {
$_select->where($field . $operator, $value[$num]);
} else {
$_select->where($dbCommand->setDate($field) . $operator, new Zend_Db_Expr($dbCommand->setDateValue($value[$num])));
}
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' No filter value found, skipping operator: ' . $operator);
}
}
}
}
示例5: __construct
/**
* constructor
*/
public function __construct()
{
$this->_db = Tinebase_Core::getDb();
$this->_dbCommand = Tinebase_Backend_Sql_Command::factory($this->_db);
// temporary on the fly creation of table
$this->_dbTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'relations', 'primary' => 'id'));
}
示例6: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_contactController = Addressbook_Controller_Contact::getInstance();
$this->_contractController = Sales_Controller_Contract::getInstance();
$this->_json = new Sales_Frontend_Json();
}
示例7: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_backend = new Tasks_Frontend_Json();
$this->_smtpConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::SMTP, new Tinebase_Config_Struct())->toArray();
$this->_smtpTransport = Tinebase_Smtp::getDefaultTransport();
}
示例8: setUp
/**
* set up tests
*/
protected function setUp()
{
$this->_transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(false);
$this->_personas = Zend_Registry::get('personas');
$this->_originalTestUser = Tinebase_Core::getUser();
}
示例9: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->_transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_instance = Tinebase_CustomField::getInstance();
Sales_Controller_Contract::getInstance()->setNumberPrefix();
Sales_Controller_Contract::getInstance()->setNumberZerofill();
}
示例10: setUp
/**
* Sets up the fixture.
*
* This method is called before a test is executed.
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
// we need that because the voip db tables can have a different prefix
Tinebase_Core::set('voipdbTablePrefix', SQL_TABLE_PREFIX);
$phoneId = Tinebase_Record_Abstract::generateUID();
$this->_objects['location'] = new Voipmanager_Model_Snom_Location(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'registrar' => 'registrar'));
$this->_objects['software'] = new Voipmanager_Model_Snom_Software(array('id' => Tinebase_Record_Abstract::generateUID()));
$this->_objects['setting'] = new Voipmanager_Model_Snom_Setting(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => Tinebase_Record_Abstract::generateUID(), 'description' => Tinebase_Record_Abstract::generateUID(), 'language_w' => true));
$this->_objects['phonesettings'] = new Voipmanager_Model_Snom_PhoneSettings(array('phone_id' => $phoneId, 'language' => 'Deutsch'));
$this->_objects['template'] = new Voipmanager_Model_Snom_Template(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'software_id' => $this->_objects['software']->getId(), 'setting_id' => $this->_objects['setting']->getId()));
$this->_objects['phone'] = new Voipmanager_Model_Snom_Phone(array('id' => $phoneId, 'macaddress' => "1234567890cd", 'location_id' => $this->_objects['location']->getId(), 'template_id' => $this->_objects['template']->getId(), 'current_model' => 'snom320', 'redirect_event' => 'none'));
$this->_objects['phoneOwner'] = array('account_id' => Zend_Registry::get('currentAccount')->getId(), 'account_type' => 'user');
$rights = new Tinebase_Record_RecordSet('Voipmanager_Model_Snom_PhoneRight', array($this->_objects['phoneOwner']));
$this->_objects['phone']->rights = $rights;
// create phone, location, template
$snomLocationBackend = new Voipmanager_Backend_Snom_Location();
$snomTemplateBackend = new Voipmanager_Backend_Snom_Template();
$snomSoftwareBackend = new Voipmanager_Backend_Snom_Software();
$snomPhoneBackend = new Voipmanager_Backend_Snom_Phone();
$snomSettingBackend = new Voipmanager_Backend_Snom_Setting();
$snomPhoneSettingsBackend = new Voipmanager_Backend_Snom_PhoneSettings();
$snomSoftwareBackend->create($this->_objects['software']);
$snomLocationBackend->create($this->_objects['location']);
$snomTemplateBackend->create($this->_objects['template']);
$snomSettingBackend->create($this->_objects['setting']);
$snomPhoneBackend->create($this->_objects['phone']);
$snomPhoneSettingsBackend->create($this->_objects['phonesettings']);
}
示例11: __construct
/**
* get a new single filter action
*
* @param string|array $_fieldOrData
* @param string $_operator
* @param mixed $_value
* @param array $_options
*
* @todo remove legacy code + obsolete params sometimes
*/
public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, array $_options = array())
{
$this->_db = Tinebase_Core::getDb();
$this->_dbCommand = Tinebase_Backend_Sql_Command::factory($this->_db);
if (is_array($_fieldOrData)) {
$data = $_fieldOrData;
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Using deprecated constructor syntax. Please pass all filter data in one array (filter field: ' . $_fieldOrData . ').');
}
$data = array('field' => $_fieldOrData, 'operator' => $_operator, 'value' => $_value, 'options' => $_options);
}
foreach (array('field', 'operator', 'value') as $requiredKey) {
if (!(isset($data[$requiredKey]) || array_key_exists($requiredKey, $data))) {
throw new Tinebase_Exception_InvalidArgument('Filter object needs ' . $requiredKey);
}
}
$this->_setOptions(isset($data['options']) ? $data['options'] : array());
$this->setField($data['field']);
$this->setOperator($data['operator']);
$this->setValue($data['value']);
if (isset($data['id'])) {
$this->setId($data['id']);
}
if (isset($data['label'])) {
$this->setLabel($data['label']);
}
}
示例12: setUp
/**
* (non-PHPdoc)
* @see ActiveSync/ActiveSync_TestCase::setUp()
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_deviceBackend = new ActiveSync_Backend_DeviceFacade();
$this->_folderBackend = new ActiveSync_Backend_FolderFacade();
$this->_device = $this->_deviceBackend->create(ActiveSync_Backend_DeviceTests::getTestDevice());
}
示例13: __construct
/**
* the constructor
*
* disabled. use the singleton
* temporarly the constructor also creates the needed tables on demand and fills them with some initial values
*/
private function __construct()
{
$this->_rolesTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'roles'));
$this->_roleMembersTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'role_accounts'));
$this->_roleRightsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'role_rights'));
$this->_db = Tinebase_Core::getDb();
}
示例14: setUp
/**
* Sets up the fixture.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
$this->_backend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
$personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
$this->_container = $personalContainer[0];
}
示例15: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
*/
public function appendFilterSql($_select, $_backend)
{
if (empty($this->_value)) {
$_select->where('1=1/* empty query */');
return;
}
$db = Tinebase_Core::getDb();
switch ($this->_operator) {
case 'contains':
case 'equals':
case 'startswith':
$queries = explode(' ', $this->_value);
foreach ($queries as $query) {
$whereParts = array();
foreach ($this->_options['fields'] as $qField) {
// if field has . in name, then we already have tablename
if (strpos($qField, '.') !== FALSE) {
$whereParts[] = Tinebase_Backend_Sql_Command::factory($db)->prepareForILike(Tinebase_Backend_Sql_Command::factory($db)->getUnaccent($db->quoteIdentifier($qField))) . ' ' . Tinebase_Backend_Sql_Command::factory($db)->getLike() . Tinebase_Backend_Sql_Command::factory($db)->prepareForILike(Tinebase_Backend_Sql_Command::factory($db)->getUnaccent('(?)'));
} else {
$whereParts[] = Tinebase_Backend_Sql_Command::factory($db)->prepareForILike(Tinebase_Backend_Sql_Command::factory($db)->getUnaccent($db->quoteIdentifier($_backend->getTableName() . '.' . $qField))) . ' ' . Tinebase_Backend_Sql_Command::factory($db)->getLike() . Tinebase_Backend_Sql_Command::factory($db)->prepareForILike(Tinebase_Backend_Sql_Command::factory($db)->getUnaccent('(?)'));
}
}
$whereClause = '';
if (!empty($whereParts)) {
$whereClause = implode(' OR ', $whereParts);
}
if (!empty($whereClause)) {
if ($this->_operator == 'equals') {
$_select->where($db->quoteInto($whereClause, trim($query)));
} else {
if ($this->_operator == 'startswith') {
$_select->where($db->quoteInto($whereClause, trim($query) . '%'));
} else {
$_select->where($db->quoteInto($whereClause, '%' . trim($query) . '%'));
}
}
}
}
break;
case 'in':
foreach ($this->_options['fields'] as $qField) {
// if field has . in name, then we allready have tablename
if (strpos($qField, '.') !== FALSE) {
$whereParts[] = $db->quoteInto($db->quoteIdentifier($qField) . ' IN (?)', (array) $this->_value);
} else {
$whereParts[] = $db->quoteInto($db->quoteIdentifier($_backend->getTableName() . '.' . $qField) . ' IN (?)', (array) $this->_value);
}
}
if (!empty($whereParts)) {
$whereClause = implode(' OR ', $whereParts);
}
if (!empty($whereClause)) {
$_select->where($whereClause);
}
break;
default:
throw new Tinebase_Exception_InvalidArgument('Operator not defined: ' . $this->_operator);
}
}