Yii2:- update record using update query for mongodb - mongodb

I am trying to make update query using Yii2 for mongodb. I make following query:
$collection = Yii::$app->mongodb->getCollection('usermaster');
$arrUpdate = [
'firstName' => $fname,
'lastName' => $lname,
'email' => $email,
'is_visible' => $isvisibleUser,
'phoneNumber' => $phone,
'userName' => $uname,
];
$collection->update(['_id = 55a4957sd88423d10ea7c07d'],$arrUpdate);
But it shows follwoing error in firebug.
"NetworkError: 500 Internal Server Error - http://localhost/yii2angularseedmaster/frontend/web/category/corporateupdate?corpUserid=55a4957sd88423d10ea7c07d"
My insert query works perfectly but update query does not works.
Please tell me what is wrong in my query.

$collection->update(['_id' => $id],$arrUpdate);

Your code should be like this
$collection = Yii::$app->mongodb->getCollection('usermaster');
$arrUpdate = [
'firstName' => $fname,
'lastName' => $lname,
'email' => $email,
'is_visible' => $isvisibleUser,
'phoneNumber' => $phone,
'userName' => $uname,
];
$collection->update(['_id' => $id],$arrUpdate);

Related

Unable to get getConfigurationAndPricing in PromoStandard

I am trying to getting Product getConfigurationAndPricing using Promostandard Soap API but for some reason I am unable to get those information. Here is my code snapit
$productId = 'TM17907'
$client = new \SoapClient("https://pspriceconfig100.pcna.online/psPriceConfig.svc?singleWsdl", array('trace' => 1));
$options = array(
'wsVersion' => '1.0.0',
'id' => $apiUsername,
'password' => $apiPassword,
'productId' => $productId,
'currency' => 'USD',
'fobId' => '1',
'priceType' => 'List',
'localizationCountry'=>'US',
'localizationLanguage' => 'en',
'configurationType' => 'Decorated',
'cache_wsdl' => WSDL_CACHE_MEMORY
);
try{
$result = $client->__soapCall('getConfigurationAndPricing',[$options]);
} catch (\Exception $e){
$output->writeln("<error>HTTP issue generate in product ID : ".$productId.", Row No.".$currentRow."</error>");
continue;
}
I am using to get PCNA products.

Argument 1 passed to GuzzleHttp\Client::send() must implement interface

