Medoo - Updating table row matching field - php

I am using Medoo but know very little php, the update below works fine but I only want it to update when the clientId matches what is posted:
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
));
//$_POST["clientId"];
I am using a newer version of PHP and am a little confused on the syntax, here is how it is with older versions of PHP
http://medoo.in/api/update

I assume you have clientId field in that table, you can try:
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
), array(
"clientId" => $_POST['clientId']
));
Hope it helps.

Related

How to update many fields at once in mongoDB PHP? [duplicate]

The following code should work. I could have missed something, but right now I have it as 2 separate update statements and have decided to ask here why this line isn't working.
$this->db->settings->update(array('_id' => $mongoID),
array(
'$set' => array('about' => $about),
'$set' => array('avatar' => $avatar)
)
);
Did I miss something when reading guides or is it only possible to do with separate update statements?
The third argument to MongoCollection::update is an array of options for the update operation.
$this->db->settings->update(
array('_id' => $mongoID),
array('$set' => array('about' => $about, 'avatar' => $avatar))
);

mongoDB, PHP update specific value not all the values

I am having a problem in updating values i get from web service ..
$collection = $modb->$table;
$collection->update(array("id" => (int)$row['id']),
array('$set' => array(
"user_id" => (int)$post_data_array['user_id'],
"story" => (int)$post_data_array['story'],
"surprize_sub1" => (int)$post_data_array['surprize_sub1'],
"surprize_sub2" => (int)$post_data_array['surprize_sub2'],
"surprize_sub3" => (int)$post_data_array['surprize_sub3'],
"exr_solve" => (int)$post_data_array['exr_solve'],
"exr_assessmnt" => (int)$post_data_array['exr_assessmnt'],
"exr_refresh" => (int)$post_data_array['exr_refresh'],
"sound_control" => (int)$post_data_array['sound_control'],
"clock_control" => (int)$post_data_array['clock_control'],
"switch_user" => (int)$post_data_array['switch_user'],
"exr_print" => (int)$post_data_array['exr_print'],
"write_on_wall" => (int)$post_data_array['write_on_wall'],
"switch_letter" => (int)$post_data_array['switch_letter'],
"view_controls" => (int)$post_data_array['view_controls'],
)));
I get these values from end users.. i want the specific field sent to be updated without loosing all the rest of data ..
in this code only sent data is set while removing the rest .. i want to change only sent ones by keeping the rest as they are, please advice
you need to use updateOne instead of update .
updateOne
Use the MongoDB\Collection::updateOne() method to update a single document matching a filter.
$collection = $modb->$table;
$collection->updateOne(array("id" => (int)$row['id']),
array('$set' => array(
// .... array elements
)));

php fedex set signature Label ADULT

I am working on wordpress site and using woocommerce extension http://www.woothemes.com/products/fedex-shipping-module/
I am Passing the values Signature value to adults. But it is not working
Please correct me where i am wrong
$request['RequestedShipment']['RateRequestTypes'] = $this->request_type;
$request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES';
$request['RequestedShipment']['SpecialServicesRequested'][] = array(
'SpecialServiceTypes' => 'SIGNATURE_OPTION',
'SignatureOptionDetail' => array(
'OptionType' => 'ADULT'
)
);
`
Do i need to change something from the from the RateService_v13.wsdl file
Please suggest
Thanks
I resolved this issue
For further user having the same issue can resolve this by below code
$item['SpecialServicesRequested'] = array(
'SpecialServiceTypes' => 'SIGNATURE_OPTION',
'SignatureOptionDetail' => array(
'OptionType' => 'ADULT'
)
);
$request['RequestedShipment']['RequestedPackageLineItems'][] = $item;
If Suppose anyone is using Fedex Integration with Laravel you may use below code.
In place of _DIRECT you may use _ADULT or any other option.
$packageLineItem1 = new FedexShipServiceCT\RequestedPackageLineItem();
$packageLineItem1
->setSequenceNumber(1)
->setItemDescription('Product')
->setSpecialServicesRequested(new FedexShipServiceCT\PackageSpecialServicesRequested(array(
'SignatureOptionDetail' => new FedexShipServiceCT\SignatureOptionDetail(array(
'OptionType' => FedexShipServiceST\SignatureOptionType::_DIRECT
))
)))
->setDimensions(new FedexShipServiceCT\Dimensions(array(
'Width' => 1,
'Height' => 1,
'Length' => 1,
'Units' => FedexShipServiceST\LinearUnits::_IN
)))
->setWeight(new FedexShipServiceCT\Weight(array(
'Value' => 1,
'Units' => FedexShipServiceST\WeightUnits::_LB
)));
Thanks

create a .php file through the launch of a .bat

I need to launch a .bat file that creates a php file, containing this text:
<?php
$_mail_mailSpooler = array (
'classname' => 'mail_mailSpooler',
'from' => 'test#test.com',
'array_indirizzi_mail' =>
array (
0 => ‘lol#hotmail.com’,
'testo_mail' => ‘prova’,
'filename_html' => NULL,
'oggetto_mail' => ‘prova’,
'elenco_allegati' => '',
'forza_mail_txt' => 0,
'asl_logger' => '',
'log_identifier' => NULL,
'log_in_web' => 0,
'log_str' => '',
'nome_file_dump' => '../mailSpooler/mail_incoming/maildda2.php',
);
I have tried echo " (test)" >gnagna.php
but it doen't work.
any suggestion please?
thanks
use type instead of echo - echo's only supposed to give user feedback, file reading and writing is properly done by type. Have a look at http://www.robvanderwoude.com/allhelpw2ksp4_en.php#TYPE for more
sorry, but i'm not already able to launch my php with right code.
i've tried type <?php
$_mail_mailSpooler = array (
'classname' => 'mail_mailSpooler',
'from' => 'test#test.com',
'array_indirizzi_mail' =>
array (
0 => ‘lol#hotmail.com’,
'testo_mail' => ‘prova’,
'filename_html' => NULL,
'oggetto_mail' => ‘prova’,
'elenco_allegati' => '',
'forza_mail_txt' => 0,
'asl_logger' => '',
'log_identifier' => NULL,
'log_in_web' => 0,
'log_str' => '',
'nome_file_dump' => '../mailSpooler/mail_incoming/maildda2.php',
); C:\>test.php
but it doesn't work.
moreover your link says that this command displays the content of an existing file and i need to create a new one!

How to log dimension like AWS CloudWatch bundled metric

Can anyone explain how to use the AWS PHP SDK to log the metric in the style like the above screen.
I use the following PHP code but the select menu is showing "ELB: AvaliabiltyZone", how to make it show "Aggregated by AvaliabiltyZone"? What is the logic used here?
$response = $cw->put_metric_data("ELB", array(
array(
"MetricName" => "Latency",
"Dimensions" => array(
array("Name" => "AvaliabiltyZone" , "Value" => "us-east-1c")
),
"Timestamp" => "now",
"Value" => 1,
"Unit" => "None"
),
));
AvaliabiltyZone
You misspelled "AvailabilityZone"
This maybe won't answer the question, but it might fix some things...
$cw = new AmazonCloudWatch();
$cw->set_region('monitoring.'.$region.'amazonaws.com');
$res1 = $CW->put_metric_data('Sys/RDS' ,
array(array('MetricName' => 'Uptime' ,
'Dimensions' => array(array('Name' => 'AvaliabiltyZone',
'Value' => 'us-east-1c')),
'Value' => $Uptime,
'Unit' => 'Seconds')));
Click Here

Categories