本文整理汇总了PHP中jDao::createConditions方法的典型用法代码示例。如果您正苦于以下问题:PHP jDao::createConditions方法的具体用法?PHP jDao::createConditions怎么用?PHP jDao::createConditions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jDao
的用法示例。
在下文中一共展示了jDao::createConditions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$offset = $this->intParam($this->offsetParameterName, 0, true);
$rep = $this->_getResponse();
$dao = jDao::get($this->dao, $this->dbProfile);
$cond = jDao::createConditions();
$this->_indexSetConditions($cond);
$results = $dao->findBy($cond, $offset, $this->listPageSize);
$pk = $dao->getPrimaryKeyNames();
$form = $this->_createForm($this->pseudoFormId);
$tpl = new jTpl();
$tpl->assign('list', $results);
$tpl->assign('primarykey', $pk[0]);
if (count($this->propertiesForList)) {
$prop = $this->propertiesForList;
} else {
$prop = array_keys($dao->getProperties());
}
$tpl->assign('properties', $prop);
$tpl->assign('controls', $form->getControls());
$tpl->assign('editAction', $this->_getAction('preupdate'));
$tpl->assign('createAction', $this->_getAction('precreate'));
$tpl->assign('deleteAction', $this->_getAction('delete'));
$tpl->assign('viewAction', $this->_getAction('view'));
$tpl->assign('listAction', $this->_getAction('index'));
$tpl->assign('listPageSize', $this->listPageSize);
$tpl->assign('page', $offset > 0 ? $offset : null);
$tpl->assign('recordCount', $dao->countBy($cond));
$tpl->assign('offsetParameterName', $this->offsetParameterName);
$this->_index($rep, $tpl);
$rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate));
jForms::destroy($this->form, $this->pseudoFormId);
return $rep;
}
示例2: index
/**
* list all users
*/
function index()
{
$offset = $this->intParam('offset', 0, true);
$rep = $this->getResponse('html');
if ($this->form == '') {
$rep->body->assign('MAIN', 'no form defined in the auth plugin');
return $rep;
}
$tpl = new jTpl();
$dao = jDao::get($this->dao, $this->dbProfile);
$cond = jDao::createConditions();
$cond->addItemOrder('login', 'asc');
$tpl->assign('list', $dao->findBy($cond, $offset, $this->listPageSize));
$pk = $dao->getPrimaryKeyNames();
$tpl->assign('primarykey', $pk[0]);
$tpl->assign('controls', jForms::create($this->form, '___$$$___')->getControls());
$tpl->assign('listPageSize', $this->listPageSize);
$tpl->assign('page', $offset);
$tpl->assign('recordCount', $dao->countAll());
$tpl->assign('cancreate', jAcl2::check('auth.users.create'));
$tpl->assign('canview', jAcl2::check('auth.users.view'));
$rep->body->assign('MAIN', $tpl->fetch('crud_list'));
jForms::destroy($this->form, '___$$$___');
return $rep;
}
示例3: read
/**
*
*/
function read()
{
$rep = $this->getResponse('json');
$liste = array();
$page = $this->intParam('page', 1, true);
//$page
$count = $this->intParam('count', 10, true);
//$count
$filtre = $this->param('filter');
$sorting = $this->param('sorting');
$offset = ($page - 1) * $count;
// instanciation de la factory
$tb = jDao::get('link');
if (empty($cb)) {
$dt = new jDateTime();
$filter = (array) json_decode($filtre);
$sorting = (array) json_decode($sorting);
$conditions = jDao::createConditions();
foreach ($filter as $key => $value) {
$conditions->addCondition($key, 'LIKE', '%' . $value . '%');
}
foreach ($sorting as $key => $value) {
$conditions->addItemOrder($key, $value);
}
$records = $tb->findBy($conditions, $offset, $count)->fetchAll();
$rep->data["Count"] = $tb->countBy($conditions);
$rep->data['Items'] = $records;
} else {
$rep->data['Items'] = $tb->findAll()->fetchAll();
}
return $rep;
}
示例4: index
/**
*
*/
function index()
{
$rep = $this->getResponse('html');
$groups = array();
$o = new StdClass();
$o->id_aclgrp = '-2';
$o->name = jLocale::get('jacl2_admin~acl2.all.users.option');
$o->grouptype = 0;
$groups[] = $o;
$o = new StdClass();
$o->id_aclgrp = '-1';
$o->name = jLocale::get('jacl2_admin~acl2.without.groups.option');
$o->grouptype = 0;
$groups[] = $o;
foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
$groups[] = $grp;
}
$listPageSize = 15;
$offset = $this->intParam('idx', 0, true);
$grpid = $this->intParam('grpid', -2, true);
$p = jAcl2Db::getProfil();
if ($grpid == -2) {
//all users
$dao = jDao::get('jelix~jacl2groupsofuser', $p);
$cond = jDao::createConditions();
$cond->addCondition('grouptype', '=', 2);
$rs = $dao->findBy($cond, $offset, $listPageSize);
$usersCount = $dao->countBy($cond);
} elseif ($grpid == -1) {
//only those who have no groups
$sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group
GROUP BY login HAVING nbgrp < 2 ORDER BY login';
$cnx = jDb::getConnection($p);
$rs = $cnx->query($sql);
$usersCount = -1;
} else {
//in a specific group
$dao = jDao::get('jelix~jacl2usergroup', $p);
$rs = $dao->getUsersGroupLimit($grpid, $offset, $listPageSize);
$usersCount = $dao->getUsersGroupCount($grpid);
}
$users = array();
$dao2 = jDao::get('jelix~jacl2groupsofuser', $p);
foreach ($rs as $u) {
$u->groups = array();
$gl = $dao2->getGroupsUser($u->login);
foreach ($gl as $g) {
if ($g->grouptype != 2) {
$u->groups[] = $g;
}
}
$users[] = $u;
}
$tpl = new jTpl();
$tpl->assign(compact('offset', 'grpid', 'listPageSize', 'groups', 'users', 'usersCount'));
$rep->body->assign('MAIN', $tpl->fetch('users_list'));
return $rep;
}
示例5: testEvents
function testEvents()
{
global $TEST_DAO_EVENTS;
$TEST_DAO_EVENTS = array();
$this->emptyTable('product_test');
$dao = jDao::get('products_events');
$prod1 = jDao::createRecord('products_events');
$prod1->name = 'assiette';
$prod1->price = 3.87;
$prod2 = jDao::createRecord('products_events');
$prod2->name = 'assiette';
$prod2->price = 3.87;
//$prod2 = clone $prod1;
$res = $dao->insert($prod2);
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoInsertBefore']));
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoInsertAfter']));
$this->assertEqual($TEST_DAO_EVENTS['onDaoInsertBefore']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoInsertBefore']['record'], $prod1);
$this->assertEqual($TEST_DAO_EVENTS['onDaoInsertAfter']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoInsertAfter']['record'], $prod2);
$prod2->name = 'nouvelle assiette';
$prod = $dao->update($prod2);
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoUpdateBefore']));
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoUpdateAfter']));
$this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateBefore']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateBefore']['record'], $prod2);
$this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateAfter']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateAfter']['record'], $prod2);
$dao->delete(0);
// unexistant id
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteBefore']));
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteAfter']));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['keys'], array('id' => 0));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['keys'], array('id' => 0));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['result'], 0);
$dao->delete($prod2->id);
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteBefore']));
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteAfter']));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['keys'], array('id' => $prod2->id));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['keys'], array('id' => $prod2->id));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['result'], 1);
$conditions = jDao::createConditions();
$conditions->addCondition('id', '=', $prod2->id);
$dao->deleteBy($conditions);
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteByBefore']));
$this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteByAfter']));
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByBefore']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByBefore']['criterias'], $conditions);
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['dao'], 'jelix_tests~products_events');
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['result'], 0);
$this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['criterias'], $conditions);
}
示例6: _prepareTpl
protected function _prepareTpl()
{
$records = array();
$tb = jDao::get('post');
$category_id = $this->param('id');
$conditions = jDao::createConditions();
$conditions->addCondition('published', '=', 'YES');
$conditions->addCondition('category_id', '=', $category_id);
$records = $tb->findBy($conditions)->fetchAll();
$this->_tpl->assign('records', $records);
}
示例7: getPageOBJ
public function getPageOBJ($name)
{
$pageFacto = jDao::get('pages');
$conditions = jDao::createConditions();
$conditions->addCondition('name', '=', $name);
$conditions->addCondition('language', '=', $GLOBALS['gJConfig']->locale);
$text = "NOT FOUND";
foreach ($pageFacto->findBy($conditions) as $page) {
$text = $page;
}
return $text;
}
示例8: getIdOfLastEvent
protected function getIdOfLastEvent()
{
$dao = jDao::get('events');
$cond = jDao::createConditions();
$cond->addItemOrder('date_debut', 'DESC');
$cond->addCondition('language', '=', $GLOBALS['gJConfig']->locale);
$results = $dao->findBy($cond);
$ret = null;
foreach ($results as $r) {
$ret = $r->id;
}
return $ret;
}
示例9: searchEngineRun
/**
* default searchEngineRun methode which make a search from the engine by querying the table define in the dao of the hfnusearch.ini.php file
* @param object $event
*/
function searchEngineRun($event)
{
$cleaner = jClasses::getService('hfnusearch~cleaner');
$words = $cleaner->stemPhrase($event->getParam('string'));
$page = (int) $event->getParam('page');
$limit = (int) $event->getParam('limit');
$id_forum = (int) $event->getParam('id_forum');
// no words ; go back with nothing :P
if (!$words) {
return array('count' => 0, 'result' => array());
}
//1) open the config file
$HfnuSearchConfig = parse_ini_file(jApp::configPath() . 'havefnu.search.ini.php', true);
//2) get the dao we want to read
$dataSource = $HfnuSearchConfig['dao'];
//3) build an array with each one
$dataSources = preg_split('/,/', $dataSource);
foreach ($dataSources as $ds) {
//4) get a factory of the current DAO
$dao = jDao::get($ds);
//getting the column name on which we need to make the query
$indexSubject = $HfnuSearchConfig[$ds]['index_subject'];
$indexMessage = $HfnuSearchConfig[$ds]['index_message'];
//5) get all the record
$conditions = jDao::createConditions();
$conditions->startGroup('OR');
if ($id_forum > 0) {
$conditions->addCondition('id_forum', '=', $id_forum);
}
foreach ($words as $word) {
$conditions->addCondition($indexSubject, 'LIKE', '%' . $word . '%');
$conditions->addCondition($indexMessage, 'LIKE', '%' . $word . '%');
}
$conditions->endGroup();
$allRecord = $dao->findBy($conditions);
if ($page > 0 and $limit > 0) {
$record = $dao->findBy($conditions, $page, $limit);
} else {
$record = $allRecord;
}
foreach ($record as $rec) {
if (jAcl2::check('hfnu.admin.post')) {
$event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount()));
} elseif (jAcl2::check('hfnu.forum.view', 'forum' . $rec->id_forum) and $rec->status < 7) {
$event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount()));
}
}
}
}
示例10: read
/**
*
*/
function read()
{
$rep = $this->getResponse('json');
$liste = array();
$id = $this->intParam('id', null, true);
$page = $this->intParam('page', 1, true);
$rows = $this->intParam('rows', 10, true);
$offset = ($page - 1) * $rows;
// instanciation de la factory
$tb = jDao::get("user");
$conditions = jDao::createConditions();
$conditions->addItemOrder('id', 'DESC');
$records = $tb->findBy($conditions)->fetchAll();
// $liste['total']=$userFactory->countAll();
$rep->data["Items"] = $records;
$rep->data["Count"] = $tb->countBy($conditions);
return $rep;
}
示例11: prepareToSave
function prepareToSave()
{
$tpl = new jTpl();
$rep = $this->getResponse('html');
if ($this->param('id') === null) {
$form = jForms::fill('NewsLetter~news');
$dao = jDao::get('NewsLetter~newsLetter');
$r = jDao::createRecord('NewsLetter~newsLetter');
$r->date_create = date("Y-m-d");
$r->text = $form->getData('text');
$dao->insert($r);
} else {
$id = $this->param('id');
$dao = jDao::get('NewsLetter~newsLetter');
$r = $dao->get($this->param('id'));
}
$actions = array();
$emails_dao = jDao::get('emails');
$conds = jDao::createConditions();
$count = $emails_dao->countBy($conds);
$email_rate = 2000;
for ($i = 0; $i <= $count; $i += $email_rate) {
$action = array();
$action['inf'] = $i;
$action['sup'] = $i + $email_rate;
$action['url'] = 'send';
$action['id'] = $r->id;
$actions[] = $action;
}
$tpl->assign('actions', $actions);
$tpl->assign('id', $r->id);
$emailSrv = new EmailService();
if ($emailSrv->nbEmailsToSend($r->id) == 0) {
$emailSrv->resetLogs($r->id);
}
$tpl->assign('n_emails', $emailSrv->nbEmailsToSend($r->id));
$tpl->assign('n_emails_sent', $emailSrv->nbEmailsSent($r->id));
$tpl->assign('servers', $emailSrv->getServers());
$tpl->assign('maxMailPerMin', $emailSrv->maxMailPerMin());
$tpl->assign('maxMailPerDay', $emailSrv->maxMailPerDay());
$rep->body->assign('MAIN', $tpl->fetch('prepare_sending'));
return $rep;
}
示例12: read
/**
*
*/
function read()
{
$rep = $this->getResponse('json');
$group_id = $this->intParam('group_id', null, true);
$user_id = $this->intParam('user_id', null, true);
//$liste=array();
// instanciation de la factory
$tb = jDao::get("user_group");
$cond = jDao::createConditions();
if (!empty($user_id)) {
$cond->addCondition('user_id', '=', $user_id);
}
if (!empty($group_id)) {
$cond->addCondition('group_id', '=', $group_id);
}
$records = $tb->findBy($cond)->fetchAll();
$rep->data["Items"] = $records;
$rep->data["Count"] = $tb->countBy($cond);
return $rep;
}
示例13: read
/**
*
*/
function read()
{
$rep = $this->getResponse('json');
$page = $this->intParam('page', 1, true);
//$page
$count = $this->intParam('count', 10, true);
//$count
$filtre = $this->param('filter');
$sorting = $this->param('sorting');
$cb = $this->param('cb');
$offset = ($page - 1) * $count;
// instanciation de la factory
$tb = jDao::get('group_feature');
if (empty($cb)) {
$dt = new jDateTime();
$filter = (array) json_decode($filtre);
$sorting = (array) json_decode($sorting);
// $start = $this->adjust($start, '-',false);
// $end = $this->adjust($end, '-');
$conditions = jDao::createConditions();
// $conditions->addCondition('createdate', '>=', $start);
// $conditions->addCondition('createdate', '<=', $end);
foreach ($filter as $key => $value) {
if ($key == 'group_id') {
$conditions->addCondition($key, '=', $value);
} else {
$conditions->addCondition($key, 'LIKE', '%' . $value . '%');
}
}
foreach ($sorting as $key => $value) {
$conditions->addItemOrder($key, $value);
}
$records = $tb->findBy($conditions, $offset, $count)->fetchAll();
$rep->data['Items'] = $records;
$rep->data["Count"] = $tb->countBy($conditions);
} else {
$rep->data['Items'] = $tb->findAll()->fetchAll();
$rep->data["Count"] = $tb->countAll();
}
return $rep;
}
示例14: read
/**
*
*/
function read()
{
$rep = $this->getResponse('json');
$app = $this->param('app', null, true);
$tb = jDao::get("param");
$conditions = jDao::createConditions();
if (!empty($app)) {
$conditions->addCondition('app', '=', $app);
$t = $tb->countBy($conditions);
if ($t == 0) {
$record = jDao::createRecord("param");
$record->app = $app;
$record->params = null;
$record->user_id = jAuth::getUserSession()->id;
$tb->insert($record);
}
}
$record = $tb->findBy($conditions)->fetch();
$record->params = (object) json_decode($record->params);
$rep->data = $record;
return $rep;
}
示例15: index
/**
* list all records
*/
function index()
{
$offset = $this->intParam($this->offsetParameterName, 0, true);
$rep = $this->_getResponse();
$dao = jDao::get($this->dao, $this->dbProfile);
$keyActionDao = $this->_getAction($this->dao);
if ($this->showPropertiesOrderLinks && count($this->propertiesForRecordsOrder)) {
if (!isset($_SESSION['CRUD_LISTORDER'][$keyActionDao])) {
$_SESSION['CRUD_LISTORDER'][$keyActionDao] = $this->propertiesForRecordsOrder;
}
if (($lo = $this->param('listorder')) && array_key_exists($lo, $this->propertiesForRecordsOrder)) {
$listOrder = $_SESSION['CRUD_LISTORDER'][$keyActionDao];
if (isset($listOrder[$lo]) && $listOrder[$lo] == 'asc') {
$listOrder[$lo] = 'desc';
} elseif (isset($listOrder[$lo]) && $listOrder[$lo] == 'desc') {
unset($listOrder[$lo]);
} else {
$listOrder[$lo] = 'asc';
}
$_SESSION['CRUD_LISTORDER'][$keyActionDao] = $listOrder;
}
}
$cond = jDao::createConditions();
$cond->addCondition($this->spkName, '=', $this->param($this->spkName));
$this->_indexSetConditions($cond);
$results = $dao->findBy($cond, $offset, $this->listPageSize);
// we're using a form to have the portunity to have
// labels for each columns.
$form = jForms::create($this->form, $this->pseudoFormId);
$tpl = new jTpl();
$tpl->assign('list', $results);
$tpl->assign('dpkName', $this->dpkName);
$tpl->assign('spkName', $this->spkName);
$tpl->assign('spk', $this->param($this->spkName));
if (count($this->propertiesForList)) {
$prop = $this->propertiesForList;
} else {
$prop = array_keys($dao->getProperties());
}
$tpl->assign('propertiesForListOrder', $this->propertiesForListOrder);
$tpl->assign('sessionForListOrder', isset($_SESSION['CRUD_LISTORDER'][$keyActionDao]) ? $_SESSION['CRUD_LISTORDER'][$keyActionDao] : $this->propertiesForListOrder);
$tpl->assign('properties', $prop);
$tpl->assign('controls', $form->getControls());
$tpl->assign('editAction', $this->_getAction('preupdate'));
$tpl->assign('createAction', $this->_getAction('precreate'));
$tpl->assign('deleteAction', $this->_getAction('delete'));
$tpl->assign('viewAction', $this->_getAction('view'));
$tpl->assign('listAction', $this->_getAction('index'));
$tpl->assign('listPageSize', $this->listPageSize);
$tpl->assign('page', $offset > 0 ? $offset : null);
$tpl->assign('recordCount', $dao->countBy($cond));
$tpl->assign('offsetParameterName', $this->offsetParameterName);
$this->_index($rep, $tpl);
$rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate));
jForms::destroy($this->form, $this->pseudoFormId);
return $rep;
}