hi I am new to laravel and I am trying to consume the api with laravel 8 I have a problem with my POST and I do not understand
public function storeEntreprise(Request $request){
$request->validate([
'name' => 'required',
'email' => 'required',
'phone_number'=>'required',
'address' => 'required',
'password' => 'required',
'password_confirmation' => 'required'
]);
$client = new Client();
$post = $request->all();
$url = "http://flexy-job.adsyst-solutions.com/api/entreprises-store";
$create = $client->request('POST', $url, [
'headers' => [
'Content-Type' => 'text/html; charset=UTF8',
],
'form-data' => [
'name' => $post['name'],
'email' => $post['email'],
'phone_number' => $post['phone_number'],
'address' => $post['address'],
'logo' => $post['logo'],
'password' => $post['password'],
'password_confirmation' => $post['password_confirmation']
]
]);
//dd($create->getBody());
echo $create->getStatusCode();
//echo $create->getHeader('Content-Type');
echo $create->getBody();
$response = $client->send($create);
return redirect()->back();
}
Can you help me please
You calling (accidentally?) $response = $client->send($create); where $create is response of API request you made ($create = $client->request('POST', $url, ...).
So PHP reports you that you can't pass ResponseInterface where RequestInterface required.
Also, you echo's body of response, and return redirect response at same time. So browser will not show you API response (because of instance back redirect).

Zend framework 3 Mysqli adapter issue

I am trying to connect mysql to zend framework 3 application but it gives such result as below:
Class 'Zend\Db\Adapter\Adapter\Driver\Mysqli' not found
I am using below code:
$config = [
'driver' => 'Mysqli',
'database' => 'abc',
'host' => 'localhost',
// 'port' => 27017,
'username' => 'root',
'password' => '',
];
$adapter = new Mysqli($config);
$result = $adapter->query("select * from
table1",Adapter::QUERY_MODE_EXECUTE);
foreach($result as $row){
echo $row->sentence;"<br>";
}
inserted this as well. use Zend\Db\Adapter\Adapter\Driver\Mysqli;

Insert email when creating account with rest api

I am faced with a Sugar 6.3 CE installation, trying to create new accounts through rest api.
I am still on the learning curve for a lot of the innards of the CRM, and cannot figure out how to have the email inserted whith the rest of the account info upon creation with a REST call.
I have tried many different field values, and after catching that $email1 was used in some snippet examples I saw on the sugarCRM site. I have not found other mentions in the forums or in the docs yet.
The $parameters array used to configure the usual rest call to create an account in php with REST api looks like this and works fine, except for the $email1:
$parameters = array(
'session' => $session,
'module' => 'Contacts',
'name_value_list' => array(
array('name' => 'first_name', 'value' =>
utf8_encode($contacts["Name"])),
array('name' => 'last_name', 'value' =>
utf8_encode($contacts["GivenName"])),
array('name' => 'phone_work', 'value' =>
utf8_encode($row->PrimaryPhoneAreaCode . ' ' . $row->PrimaryPhone)),
array('name' => 'phone_fax', 'value' =>
utf8_encode($row->PrimaryFaxAreaCode . ' ' . $row->PrimaryFaxNumber)),
array('name' => 'title', 'value' =>
utf8_encode($contacts["Title"])),
/*
* PROBLEM HERE!
*/
array('name' => 'email1', 'value' =>
utf8_encode($row->PrimaryEmail)),
array('name' => 'primary_address_street', 'value' =>
utf8_encode($row->Address1) . ' ' .
utf8_encode($row->Address2)),
array('name' => 'language', 'value' =>
utf8_encode($row->Language)),
array('name' => 'assigned_user_id', 'value' =>
get_rep_id($row->Salesperson1Name, $sugarlink)),
)
);
I would be curious, if someone has the trick. I tried to find to field for emails but it seems to be in separate tables. Any help / tips appreciated.
If you are using REST API the email1 will work for both set en get methods (just tested it).
Did not used the SOAP API as in your example, and suggest to migrate all to REST according to SugarCRM recommendations.
You must add the email into emailadress database first, create contact and set a relationship between both ;-)
$set_entry_parametersEADDR = array(
"session" => $session_id,
//The name of the module from which to retrieve records.
"module_name" => "EmailAddresses",
//Record attributes
"name_value_list" => array(
array('name' => 'email_address', 'value' => $email),
array('name' => 'email_address_caps', 'value' => strtoupper($email)),
array('name' => 'invalid_email' , 'value' => 0),
array('name' => 'opt_out', 'value' => 0),
array('name' => 'date_created' , 'value' => date('Y-m-d H:i:s')),
array('name' => 'date_modified', 'value' => date('Y-m-d H:i:s')),
array('name' => 'deleted' , 'value' => 0),
),
);
$set_entry_resultEmailsAdd = call("set_entry", $set_entry_parametersEADDR, $url);
print_r($set_entry_resultEmailsAdd);
$Email_id = $set_entry_resultEmailsAdd->id;
$set_entry_parameters_contact = array(
//session id
"session" => $session_id,
//The name of the module from which to retrieve records.
"module_name" => "Contacts",
//Record attributes
"name_value_list" => array(
//to update a record, you will nee to pass in a record id as commented below
//array("name" => "id", "value" => "9b170af9-3080-e22b-fbc1-4fea74def88f"),
array("name" => "first_name", "value" => $prof["Prenom"]),
array("name" => "last_name", "value" => $prof["Nom"]),
array("name" => "login_c", "value" => $prof["Login"]),
//array("name" => "email1", "value" => $email),
array("name" => "fonction_c", "value" => "prof")
),
);
$set_entry_result_contact = call("set_entry", $set_entry_parameters_contact, $url);
print_r($set_entry_result_contact);
$contact_id = $set_entry_result_contact->id;
$set_relationship_parameters_email = array(
'session' => $session_id,
'module_name' => 'Contacts',
'module_id' => $contact_id,
'link_field_name' => 'email_addresses',
'related_ids' => $Email_id,
);
$set_relationship_result_email = call("set_relationship", $set_relationship_parameters_email, $url);
print_r($set_relationship_result_email);
Currently I think that not works with REST api but works with SOAP API. Could you try to use email1_set_in_workflow key instead of email1?
It's not a very good solution but perhaps that could unlock you pending a better way to do that in future release

Zend_Feed_Reader Not supported Schema

I'm using Zend FW and wanted to make a feed reader. I did the following:
$feed = Zend_Feed_Reader::import('feed://blog.lookup.cl/?feed=rss2');
$data = array(
'title' => $feed->getTitle(),
'link' => $feed->getLink(),
'dateModified' => $feed->getDateModified(),
'description' => $feed->getDescription(),
'language' => $feed->getLanguage(),
'entries' => array(),
);
foreach ($feed as $entry) {
$edata = array(
'title' => $entry->getTitle(),
'description' => $entry->getDescription(),
'dateModified' => $entry->getDateModified(),
'authors' => $entry->getAuthors(),
'link' => $entry->getLink(),
'content' => $entry->getContent()
);
$data['entries'][] = $edata;
}
And it throws the following exception: Scheme "feed" is not supported
The blog was made using Wordpress.
What's wrong? If "feed it's not supported", how can I change the type of feed that Wordpress does?
Thanks in advance,
Take care,
Solved.
I had to put http instead of feed.