User::model()->update($_id, array('$set' => array('d' => 1)[, array('deleted' => 1)[, array('w' => 2)]]);
I want to update user table with specified user id.
it's not working
The brackets are optional parts, this stems from the PHP manual ( i.e.: http://php.net/manual/en/function.pathinfo.php ) so:
User::model()->update($_id, array('$set' => array('d' => 1)
[, array('deleted' => 1)[, array('w' => 2)]]);
Will never work and will actually throw a syntax error in PHP in its current state. Instead you can try:
User::model()->update($_id, array('$set' => array('d' => 1)));
Related
I have the following conditions in my query:
'conditions' => array('Zona.nombre LIKE' => $buscar,
'date_format("%Y", Zona.created)' => 'date_format("%Y", NOW())',
How do I get result of current year ?
In CakePHP you can simply do this:
'YEAR(Zona.created)' => date('Y'),
It can be done something like that.
"DATE_FORMAT(Zona.created, '%Y') = " => "DATE_FORMAT(YEAR(), '%Y')",
I am currently encountering issues trying to build a custom search field (itself bound to an unused field on a Module) to search two Phone Number fields. The documentation covering modifications of a search field are really poor, but I have the following in place in the module's SearchFields.php
'phone' =>
array (
'query_type' => 'default',
'operator' => '=',
'db_field' =>
array (
0 => 'home_phone_c',
1 => 'work_phone_c',
),
),
The field itself returns no results, so am I missing something that would prevent this from working?
why not you use "sub-query" operator for this? See SearchFields.php inside metadata folder of Account module. You will see entry like following:
'email' =>
array (
'query_type' => 'default',
'operator' => 'subquery',
'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
'db_field' =>
array (
0 => 'id',
),
'vname' => 'LBL_ANY_EMAIL',
),
this will help you to understand the sugar logic of doing it.
You need to designate the correct tables. Try the below code (or use the tables that you're searching):
'phone' =>
array (
'query_type' => 'default',
'operator' => '=',
'db_field' =>
array (
0 => 'accounts_cstm.home_phone_c',
1 => 'accounts_cstm.work_phone_c',
),
),
I am using Laravel with mongodb(Jenssegers), i have array data like following,
$insert[] = ['sub_id'=>$loggedin,
'userid' => $row->userid,
'username' => $row->username,
'email' => $row->email,
'mobileno' => $row->mobileno,
'manager_mail' => $row->manager_mail,
'roleid' => $userrole->roleid];
my insert query is,
$user->save($insert);
But its not working, please suggest any solution?
You need to use create() or insert() methods:
User::create($insert);
Or:
User::insert($insert);
Or:
DB::table('table_name')->insert($insert);
Eloquent save method accept 1D array. But you provided 2D. Please try following code:
$insert = ['sub_id'=>$loggedin,
'userid' => $row->userid,
'username' => $row->username,
'email' => $row->email,
'mobileno' => $row->mobileno,
'manager_mail' => $row->manager_mail,
'roleid' => $userrole->roleid];
$user->save($insert);
I'm new to Fuel...
got my script inserting a record using the following code:
$address = Model_Address::forge(array(
'street1' => $step1_data['street1'],
'street2' => $step1_data['street2'],
'suburb' => $step1_data['street2'],
'city' => $step1_data['city'],
'region' => $step1_data['region'],
'country' => $step1_data['country'],
'postcode' => $step1_data['postcode'],
));
$address->save();
I think I should be able to get the insert id via $address->id but it's empty.
I'm not sure what I'm doing wrong?
We are using pg_swl not sure if that makes any difference.
I have a the need to add a single line of code to locallib.php in the \mod\lti directory . ('custom_user' => $USER->username,)
$requestparams = array(
'resource_link_id' => $instance->id,
'resource_link_title' => $instance->name,
'resource_link_description' => $instance->intro,
'user_id' => $USER->id,
'roles' => $role,
'context_id' => $course->id,
'context_label' => $course->shortname,
'context_title' => $course->fullname,
'launch_presentation_locale' => current_language()
);
$requestparams = array(
'resource_link_id' => $instance->id,
'resource_link_title' => $instance->name,
'resource_link_description' => $instance->intro,
'user_id' => $USER->id,
'custom_user' => $USER->username,
'roles' => $role,
'context_id' => $course->id,
'context_label' => $course->shortname,
'context_title' => $course->fullname,
'launch_presentation_locale' => current_language()
);
Is there a right way to do this? Looking at plugins, it seems that they are for adding whole new functions, not just patching individual existing code.
Just having a look at the module - haven't come across it before.
There are custom parameters but they look like literal values.
I would say its okay to put that code in. Although I would probably add // CUSTOM before and after the mod.