本文整理汇总了PHP中iaDb::printf方法的典型用法代码示例。如果您正苦于以下问题:PHP iaDb::printf方法的具体用法?PHP iaDb::printf怎么用?PHP iaDb::printf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaDb
的用法示例。
在下文中一共展示了iaDb::printf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _gridRead
protected function _gridRead($params)
{
$output = array();
$iaDb =& $this->_iaDb;
switch ($params['get']) {
case 'plugins':
if ($plugins = $this->_iaDb->onefield('name', null, null, null, 'extras')) {
$output['data'][] = array('value' => iaCore::CORE, 'title' => iaLanguage::get('core', 'Core'));
foreach ($plugins as $plugin) {
$output['data'][] = array('value' => $plugin, 'title' => iaLanguage::get($plugin, ucfirst($plugin)));
}
}
break;
case 'comparison':
if (isset($params['lang1']) && isset($params['lang2']) && $params['lang1'] != $params['lang2'] && array_key_exists($params['lang1'], $this->_iaCore->languages) && array_key_exists($params['lang2'], $this->_iaCore->languages)) {
$start = isset($params['start']) ? (int) $params['start'] : 0;
$limit = isset($params['limit']) ? (int) $params['limit'] : 15;
$values = array();
if (!empty($params['key'])) {
$conditions[] = '`key` LIKE :key OR `value` LIKE :key';
$values['key'] = '%' . $params['key'] . '%';
}
if (!empty($params['category'])) {
$conditions[] = '`category` = :category';
$values['category'] = $params['category'];
}
if (!empty($params['plugin'])) {
if (iaCore::CORE == $params['plugin']) {
$params['plugin'] = '';
}
$conditions[] = '`extras` = :plugin';
$values['plugin'] = $params['plugin'];
}
$where = empty($conditions) ? iaDb::EMPTY_CONDITION : implode(' AND ', $conditions);
$iaDb->bind($where, $values);
$rows = $iaDb->all('SQL_CALC_FOUND_ROWS DISTINCT `key`, `category`', $where, $start, $limit);
$output = array('data' => array(), 'total' => $iaDb->foundRows());
$keys = array();
foreach ($rows as $row) {
$keys[] = $row['key'];
}
$stmt = "`code` = ':lang' AND `key` IN('" . implode("','", $keys) . "')";
$lang1 = $iaDb->keyvalue(array('key', 'value'), iaDb::printf($stmt, array('lang' => $params['lang1'])));
$lang2 = $iaDb->keyvalue(array('key', 'value'), iaDb::printf($stmt, array('lang' => $params['lang2'])));
foreach ($rows as $row) {
$key = $row['key'];
$output['data'][] = array('key' => $key, 'lang1' => isset($lang1[$key]) ? $lang1[$key] : null, 'lang2' => isset($lang2[$key]) ? $lang2[$key] : null, 'category' => $row['category']);
}
}
break;
default:
$params['lang'] = isset($_GET['lang']) && array_key_exists($_GET['lang'], $this->_iaCore->languages) ? $_GET['lang'] : $this->_iaCore->iaView->language;
$output = parent::_gridRead($params);
}
return $output;
}
示例2: url
public function url($action, $data = array())
{
$data['action'] = $action;
$data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
if (!isset($this->_patterns[$action])) {
$action = 'view';
}
$url = iaDb::printf($this->_patterns[$action], $data);
return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
}
示例3: url
public function url($action, $data = array(), $generate = false)
{
$data['action'] = $action;
$data['alias'] = isset($data['album_alias']) ? $data['album_alias'] : $data['title_alias'];
if (!isset($this->patterns[$action])) {
$action = 'view';
}
$url = iaDb::printf($this->patterns[$action], $data);
return self::get('url') . $url;
}
示例4: _entryDelete
protected function _entryDelete($entryId)
{
$row = $this->_iaDb->row(array('name', 'item'), iaDb::convertIds($entryId));
$result = parent::_entryDelete($entryId);
if ($result && $row) {
$stmt = iaDb::printf("`key` = 'fieldgroup_:name' OR `key` = 'fieldgroup_description_:item_:name'", $row);
$this->_iaDb->delete($stmt, iaLanguage::getTable());
}
return $result;
}
示例5: _gridQuery
protected function _gridQuery($columns, $where, $order, $start, $limit)
{
foreach (array('amount', 'gateway', 'status') as $joinedColumnName) {
if (false !== stripos($order, $joinedColumnName)) {
$order = str_replace(' i.`', ' t.`', $order);
break;
}
}
$sql = 'SELECT SQL_CALC_FOUND_ROWS ' . 'i.`id`, i.`date_created`, i.`fullname`, ' . 't.`plan_id`, t.`operation`, ' . 't.`status`, CONCAT(t.`amount`, " ", t.`currency`) `amount`, t.`currency`, t.`gateway`, ' . "1 `pdf`, 1 `update`, IF(t.`status` != 'passed', 1, 0) `delete` " . 'FROM `:prefix:table_invoices` i ' . 'LEFT JOIN `:prefix:table_transactions` t ON (t.`id` = i.`transaction_id`) ' . 'LEFT JOIN `:prefix:table_members` m ON (m.`id` = t.`member_id`) ' . ($where ? 'WHERE ' . $where . ' ' : '') . $order . ' ' . 'LIMIT :start, :limit';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_invoices' => self::getTable(), 'table_members' => iaUsers::getTable(), 'table_transactions' => 'payment_transactions', 'start' => $start, 'limit' => $limit));
return $this->_iaDb->getAll($sql);
}
示例6: getAddress
public function getAddress($transactionId)
{
$invoice = $this->getBy('transaction_id', $transactionId);
if ($invoice && $invoice['address1']) {
return $invoice;
}
// else return an address of the latest populated transaction
$iaTransaction = $this->iaCore->factory('transaction');
$sql = 'SELECT SQL_CALC_FOUND_ROWS i.`address1`, i.`address2`, i.`zip`, i.`country` ' . 'FROM `:prefix:table_transactions` t ' . 'LEFT JOIN `:prefix:table_invoices` i ON (i.`transaction_id` = t.`id`) ' . 'WHERE t.`member_id` = :member AND i.`address1` != "" ' . 'ORDER BY t.`date` DESC ' . 'LIMIT 1';
$sql = iaDb::printf($sql, array('prefix' => $this->iaDb->prefix, 'table_transactions' => $iaTransaction::getTable(), 'table_invoices' => self::getTable(), 'member' => iaUsers::getIdentity()->id));
$row = $this->iaDb->getRow($sql);
return $row ? $row : array('address1' => '', 'address2' => '', 'zip' => '', 'country' => '');
}
示例7: url
public function url($action, $data = array(), $generate = false)
{
$data['action'] = $action;
$data['alias'] = isset($data['artist_alias']) ? $data['artist_alias'] : $data['title_alias'];
if (!isset($this->patterns[$action])) {
$action = 'view';
}
if ($generate) {
$iaUtil = $iaCore->factory('core', 'util');
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
if (!utf8_is_ascii($data['alias'])) {
$data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
}
}
$url = iaDb::printf($this->patterns[$action], $data);
return self::get('url') . $url;
}
示例8: url
public function url($action, $data = array(), $generate = false)
{
$data['action'] = $action;
$data['alias'] = isset($data['genre_alias']) ? $data['genre_alias'] : $data['title_alias'];
if (!isset($this->patterns[$action])) {
$action = 'view';
}
if ($generate) {
iaCore::util();
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
if (!utf8_is_ascii($data['alias'])) {
$data['alias'] = $iaCore->convertStr(utf8_to_ascii($data['alias']));
}
}
$url = iaDb::printf($this->patterns[$action], $data);
return $this->iaCore->packagesData[self::PACKAGE_NAME]['url'] . $url;
}
示例9: delete
public function delete($id)
{
$result = false;
$this->iaDb->setTable(self::getTable());
// if item exists, then remove it
if ($row = $this->iaDb->row_bind(array('title', 'image'), '`id` = :id', array('id' => $id))) {
$result[] = (bool) $this->iaDb->delete(iaDb::convertIds($id), self::getTable());
if ($row['image'] && $result) {
$iaPicture = $this->iaCore->factory('picture');
$iaPicture->delete($row['image']);
}
$result[] = (bool) $this->iaDb->delete(iaDb::convertIds($id, 'blog_id'), $this->_tableBlogEntriesTags);
$sql = 'DELETE ' . 'FROM `:prefix:table_blog_tags` ' . 'WHERE `id` NOT IN (' . 'SELECT DISTINCT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags`)';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_entries_tags' => 'blog_entries_tags', 'table_blog_tags' => 'blog_tags'));
$result[] = (bool) $this->iaDb->query($sql);
if ($result) {
$this->iaCore->factory('log')->write(iaLog::ACTION_DELETE, array('module' => 'blog', 'item' => 'blog', 'name' => $row['title'], 'id' => (int) $id));
}
}
$this->iaDb->resetTable();
return $result;
}
示例10: _getAdminToolbarActions
private function _getAdminToolbarActions()
{
$result = array();
$stmt = "`pages` REGEXP('[[:<:]]:page(::action)?(,|\$)') AND `type` = 'regular' ORDER BY `order` DESC";
$stmt = iaDb::printf($stmt, array('page' => $this->name(), 'action' => $this->get('action')));
$iaAcl = $this->iaCore->factory('acl');
$rows = $this->iaCore->iaDb->all(array('attributes', 'name', 'icon', 'text', 'url'), $stmt, null, null, 'admin_actions');
foreach ($rows as $entry) {
if ($iaAcl->checkAccess(iaAcl::OBJECT_ADMIN_PAGE, $entry['name'])) {
$result[] = array('attributes' => $entry['attributes'], 'icon' => empty($entry['icon']) ? '' : 'i-' . $entry['icon'], 'title' => iaLanguage::get($entry['text'], $entry['text']), 'url' => iaDb::printf($entry['url'], $this->iaCore->iaView->get('toolbarActionsReplacements', array())));
}
}
return $result;
}
示例11: getAuth
public function getAuth($userId, $user = null, $password = null)
{
$sql = 'SELECT u.*, g.`name` `usergroup` ' . 'FROM `:prefix_:table_users` u ' . 'LEFT JOIN `:prefix_:table_groups` g ON (g.`id` = u.`usergroup_id`) ' . 'WHERE :condition ' . 'LIMIT 1';
if ((int) $userId) {
$condition = sprintf('u.`id` = %d', $userId);
} else {
$condition = '(u.`username` = :username OR u.`email` = :email) AND u.`password` = :password';
$this->iaDb->bind($condition, array('username' => preg_replace('/[^a-zA-Z0-9.@_-]/', '', $user), 'email' => $user, 'password' => $this->encodePassword($password)));
}
$sql = iaDb::printf($sql, array('prefix_' => $this->iaDb->prefix, 'table_users' => self::getTable(), 'table_groups' => self::getUsergroupsTable(), 'condition' => $condition));
$row = $this->iaDb->getRow($sql);
if (iaCore::STATUS_ACTIVE == $row['status']) {
self::_setIdentity($row);
$this->iaDb->update(null, iaDb::convertIds($row['id']), array('date_logged' => iaDb::FUNCTION_NOW), self::getTable());
$this->_assignItem($row);
return $row;
}
return false;
}
示例12: _getPages
private function _getPages()
{
$sql = 'SELECT DISTINCTROW p.*, IF(t.`value` is null, p.`name`, t.`value`) `title` ' . 'FROM `:prefixpages` p ' . 'LEFT JOIN `:prefix:table_language` t ' . "ON (`key` = CONCAT('page_title_', p.`name`) AND t.`code` = ':language') " . "WHERE p.`status` = ':status' AND p.`service` = 0 " . 'ORDER BY t.`value`';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_language' => iaLanguage::getTable(), 'language' => $this->_iaCore->iaView->language, 'status' => iaCore::STATUS_ACTIVE));
return $this->_iaDb->getAll($sql);
}
示例13: _getUsersSpecificConfig
private function _getUsersSpecificConfig()
{
$sql = 'SELECT c.`name`, c.`value` ' . 'FROM `:prefix:table_custom_config` c, `:prefix:table_members` m ' . "WHERE c.`type` = ':type' AND c.`type_id` = m.`usergroup_id` AND m.`id` = :id";
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_custom_config' => iaCore::getCustomConfigTable(), 'table_members' => iaUsers::getTable(), 'id' => $this->_typeId));
return ($rows = $this->_iaDb->getKeyValue($sql)) ? $rows : array();
}
示例14: foreach
if ($favorites = $iaItem->getFavoritesByMemberId(iaUsers::getIdentity()->id)) {
foreach ($favorites as $itemName => $ids) {
$fields = array('id');
$class = iaCore::CORE != $itemsList[$itemName] ? $iaCore->factoryPackage('item', $itemsList[$itemName], iaCore::FRONT, $itemName) : $iaCore->factory('members' == $itemName ? 'users' : $itemName);
if ($class && method_exists($class, iaUsers::METHOD_NAME_GET_FAVORITES)) {
$favorites[$itemName]['items'] = $class->{iaUsers::METHOD_NAME_GET_FAVORITES}($ids);
} else {
if ($itemName == $iaUsers->getItemName()) {
$fields[] = 'username';
$fields[] = 'fullname';
$fields[] = 'avatar';
$fields[] = 'id` `member_id';
} else {
$fields[] = 'member_id';
}
$stmt = iaDb::printf("`id` IN (:ids) && `status` = ':status'", array('ids' => implode(',', $ids), 'status' => iaCore::STATUS_ACTIVE));
$favorites[$itemName]['items'] = $iaDb->all('*, 1 `favorite`', $stmt, null, null, $iaItem->getItemTable($itemName));
}
// we need this to generate correct template filename
$favorites[$itemName]['package'] = iaCore::CORE == $itemsList[$itemName] ? '' : $itemsList[$itemName];
// filter values
$favorites[$itemName]['fields'] = $iaField->filter($favorites[$itemName]['items'], $itemName);
}
}
} else {
$favorites = isset($_SESSION[iaUsers::SESSION_FAVORITES_KEY]) ? (array) $_SESSION[iaUsers::SESSION_FAVORITES_KEY] : array();
// populate visible fields
foreach ($favorites as $itemName => &$items) {
if (isset($items['items']) && $items['items']) {
// generate correct fields array
$favorites[$itemName]['fields'] = $iaField->filter($items['items'], $itemName);
示例15: install
//.........这里部分代码省略.........
}
if ($this->itemData['item_fields']) {
$iaDb->setTable(iaField::getTable());
$maxOrder = $iaDb->getMaxOrder(iaField::getTable());
foreach ($this->itemData['item_fields'] as $item) {
if (!$iaDb->exists('`item` = :item AND `name` = :name', array('item' => $item['item'], 'name' => $item['name']))) {
$item['order'] || ($item['order'] = ++$maxOrder);
$item['fieldgroup_id'] = isset($fieldGroups[$item['item'] . $item['group']]) ? $fieldGroups[$item['item'] . $item['group']] : 0;
$this->_addPhrase('field_' . $item['name'], $item['title']);
unset($item['group'], $item['title']);
if (is_array($item['numberRangeForSearch'])) {
foreach ($item['numberRangeForSearch'] as $num) {
$this->_addPhrase('field_' . $item['name'] . '_range_' . $num, $num, iaLanguage::CATEGORY_FRONTEND);
}
}
unset($item['numberRangeForSearch']);
if ('dependent' == $item['relation']) {
$iaDb->setTable(iaField::getTableRelations());
foreach (explode(';', $item['parent']) as $parent) {
$list = explode(':', $parent);
if (2 == count($list)) {
list($fieldName, $fieldValues) = $list;
foreach (explode(',', $fieldValues) as $fieldValue) {
$entryData = array('field' => $fieldName, 'element' => $fieldValue, 'child' => $item['name'], 'item' => $item['item'], 'extras' => $this->itemData['name']);
$iaDb->insert($entryData);
}
}
}
$iaDb->resetTable();
}
unset($item['parent']);
if (is_array($item['values'])) {
foreach ($item['values'] as $key => $value) {
$key = sprintf('field_%s_%s', $item['name'], $key);
$this->_addPhrase($key, $value);
}
if ($item['default']) {
// TODO: multiple default values for checkboxes should be implemented
if (!in_array($item['default'], array_keys($item['values']))) {
$item['default'] = array_search($item['default'], $item['values']);
}
}
$item['values'] = implode(',', array_keys($item['values']));
}
$fieldPages = $item['item_pages'] ? $item['item_pages'] : array();
$tableName = $item['table_name'];
$className = $item['class_name'];
unset($item['item_pages'], $item['table_name'], $item['class_name']);
$fieldId = $iaDb->insert($item);
$item['table_name'] = $tableName;
$item['class_name'] = $className;
if ($fieldPages) {
foreach ($fieldPages as $pageName) {
if (trim($pageName) != '') {
$iaDb->insert(array('page_name' => $pageName, 'field_id' => $fieldId, 'extras' => $this->itemData['name']), null, iaField::getTablePages());
}
}
}
$iaDb->setTable($tableName);
$tableFields = $iaDb->describe();
$isExist = false;
foreach ($tableFields as $f) {
if ($f['Field'] == $item['name']) {
$isExist = true;
break;
}