本文整理匯總了PHP中DboSource::expression方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::expression方法的具體用法?PHP DboSource::expression怎麽用?PHP DboSource::expression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::expression方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add
public function add()
{
//var_dump($this->request->data);
$this->loadModel('User');
$us = $this->User->find('all');
//var_dump($us['0']);
if (!empty($this->data)) {
$this->loadModel('User');
$this->User->create();
//$this->request->data['User']['ip'] = $this->request->clientIp();
$m = $this->request->data['User']['dob']['month'];
$d = $this->request->data['User']['dob']['day'];
$y = $this->request->data['User']['dob']['year'];
$dob = $m . '-' . $d . '-' . $y;
//$mem = $this->request->data['User']['member'];
//var_dump($mem);
$this->request->data['User']['dob'] = $dob;
//$this->request->data['User']['mem'] = 'User';
//$this->request->data['login_attempt']['login_times'] = 1;
$this->request->data['User']['register_date'] = DboSource::expression('NOW()');
if ($this->User->save($this->request->data)) {
//echo "<div id='footer_a_link'>";
$this->Session->setFlash('You are registered successfully. Please log in.');
// $this->redirect(array('action' => 'login', 'controller' => 'Users'));
} else {
$this->Session->setFlash('Not Registered');
}
}
}
示例2: create_concert
public function create_concert()
{
$this->loadModel('Taste');
$load_taste = $this->Taste->find('all');
$this->set(compact('load_taste', 'load_taste'));
//var_dump($this->request->data);
$this->loadModel('Band');
$load_band = $this->Band->find('all');
$this->set(compact('load_band', 'load_band'));
$this->loadModel('Concert');
//var_dump($this->request->data);
if (!empty($this->data)) {
$this->Concert->create();
//$this->request->data['User']['ip'] = $this->request->clientIp();
$this->request->data['Concert']['concert_name'] = $this->request->data['Concerts']['concert_name'];
$this->request->data['Concert']['concert_place'] = $this->request->data['Concerts']['concert_place'];
$this->request->data['Concert']['concert_time'] = $this->request->data['Concerts']['concert_time'];
$this->request->data['Concert']['concert_ticket_price'] = $this->request->data['Concerts']['concert_ticket_price'];
$this->request->data['Concert']['concert_band'] = $this->request->data['concert_band'] + 1;
$this->request->data['Concert']['concert_taste'] = $this->request->data['concert_taste'] + 1;
//$this->request->data['Concert']['band_name'] = $this->request->data['Bands']['band_name'];
//$this->request->data['login_attempt']['login_times'] = 1;
$this->request->data['Concert']['concert_creation_date'] = DboSource::expression('NOW()');
if ($this->Concert->save($this->request->data)) {
//echo "<div id='footer_a_link'>";
$this->Session->setFlash('Concert has been registered successfully.');
//$this->redirect(array('action' => 'index', 'controller' => 'Bands'));
} else {
$this->Session->setFlash('Not Registered');
}
}
}
示例3: process
public function process()
{
$c = new CakeEmail('default');
//grab 50 emails
$emails = $this->EmailMessage->find("all", array("conditions" => array("EmailMessage.processed" => 0, "EmailMessage.to !=" => '', "NOT" => array("EmailMessage.to" => null)), "contain" => array()));
$total_emails = count($emails);
$this->out("emails to processes: " . $total_emails);
SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Emails to processes: " . $total_emails));
foreach ($emails as $email) {
$e = $email['EmailMessage'];
$c->reset();
$c->config('default');
$c->to($e['to']);
$c->subject($e['subject']);
$c->template($e['template']);
$c->viewVars(array("msg" => $email));
if ($c->send()) {
$this->EmailMessage->create();
$this->EmailMessage->id = $e['id'];
$this->EmailMessage->save(array("processed" => 1, "sent_date" => DboSource::expression('NOW()')));
$total_emails--;
$this->out("Email:" . $e['to'] . " Template: " . $e['template']);
} else {
$this->out("Email failed: " . $e['id']);
SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Email Failed: " . $e['id']));
}
}
}
示例4: delete
public function delete($id = null)
{
if (!$id) {
$this->Session - setFlash('Tarea inválida');
$this->redirect(array('action' => 'index', 'pendiente'), null, true);
}
$this->Tarea->id = $id;
$this->request->data['Tarea']['estado'] = 1;
$this->request->data['Tarea']['finalizado'] = DboSource::expression('NOW()');
if ($this->Tarea->save($this->request->data)) {
$this->Session->setFlash('Tarea #' . $id . ' Terminada');
$this->redirect(array('action' => 'index', 'pendiente'), null, true);
}
}
示例5: beforeSave
public function beforeSave($options = array())
{
$key = $this->alias;
$update_time = @DboSource::expression('NOW()');
//update columns
if (empty($this->id)) {
if (empty($this->data[$key]['created'])) {
$this->data[$key]['created'] = $update_time;
}
}
if (empty($this->data[$key]['modified'])) {
$this->data[$key]['modified'] = $update_time;
}
return true;
}
示例6: admin_add
function admin_add()
{
if (!empty($this->request->data) && $this->request->is('post')) {
$this->User->create();
$this->request->data['User']['user_added_date'] = @DboSource::expression('NOW()');
$this->request->data['User']['password'] = md5($this->request->data['User']['password']);
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user added successfully', true), 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.', true), 'default', array('class' => 'error'));
}
}
$roles = $this->UserRole->find('all', array('conditions' => array('status' => 'Active'), 'order' => array('role_name' => 'asc')));
$this->set('Roles', $roles);
}
示例7: admin_edit
public function admin_edit($id = null)
{
$this->Cmse->id = $id;
if (!$this->Cmse->exists()) {
throw new NotFoundException(__('Invalid Page'));
}
if ($this->request->is('post') || $this->request->is('put')) {
$this->request->data['Cmse']['page_modified_date'] = DboSource::expression('now()');
if ($this->Cmse->save($this->request->data)) {
$this->Session->setFlash(__('The page has been saved'), 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The page could not be saved. Please, try again.'), 'default', array('class' => 'error'));
}
} else {
$this->request->data = $this->Cmse->read(null, $id);
}
}
示例8: assignUserACoupon
public function assignUserACoupon($forUser, $couponType = 1, $parameters = [])
{
$fields = ['presenter_id' => null, 'start_date' => date('Y-m-d H:i:s'), 'end_date' => '0000-00-00 00:00:00', 'max_redemptions' => '-1', 'discount_percentage' => 50, 'discount_flat' => '0.00', 'discount_sku' => null, 'reference_id' => null, 'user_visible' => true, 'expiration_date' => DboSource::expression('DATE_ADD(NOW(),INTERVAL 1 YEAR)')];
$data = array_merge($fields, $parameters);
$coupon = $this->CouponPresenter->getPresenterCoupon($data['presenter_id'], $couponType);
if (empty($coupon)) {
$success = $this->CouponPresenter->saveCreate(array("presenter_id" => $data['presenter_id'], "coupon_id" => $couponType, "start_date" => $data['start_date'], "end_date" => $data['end_date'], "max_redemptions" => $data['max_redemptions'], "discount_percentage" => $data['discount_percentage'], "discount_flat" => $data['discount_flat'], "discount_sku" => $data['discount_sku'], "expiration_date" => $data['expiration_date']));
if ($success) {
$coupon = $this->CouponPresenter->getPresenterCoupon($data['presenter_id'], $couponType);
}
}
//Coupon should be assigned now
if (!empty($coupon)) {
$this->create();
$return = $this->save(array("coupon_presenter_id" => $coupon['CouponPresenter']['id'], "user_id" => $forUser, "reference_id" => $data['reference_id'], "user_visible" => $data['user_visible'], "date_added" => date('Y-m-d H:i:s'), "redemption_reference_id" => '', "redemption_amount" => '0.00', "expiration_date" => $data['expiration_date']));
} else {
$return = NULL;
}
return $return;
}
示例9: admin_verify_login
function admin_verify_login()
{
if (!empty($this->data)) {
$rs = $this->Login->verifyLogin($this->data);
if ($rs) {
$this->Session->write('User', $rs);
$this->Session->write('LoginStatus', 1);
/*-save last login details-*/
$arrData = array('User' => array('last_login_ip' => $this->request->clientIp(), 'last_login_date' => @DboSource::expression('NOW()')));
$this->User->validation = null;
$this->User->id = $rs['Login']['id'];
$this->User->save($arrData, false);
//print_r($rs['Login']['id']);die;
/*-[end]save last login details-*/
$this->redirect('/admin/users/index');
} else {
$this->Session->setFlash("Invalid Email or Password");
$this->redirect(array('action' => 'index'));
}
}
}
示例10: testCalculations
/**
* testCalculations method
*
* @return void
*/
public function testCalculations()
{
$this->Model = new TestModel();
$result = $this->Dbo->calculate($this->Model, 'count');
$this->assertEquals('COUNT(*) AS `count`', $result);
$result = $this->Dbo->calculate($this->Model, 'count', array('id'));
$this->assertEquals('COUNT(`id`) AS `count`', $result);
$result = $this->Dbo->calculate($this->Model, 'count', array($this->Dbo->expression('DISTINCT id')));
$this->assertEquals('COUNT(DISTINCT id) AS `count`', $result);
$result = $this->Dbo->calculate($this->Model, 'count', array('id', 'id_count'));
$this->assertEquals('COUNT(`id`) AS `id_count`', $result);
$result = $this->Dbo->calculate($this->Model, 'count', array('Model.id', 'id_count'));
$this->assertEquals('COUNT(`Model`.`id`) AS `id_count`', $result);
$result = $this->Dbo->calculate($this->Model, 'max', array('id'));
$this->assertEquals('MAX(`id`) AS `id`', $result);
$result = $this->Dbo->calculate($this->Model, 'max', array('Model.id', 'id'));
$this->assertEquals('MAX(`Model`.`id`) AS `id`', $result);
$result = $this->Dbo->calculate($this->Model, 'max', array('`Model`.`id`', 'id'));
$this->assertEquals('MAX(`Model`.`id`) AS `id`', $result);
$result = $this->Dbo->calculate($this->Model, 'min', array('`Model`.`id`', 'id'));
$this->assertEquals('MIN(`Model`.`id`) AS `id`', $result);
$result = $this->Dbo->calculate($this->Model, 'min', 'left');
$this->assertEquals('MIN(`left`) AS `left`', $result);
}
示例11: dataFlow5_archived
/**
* Data flow 5 - N2Y
* @see DataFlowFiveTask
*/
public function dataFlow5_archived()
{
$this->Orders = ClassRegistry::init('Orders');
$this->OrderShipmentPackage = ClassRegistry::init('OrderShipmentPackage');
$folder = "dataflow5";
$files = $this->NetSuite->download(AWS_NETSUITE_RECEIVING_BUCKET, $folder);
$email = 'netsuite_api@youniqueproducts.com';
$this->out('Files found: ' . count($files), 1, Shell::VERBOSE);
foreach ($files as $file) {
$packages = $file['data'];
$this->out('File: ' . $packages['file'], 1, Shell::VERBOSE);
foreach ($packages as $package_data) {
if (strlen($package_data->order_id) >= 13 && substr($package_data->order_id, 0, 13) == "Sales Order #") {
$order_id = substr($package_data->order_id, 13);
} elseif (substr($package_data->order_id, 0, 2) == "SO") {
$order_id = substr($package_data->order_id, 2);
} else {
$order_id = $package_data->order_id;
}
$this->out('Order updating: ' . $order_id, 1, Shell::VERBOSE);
$OrderShipmentId = $package_data->shipment_id;
$DateShipped = date("Y-m-d H:i:s", strtotime($package_data->ship_date));
$TrackingNumber = $package_data->tracking_numbers;
$Carrier = $package_data->shipping_carrier;
$ShipMethod = $package_data->shipping_method;
$updating = array('order_shipment_id' => $OrderShipmentId, 'date_shipped' => $DateShipped, 'shipping_method' => $ShipMethod, 'tracking_number' => $TrackingNumber, 'carrier' => $ShipMethod);
$shipment_record = $this->OrderShipmentPackage->getPackageDetailsByShipmentId($OrderShipmentId);
if (count($shipment_record) && ($shipment_record[0]['OrderShipmentPackage']['tracking_number'] == null || $shipment_record[0]['OrderShipmentPackage']['tracking_number'] == '')) {
$OrderShipmentPackageId = $shipment_record[0]['OrderShipmentPackage']['id'];
$this->OrderShipmentPackage->updatePackageDetails($OrderShipmentPackageId, $updating);
} elseif (!count($shipment_record)) {
$updating['date_created'] = date("Y-m-d H:i:s");
$this->OrderShipmentPackage->savePackageDetails($updating);
$shipment_record = $this->OrderShipmentPackage->getPackageDetailsByShipmentId($OrderShipmentId);
$email_result = $this->NetSuite->sendCustomerTrackingEmail($shipment_record);
if ($email_result == 1) {
$this->out("Tracking email sent: " . $shipment_record[0]['OrderShipmentPackage']['tracking_number']);
} else {
$this->out("ERROR: Tracking email failed or was already sent.");
}
} else {
$this->out("Shipment: " . $OrderShipmentId . ", was not saved - maybe it already existed");
}
$this->Order->updateOrderStatus($order_id, Order::STATUS_SHIPPED);
$this->Order->updateSecondaryStatus($order_id, DboSource::expression('NULL'));
$this->out('Order updated: ' . $order_id, 1, Shell::VERBOSE);
$this->hr();
}
$new_file_location = str_replace("tmp", "processed", $file['file']);
$this->client->registerStreamWrapper();
rename($file['file'], $new_file_location);
}
return true;
}
示例12: open
public function open()
{
$this->saveField('party_status_id', 1);
$this->saveField('end_time', DboSource::expression("concat_ws(' ',CURDATE() + INTERVAL 10 DAY,'23:59:59')"));
return true;
//return $this->finalize();
}
示例13: review
function review()
{
if (!$this->Session->check($_GET['token'])) {
$this->Session->write($_GET['token'], 'InProgress');
} else {
if ($this->Session->read($_GET['token']) == 'canceled') {
return $this->redirect('http://' . env('SERVER_NAME') . '/recipes/index');
}
}
if ($this->request->is('POST') || $this->request->is('PUT')) {
$submit = $this->data['submit'];
if ($submit == 'cancel') {
$this->Session->write($_GET['token'], 'canceled');
return $this->redirect('http://' . env('SERVER_NAME') . '/recipes/index');
}
}
$paypal_api_username = Configure::read('paypal_api_username');
$paypal_api_password = Configure::read('paypal_api_password');
$paypal_api_signature = Configure::read('paypal_api_signature');
$params = array('method' => 'GetExpressCheckoutDetails', 'version' => '106', 'user' => $paypal_api_username, 'pwd' => $paypal_api_password, 'signature' => $paypal_api_signature, 'token' => $_GET['token']);
$shopping_items = array();
$result = $this->__paypalClassicApi($params);
$paypal_item_number = 0;
while ($paypal_item_number < 1000) {
if (isset($result['L_NUMBER' . $paypal_item_number])) {
$item_data = $result['L_NUMBER' . $paypal_item_number];
// index 0 type, 1 ID
$pieces = explode('#', $item_data);
$buyable = $this->Payment->checkIfBuyable($pieces[1]);
if ($buyable == false) {
$this->__purchase_error();
}
$shopping_items[] = array('id' => $pieces[1], 'type' => 'recipe');
} else {
break;
}
$paypal_item_number++;
}
if (!isset($result['CHECKOUTSTATUS']) || $result['CHECKOUTSTATUS'] == 'PaymentActionCompleted') {
$this->log($result, 'error');
$this->log($this->_logged_user['id'] . ' review function error 2', 'error');
$this->__purchase_error();
}
if ($this->request->is('POST') || $this->request->is('PUT')) {
$shopping_items = array();
$item_names = array();
$paypal_item_number = 0;
while ($paypal_item_number < 1000) {
if (isset($result['L_NUMBER' . $paypal_item_number])) {
$item_data = $result['L_NUMBER' . $paypal_item_number];
$amount = $result['L_PAYMENTREQUEST_0_AMT' . $paypal_item_number];
$tax = $result['L_PAYMENTREQUEST_0_TAXAMT' . $paypal_item_number];
$item_names[] = $result['L_PAYMENTREQUEST_0_NAME' . $paypal_item_number];
$pieces = explode('#', $item_data);
$shopping_items[] = array('id' => $pieces[1], 'type' => $pieces[0], 'amount' => $amount, 'tax' => $tax);
} else {
break;
}
$paypal_item_number++;
}
$this->log('Payment Transaction start', 'debug');
$currency = $result['CURRENCYCODE'];
$params = array('user' => $paypal_api_username, 'pwd' => $paypal_api_password, 'signature' => $paypal_api_signature, 'method' => 'DoExpressCheckoutPayment', 'version' => '106', 'token' => $_GET['token'], 'PAYERID' => $_GET['PayerID'], 'PAYMENTREQUEST_0_AMT' => $result['AMT'], 'PAYMENTREQUEST_0_CURRENCYCODE' => $result['CURRENCYCODE'], 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale');
$result1 = $this->__paypalClassicApi($params);
$dataSource = $this->Payment->getDataSource();
try {
$dataSource->begin();
foreach ($shopping_items as $shopping_item) {
$category = $shopping_item['type'];
$category = ucfirst($category);
$amount = $shopping_item['amount'] + $shopping_item['tax'];
$this->Payment->create();
$this->Payment->set(array('item_id' => $shopping_item['id'], 'user_id' => $this->_logged_user['id'], 'trans_type' => 'purchased', 'amount' => $amount, 'currency' => $currency, 'category' => $category, 'recipe_access_level' => 2, 'display_from' => DboSource::expression('NOW()')));
if (!$this->Payment->save()) {
throw new Exception();
}
}
$dataSource->commit();
} catch (Exception $e) {
$this->log('Payment Transaction error', 'error');
$this->__purchase_error();
}
$this->__email_transaction_complete($this->_logged_user['display_name'], $item_names);
$shopping_cart = array('loggin_id' => $this->_logged_user['id']);
$this->Cookie->write('shoppingcart', $shopping_cart, true, time() + 3600);
$this->log('Payment Transaction ends', 'debug');
$this->Session->setFlash('レシピ購入を完了しました。', 'default', array('class' => 'message success'));
$this->redirect(array('controller' => 'recipes', 'action' => 'complete_purchase'));
}
foreach ($shopping_items as $index => $item) {
$this->Recipe->id = $item['id'];
$recipe = $this->Recipe->read();
$img_path = '/uploads/recipe/' . $recipe['Recipe']['hash'] . '/disp/recipe' . $recipe['Recipe']['id'] . '.jpg';
$shopping_items[$index]['image'] = $img_path;
$shopping_items[$index]['name'] = $recipe['Recipe']['title'];
}
$this->set('details', $result);
$this->set('title', "確認ページ");
$this->set('data', $shopping_items);
}
示例14: createUser
private function createUser($username, $display, $token)
{
App::uses('String', 'Utility');
$this->User->deleteAll(array('TwitchUsername' => $username));
$newUser = array('APIKey' => strtoupper(String::uuid()), 'TwitchUsername' => $username, 'TwitchDisplay' => $display, 'TwitchToken' => $token, 'CreateDate' => DboSource::expression('NOW()'));
$this->User->save($newUser);
return array($newUser);
}
示例15: changePresenterStatus
public function changePresenterStatus($presenter_id, $new_status, $admin_user)
{
$presenter = $this->read('', $presenter_id);
$this->saveField("presenter_status_id", $new_status);
if (in_array($new_status, array(PresenterStatus::SUSPENDED, PresenterStatus::CANCELLED, PresenterStatus::TERMINATED, PresenterStatus::VOLUNTARY_SUSPENSION))) {
$this->saveField("terminated_date", DboSource::expression('NOW()'));
} else {
$this->saveField("terminated_date", NULL);
$this->query("\n\t\t\t\tINSERT INTO termination_history (terminated_date, reactivated_date, presenter_id) \n\t\t\t\tVALUES('{$presenter['Presenter']['terminated_date']}', NOW(), {$presenter_id});\n\t\t\t");
}
// log change
// $admin_user is integer when called from CronPresenterMonthlyShell.php
$admin_user_id = gettype($admin_user) === 'object' ? $admin_user->id : $admin_user;
App::uses('AdminUserAudit', 'Model');
$this->AdminUserAudit = new AdminUserAudit();
$this->AdminUserAudit->create();
$this->AdminUserAudit->saveField('admin_user_id', $admin_user_id);
$this->AdminUserAudit->saveField('reference_name', 'presenters.presenter_status_id');
$this->AdminUserAudit->saveField('reference_id', $presenter_id);
$this->AdminUserAudit->saveField('old_value', $presenter['Presenter']['presenter_status_id']);
$this->AdminUserAudit->saveField('new_value', $new_status);
$this->AdminUserAudit->saveField('notes', "Admin3 sponsor status change");
}