Access _users table in SocialEngine? - zend-framework

i got a (simple?) problem accessing _users table in SocialEngine. To access tables in SE4 i use this:
$table = Engine_Api::_()->getDbTable(tablename,tablegroup);
and this works fine for _user_online (->getDbTable('online','user')) etc. but I don't know how to access _users table (which has not tablegroup prefix).
i tried:
->getDbTable('users')
->getDbTable('','users')
->getDbTable(null,'users')
->getDbTable('foo','what_a')
no way.

Engine_Api::_()->getItemTable('user');
I suggest you read SocialEngine factory codes to find out answer to this kind of questions.

you are missing commas
try this
$table = Engine_Api::_()->getDbTable('users','user');
it will give you users table object. hope this will help

You can use below 2 methods to get the "engine4_users" table object:
1) $userTable = Engine_Api::_()->getItemTable('user);
2) $userTable = Engine_Api::_()->getDbTable('users', 'user');

Try this one.
$query=Engine_Db_Table::getDefaultAdapter()->select()
->from('engine4_yourtablename')
->where("your_field_name = ?", $variable)->limit(1);
$query= $query->query()->fetch();
Hope this will help.

Related

How to insert an option value into a select tag with CasperJS?

Well, the question is very self-explanatory.
Right now, I'm front of a form which has a select tag with a couple of options already. But I must insert a new one, with a different value that I will receive from a .json file.
The thing is: I haven't been able to find a suitable solution from the CasperJS documentation.
I've tried something like this:
this.fill('form.coworkerdiscountcode', {
'CoworkerDiscountCode.DiscountCode': ['Value1']
});
But no results. Any ideas?
Thanks in advance.
You can execute any javascript code by passing it to casper.evaluate like this:
casper.evaluate(function() {
var x = document.getElementById("coworkerdiscountcode");
var option = document.createElement("option");
option.text = "Kiwi";
x.add(option);
});

How to get moodle module name from module id

I want to list the names of the modules (activities) in my course sections from moodle function or from db query.
I can get section details and module id from mdl_course_sections and mdl_course_modules tables I want to get name or tile put in every activity to be list down.
I already tried mod_frog_get_coursemodule_info($cm) but I hadn't any luck with it.
Use get_fast_mod_info() e.g.:
$modinfo = get_fast_modinfo($courseid);
foreach ($modinfo as $cm) {
echo $cm->modname;
}
I advise you :
$modinfo = get_fast_modinfo($courseid);
$cm = $modinfo->get_cm($moduleid);
Reference: https://docs.moodle.org/dev/Module_visibility_and_display#get_fast_modinfo_data
I found a solution to this with following code
$activity_modules = $DB->get_record('modules',array('id' =>$moduleid));
$dynamic_activity_modules_data = $DB->get_record($activity_modules->name,array('id' =>$instanceid));
echo $dynamic_activity_modules_data->name;
Use get_fast_modinfo() :
$cm = $modinfo->cms[$moduleid];
$modulename = $cm->modname;
This can be achieved in 2 lines within moodle structure:
global $DB;
$moduleName = $DB->get_field('modules','name',array('id' => $moduleID));

Help needed formatting Doctrine Query in Zend Framework

Can anyone tell me how to format the query below correctly in my controller.
Currently it gives me nothing in my FilteringSelect. However if I change it to >= I get back all the kennelIDs which is incorrect also but at least I'm getting something.
I've tested that the session variable is set and can confirm that there are kennels with the matching capacity.
// Create autocomplete selection for the service of this booking
public function servkennelAction()
{
$sessionKennelBooking = new Zend_Session_Namespace('sessionKennelBooking');
// disable layout and view rendering
$this->_helper->layout->disableLayout();
$this->getHelper('viewRenderer')->setNoRender(true);
// get list of grooming services for dogs from the table
$qry= Doctrine_Query::create()
->from('PetManager_Model_Kennels k');
//This should be set by default and narrows down the search criteria
if(isset($sessionKennelBooking->numPets)){
$b=(int)$sessionKennelBooking->numPets;
$qry->addWhere('k.capacity = ?','$b');
}
$result=$qry->fetchArray();
//generate and return JSON string using the primary key of the table
$data = new Zend_Dojo_Data('kennelID',$result);
echo $data->toJson();
}
Many thanks in Advance.
Graham
I think that addWhere condition is wrong. It has to be:
$qry->addWhere('k.capacity = ?', $b);
i.e. $b without quotes.

how to delete findDependentRowset result in Zend Framework

I have place model & entry model that entry is parent
everything is fine but how can I delete the result row $categoryPlacements
in place model:
$entryModel = new Model_EntryModel();
$entryRow = $entryModel->find ( $entryId )->current ();
$categoryPlacements = $entryRow->findDependentRowset($this);
in this case i want to delete the $categoryPlacements result in place model
I can use categoryPlacements->toarray() and then delete but is another easy way?
Foering Keys at the database could solve this issue.
$categoryPlacements = $entryRow->findDependentRowset($this);
foreach ($categoryPlacements as $placement){
$where = $db->getAdapter()->quoteInto('id = ?',$placement->id);
$db->delete($where);
}
Sorry if this is not what you need, regardĀ“s.

Sync Services Ado.net SyncSchema

I'm trying to build a custom ServerSyncProvider
right now. I'm trying to understand the GetScema Method.
I'm trying to build a dataSet and associate it to SyncSchema class
one of my table columns is a nvarchar(50).
Here is what I'm doing this:
DataColumn column = new DataColumn();
column.ColumnName = "Name";
column.DataType = typeof(String);
column.MaxLength = 55;
table.Columns.Add(column);
But it turns out that on my client side, this column becomes nvarchar(1)
any idea?
Thanks a lot for helping me.
Use this code:
column.ExtendedProperties.Add("ColumnLength", 50);