本文整理汇总了PHP中to_int函数的典型用法代码示例。如果您正苦于以下问题:PHP to_int函数的具体用法?PHP to_int怎么用?PHP to_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_question_detail
public function get_question_detail($question_id, $form_type_id)
{
$this->db->where('id', to_int($question_id));
$this->db->where('form_type_id', to_int($form_type_id));
$this->db->select('q.id as question_id, q.form_type_id, q.form_section_id, q.description, q.help_text, q.type, q.allowed_types, q.max_size, q.table, q.options, q.sort_order')->from('questions q');
return $this->db->get()->row();
}
示例2: _post_args
protected function _post_args($key, $type = ARGS_TYPE_STRING, $default = '', $params = array())
{
$value = '';
$post_default = '';
$key_exist = array_key_exists($key, $_POST);
$override = array_key_exists('override', $params) ? $params['override'] : FALSE;
$entities_to_ascii = array_key_exists('entities_to_ascii', $params) ? $params['entities_to_ascii'] : FALSE;
$gtzero = array_key_exists('gtzero', $params) ? $params['gtzero'] : TRUE;
switch ($type) {
case ARGS_TYPE_STRING:
$post_default = $override ? $default : '';
$value = $key_exist ? $this->input->post($key, TRUE) ? $this->input->post($key, TRUE) : $post_default : $default;
if ($entities_to_ascii) {
$value = entities_to_ascii($value);
}
break;
case ARGS_TYPE_INT:
$default = validate_integer($default) ? to_int($default) : 0;
$post_default = $override ? $default : 0;
$value = $key_exist ? ($value = $this->input->post($key)) && gtzero_integer($value) ? to_int($value) : $post_default : $default;
break;
case ARGS_TYPE_TRUE_FALSE:
$default = validate_integer($default) ? gtzero_integer($default) ? TRUE : FALSE : FALSE;
$post_default = $override ? $default : FALSE;
$value = $key_exist ? ($value = $this->input->post($key)) && ($gtzero && gtzero_integer($value) || !$gtzero && validate_integer($value)) ? TRUE : $post_default : $default;
break;
case ARGS_TYPE_ARRAY:
$value = $key_exist ? ($value = $this->input->post($key)) && is_array($value) ? $value : array() : (is_array($default) ? $default : array());
break;
case ARGS_TYPE_DECIMAL:
$default = gtzero_decimal($default) ? to_float($default) : 0;
$post_default = $override ? $default : 0;
$value = $key_exist ? ($value = $this->input->post($key)) && gtzero_decimal($value) ? to_float($value) : $post_default : $default;
break;
case ARGS_TYPE_DATE:
$default = validate_date($default) ? $default : '';
$post_default = $override ? $default : '';
$value = $key_exist ? ($value = $this->input->post($key)) && validate_date($value) ? $value : $post_default : $default;
break;
case ARGS_TYPE_DATETIME:
$default = validate_datetime($default) ? $default : '';
$post_default = $override ? $default : '';
$value = $key_exist ? ($value = $this->input->post($key)) && validate_date($value) ? $value : $post_default : $default;
break;
default:
$post_default = $override ? $default : '';
$value = $key_exist ? $this->input->post($key, TRUE) ? $this->input->post($key, TRUE) : $post_default : $default;
break;
}
unset($post_default);
return $value;
}
示例3: buildQuerySets
/** Builds the query from the the key=> values either in the arg $arr
* (if it was implemented from a controller action), or
* from it's own values (if it is implemented in a search model), or from
* a post array if it is implemented from a controller.
* @param array $arr
* @return array keyed by
* 'fieldname'=>['val'=>$val,'crit'=>$crit, {'param'=>$param}
*/
public function buildQuerySets(Array $arr = []) {
if ($this->matchObjs === null) {
$this->matchObjs=PkMatch::matchFactory(static::getFullQueryDef());
}
//pkdebug("The generated 'matches' are", $this->matchObjs);
$this->checkClearPost();
if (empty($arr)) {
if ($this instanceOf PkModel) {
#To use Accessors/Mutators
//$arr = $this->getAttributes();
$arr = $this->getAccessorAttributes();
}
}
if (empty($arr)) return [];
$sets = [];
$clear = false;
if (array_key_exists('submit', $arr) && ($arr['submit'] == 'clear'))
$clear = true;
foreach ($arr as $key => $val) {
#Does it end in '_crit'?
$root = removeEndStr($key, '_crit');
if ($root === false) continue;#Not a crit
if ($val === null) continue;
if (!$this->isValidCriterion($key)) continue;
#We COULD get static::getBasenameQueryDef($root) now, and see if we have supplimental info
$maxvalfield = $root . '_maxval'; #For 'BETWEEN'comparison
$minvalfield = $root . '_minval'; #For 'BETWEEN'comparison
$valfield = $root . '_val';
$valval = null;
#Getting Complicated. $valval can be a scalar for ordinary comparison
#If doing an " IN " comparison, $valval is a JSON encoded array.
#if doing a "BETWEEN" comparison, $valval is an actual array, ['max'=>$max,'min'=>$min]
$rootMatch = keyVal($root, $this->matchObjs, new PkMatch);
if (array_key_exists($maxvalfield, $arr)) {
$valval['maxval'] = $arr[$maxvalfield];
$rootMatch->maxval = $arr[$maxvalfield];
}
if (array_key_exists($minvalfield, $arr)) {
$valval['minval'] = $arr[$minvalfield];
$rootMatch->minval = $arr[$minvalfield];
}
if (is_array($valval)) { #At least one of min or max was set for BETWEEN
$rootMatch->maxval=$valval['maxval'] = to_int(keyVal('maxval', $valval), PHP_INT_MAX);
$rootMatch->minval=$valval['minval'] = to_int(keyVal('minval', $valval), -PHP_INT_MAX);
}
if (array_key_exists($valfield, $arr)) $valval = $arr[$valfield];
if ($valval === null) continue;
//if (!array_key_exists($valfield, $arr)) continue;
$paramfield = $root . '_param';
$arr[$paramfield] = keyVal($paramfield, $arr);
#We have a criterion and value - build our array
//$sets[$root] = ['crit' => $arr[$key], 'val' => $arr[$valfield], 'param' => $arr[$paramfield]];
$sets[$root] = [];
$rootMatch->crit=$sets[$root]['crit'] = $arr[$key];
$rootMatch->val=$sets[$root]['val'] = $valval;
$rootMatch->param=$sets[$root]['param'] = $arr[$paramfield];
$sets[$root]['def'] = static::getFullQueryDef($root);
}
$this->querySets = $sets;
//pkdebug("After QA, mathcObjs are:", $this->matchObjs);
//foreach ($this->matchObjs as $ma) {
//if ($ma->compfield == 'assetdebtratio') pkdebug("After buildQS, The MA is: ", $ma);
//}
return $sets;
}
示例4: deactivate
public function deactivate($pkey, $method = "echo")
{
_has_user_access_permission(TRUE, array('admin', 'management_company'));
$params = ($params = unserialize_object($pkey)) && is_array($params) ? $params : array();
$company_id = $this->current_user->group_id == GROUP_ADMIN ? 0 : $this->current_user->company_id;
$user_id = isset($params[SYS_USER_ID]) && gtzero_integer($params[SYS_USER_ID]) ? to_int($params[SYS_USER_ID]) : 0;
$code = isset($params['code']) && !empty($params['code']) ? $params['code'] : FALSE;
$redirect_url = $this->_post_args('redirect_url', ARGS_TYPE_STRING, $this->agent->referrer());
$user_info = $this->user_m->details($user_id);
if (!$user_info || _has_company_group_access($this->current_user->group_id) && $user_info->company_id != $this->current_user->company_id || $this->current_user->user_id == $user_id) {
$this->show_permission_denied_error($method);
}
$company_id = $user_info->company_id;
$this->form_validation->set_rules('confirm', 'confirm', 'trim|required');
$output = array('message' => "", 'status' => "");
if ($this->form_validation->run() == TRUE) {
/*if ($this->_valid_csrf_nonce() === FALSE || $user_id != $this->input->post('id'))
{
show_error('This form post did not pass our security checks.');
}*/
$is_record_updated = $this->ion_auth->deactivate($user_id);
if ($is_record_updated) {
$output['message'] = sprintf('The user "%s" has been deactivated.', $user_info->full_name);
$output['status'] = SUCCESS_MESSAGE;
$output['user_id'] = $user_id;
/*trigger_trip("user_activated", $user_info->company_id, array('user_id' => $user_id, 'updated_by' => $this->current_user->user_id));*/
} else {
$output['message'] = sprintf('Error occurred while trying to deactivated user "%s".', $user_info->full_name);
$output['status'] = ERROR_MESSAGE;
}
$this->_output_request($output, $redirect_url);
} else {
if (validation_errors()) {
$output['message'] = validation_errors();
$output['status'] = ERROR_MESSAGE;
}
}
$csrf = _get_csrf_nonce();
$data = array('form_action' => site_url('users/deactivate/' . $pkey), 'cancel_url' => $redirect_url, 'page' => 'user/confirm', 'title' => 'Deactivate User', 'display_message' => sprintf('Are you sure you want to deactivate user "%s"?', $user_info->full_name), 'display_heading' => sprintf('Deactivate User', $user_info->full_name), 'submit_btn_text' => "Save Changes", 'hiddenvars' => array_merge($csrf, array('redirect_url' => $redirect_url)));
if ($this->input->is_ajax_request()) {
$html = $this->template->raw_view('pages/user/confirm_modal', $data, TRUE);
if ($method == "ajax") {
$output['html'] = $html;
$this->_output_request($output, $redirect_url);
} else {
echo $html;
}
} else {
if (!empty($output['status'])) {
set_flash_data($output['status'], $output['message'], FALSE);
}
$this->template->load('default', $data);
}
}
示例5: get_by_many
public function get_by_many($params = array(), $return = 'RESULT')
{
$this->db->select('nt.*')->select("CONCAT(u.first_name,' ',u.last_name) AS created_by_name", FALSE)->from('notes nt')->join('users u', 'nt.created_by = u.id', 'LEFT')->where('nt.is_deleted', 0);
if (array_key_exists('ref_id', $params)) {
$this->db->where('nt.ref_id', to_int($params['ref_id']));
}
if (array_key_exists('note_type_id', $params)) {
$this->db->where('nt.note_type_id', to_int($params['note_type_id']));
}
if (array_key_exists('note_id_not', $params) && !empty($params['note_id_not'])) {
$this->db->where('nt.id !=', $params['note_id_not'], FALSE);
}
if ($return == 'RESULT') {
return $this->db->get()->result();
} elseif ($return == 'ROW') {
$this->db->limit(1);
return $this->db->get()->row();
} elseif ($return == 'COUNT') {
return $this->db->count_all_results();
} else {
return $this->db->get()->result();
}
}
示例6: get_question_by_many
public function get_question_by_many($params = array(), $return = 'result')
{
$srv = sprintf("(SELECT\n\t`sf`.`id` AS `site_form_id`,`sf`.`site_id`, `q`.`id` AS `question_id`, `q`.`description` AS `question_desc`, `q`.`help_text`,`q`.`type` AS `question_type`, `q`.`allowed_types`, `q`.`max_size`, `q`.`options`\n\t, `q`.`table` AS `question_table`, `q`.`form_type_id`, `q`.`form_section_id`, `q`.`sort_order`\t\nFROM site_forms sf\n\tINNER JOIN questions q ON sf.form_type_id =q.form_type_id\nWHERE \n\tsf.site_id=%d\n\tAND sf.form_type_id=%d) AS srv", $params['site_id'], $params['form_type_id']);
$this->db->select('srv.*')->select('IFNULL(sff.answer, \'\') AS answer', FALSE)->select('IFNULL(sff.notes, \'\') AS notes', FALSE)->from('site_forms')->join($srv, 'site_forms.id=srv.site_form_id AND site_forms.site_id=srv.site_id AND site_forms.form_type_id=srv.form_type_id', 'INNER')->join('site_form_feedback sff', 'srv.site_form_id=sff.site_form_id AND srv.site_id=sff.site_id AND srv.form_type_id=sff.form_type_id AND srv.question_id=sff.question_id', 'LEFT')->where('site_forms.site_id', to_int($params['site_id']))->where('site_forms.form_type_id', to_int($params['form_type_id']))->where('site_forms.id', to_int($params['site_form_id']));
if (array_key_exists('question_id', $params) && $params['question_id']) {
$this->db->where('srv.question_id', to_int($params['question_id']));
}
$this->db->order_by('srv.form_type_id', 'ASC');
$this->db->order_by('srv.form_section_id', 'ASC');
$this->db->order_by('srv.sort_order', 'ASC');
return $return == 'row' ? $this->db->get()->row() : $this->db->get()->result();
}
示例7: get_user_profile
public function get_user_profile($user_id)
{
if (($data = _get_cache($user_id, CACHE_KEY_USER_PROFILE)) && $data !== FALSE) {
return $data;
}
$this->db->select('u.id AS user_id, u.username, u.email, u.first_name, u.last_name, u.avatar, u.phone, g.id as group_id, u.postcode')->select('g.name as group_name, g.description as group_description, u.gmt_offset')->select("CONCAT(u.first_name,' ', u.last_name) AS user_full_name", FALSE)->from('users u')->join('users_groups ug', 'u.id = ug.user_id', 'INNER')->join('groups g', 'ug.group_id = g.id', 'INNER')->where('u.id', to_int($user_id))->group_by('u.id');
$query = $this->db->get();
$user_info = $query->row();
if ($user_info) {
$user_info->user_id = to_int($user_info->user_id);
$user_info->group_id = to_int($user_info->group_id);
$user_info->gmt_offset = ci()->cfg->gmt_offset;
$user_info->{'company_id'} = $this->user_company_by_user_id($user_info->user_id, $user_info->group_id);
$user_info->{'client_ids'} = FALSE;
if ($user_info->group_id == GROUP_CLIENT_USER) {
$user_info->{'client_ids'} = $clients;
}
}
_set_cache($user_id, $user_info, CACHE_KEY_USER_PROFILE);
return $user_info;
}
示例8: details
public function details($product_id)
{
$this->db->select('p.*')->select("CONCAT(u.first_name,' ',u.last_name) AS created_by_name", FALSE)->from('manufacturers m')->join('users u', 'm.created_by = u.id', 'LEFT')->where('m.is_deleted', 0)->where('m.id', to_int($product_id));
$row = $this->db->get()->row();
return $row;
}
示例9: delete
public function delete($pkey, $method = "echo")
{
_has_user_access_permission(TRUE, array('admin', 'location_manager', 'user_company'));
$params = ($params = unserialize_object($pkey)) && is_array($params) ? $params : array();
$type_id = isset($params[SYS_CONTACT_TYPE_ID]) && gtzero_integer($params[SYS_CONTACT_TYPE_ID]) ? to_int($params[SYS_CONTACT_TYPE_ID]) : 0;
$ref_id = isset($params[SYS_REF_ID]) && gtzero_integer($params[SYS_REF_ID]) ? to_int($params[SYS_REF_ID]) : 0;
$contact_id = isset($params[SYS_CONTACT_ID]) && gtzero_integer($params[SYS_CONTACT_ID]) ? to_int($params[SYS_CONTACT_ID]) : 0;
$redirect_url = $this->_post_args('redirect_url', ARGS_TYPE_STRING, $this->agent->referrer());
$contact_info = $this->contact_m->details($contact_id, $ref_id, $type_id);
if (!$contact_info) {
$this->show_permission_denied_error($method);
}
$this->form_validation->set_rules('confirm', 'confirm', 'trim|required');
$output = array('message' => "", 'status' => "");
if ($this->form_validation->run() == TRUE) {
$is_record_updated = $this->contact_m->delete($contact_id);
if ($is_record_updated) {
$output['message'] = sprintf('The contact "%s" has been deleted.', $contact_info->contact_name);
$output['status'] = SUCCESS_MESSAGE;
$output['contact_id'] = $contact_id;
} else {
$output['message'] = sprintf('Error occurred while trying to delete contact "%s".', $contact_info->contact_name);
$output['status'] = ERROR_MESSAGE;
}
$this->_output_request($output, $redirect_url);
} else {
if (validation_errors()) {
$output['message'] = validation_errors();
$output['status'] = ERROR_MESSAGE;
}
}
$doc_key = $this->_post_args('doc_key', ARGS_TYPE_STRING) ? $this->_post_args('doc_key', ARGS_TYPE_STRING) : keygen();
$csrf = _get_csrf_nonce();
$data = array('form_action' => site_url('contacts/delete/' . $pkey), 'cancel_url' => $redirect_url, 'page' => 'contacts/delete', 'title' => 'Contact "' . $contact_info->contact_name . '"', "display_message" => sprintf('Are you sure you want to delete contact "%s"?', $contact_info->contact_name), "display_heading" => sprintf('Delete contact', $contact_info->contact_name), "submit_btn_text" => "Save Changes", 'hiddenvars' => array_merge($csrf, array('redirect_url' => $redirect_url)), 'doc_key' => $doc_key);
if ($this->input->is_ajax_request()) {
$html = $this->template->raw_view('pages/contacts/delete_modal', $data, TRUE);
if ($method == "ajax") {
$output['html'] = $html;
$this->_output_request($output, $redirect_url);
} else {
echo $html;
}
} else {
if (!empty($output['status'])) {
set_flash_data($output['status'], $output['message'], FALSE);
}
$this->template->load('default', $data);
}
}
示例10: displayValue
public static function displayValue($value = null) {
if (!$value) return '';
$value = to_int($value * 100);
return "$value%";
}
示例11: to_int
<?php
// implicitly weak mode code
function to_int(int &$x)
{
}
function to_float(float &$x)
{
}
function to_string(string &$x)
{
}
function to_bool(bool &$x)
{
}
$x = 1.0;
var_dump($x);
to_int($x);
// because $x is by-reference, the weak type hint converts it
var_dump($x);
to_float($x);
var_dump($x);
to_string($x);
var_dump($x);
to_bool($x);
var_dump($x);
示例12: show_files
public function show_files($pkey = '')
{
$document_type_id = 9;
$ref_id = 0;
$doc_ref = FALSE;
$params = ($params = wdp_arr_decode($pkey)) && is_array($params) ? $params : array();
if ($params) {
$ref_id = array_key_exists(WDP_REF_ID, $params) && gtzero_integer($params[WDP_REF_ID]) ? to_int($params[WDP_REF_ID]) : 0;
$document_type_id = array_key_exists(WDP_TYPE_ID, $params) && gtzero_integer($params[WDP_TYPE_ID]) ? to_int($params[WDP_TYPE_ID]) : 0;
} else {
$doc_secret_key = wdp_arr_decode($this->input->post('doc_secret_key'));
if ($doc_secret_key) {
$ref_id = isset($doc_secret_key[WDP_REF_ID]) ? $doc_secret_key[WDP_REF_ID] : FALSE;
$doc_ref = isset($doc_secret_key[WDP_DOC_REF]) ? $doc_secret_key[WDP_DOC_REF] : FALSE;
$document_type_id = isset($doc_secret_key[WDP_TYPE_ID]) ? $doc_secret_key[WDP_TYPE_ID] : 0;
} else {
$ref_id = $this->input->post('ref_id');
$doc_ref = $this->input->post('doc_ref');
$document_type_id = $this->input->post('document_type_id') ? $this->input->post('document_type_id') : 0;
}
}
$files = $this->document_model->get_files(array('ref_id' => $ref_id, 'doc_ref' => $doc_ref, 'document_type_id' => $document_type_id));
$this->template->raw_view('pages/docs/files', array('files' => $files, 'ref_id' => $ref_id));
}
示例13: delete
public function delete($client_id)
{
$this->db->where('id', to_int($client_id));
return $this->db->update('clients', array('is_deleted' => 1));
}
示例14: intOrNull
/**
* Useful for converting empty strings to null for inserting null to int
* fields in DB
* @param mixed $value
* @return integer|null
*/
function intOrNull($value = null) {
$int = to_int($value);
if ($int !== false) return $int;
return null;
}
示例15: index
public function index($pkey = '', $method = 'echo')
{
ensure_user_access(TRUE, array('admin', 'management_company'));
$params = ($params = wdp_arr_decode($pkey)) && is_array($params) ? $params : array();
$company_id = $this->current_user->group_id == 1 ? 0 : $this->current_user->company_id;
$grid_column_type_id = isset($params[GRID_CTYPE]) && gtzero_integer($params[GRID_CTYPE]) ? to_int($params[GRID_CTYPE]) : 0;
$redirect_url = $this->_post_args('redirect_url', ARGS_TYPE_STRING, $this->agent->referrer());
$params = array('user_id' => $this->current_user->user_id, 'grid_column_type_id' => $grid_column_type_id);
if (_check_company_user_access()) {
$params['company_id'] = $company_id;
}
$grid_columns = $this->setting_m->grid_columns_by_many($params);
if (!$grid_columns) {
$this->show_permission_denied_error($method);
}
$this->form_validation->set_rules('grid_column_rows', '', '');
$output = array('message' => "", 'status' => "");
if ($this->form_validation->run() == TRUE) {
$grid_column_rows = $this->_post_args('grid_column_rows', ARGS_TYPE_ARRAY);
if ($this->current_user->group_id == 2) {
$this->setting_m->delete_company_grid_columns($company_id, $grid_column_type_id);
foreach ($grid_column_rows as $grid_column_id => $is_visible) {
$this->setting_m->add_company_grid_columns(array('company_id' => $company_id, 'grid_column_id' => $grid_column_id, 'grid_column_type_id' => $grid_column_type_id, 'visible' => to_int($is_visible)));
}
$this->setting_m->user_grid_columns_by_many($company_id, array('company_id' => $company_id, 'grid_column_type_id' => $grid_column_type_id), TRUE);
} else {
$this->setting_m->delete_user_grid_columns($this->current_user->user_id, $grid_column_type_id);
foreach ($grid_column_rows as $grid_column_id => $is_visible) {
$this->setting_m->add_user_grid_columns(array('user_id' => $this->current_user->user_id, 'grid_column_id' => $grid_column_id, 'grid_column_type_id' => $grid_column_type_id, 'visible' => to_int($is_visible)));
}
$this->setting_m->user_grid_columns_by_many($company_id, array('user_id' => $this->current_user->user_id, 'grid_column_type_id' => $grid_column_type_id), TRUE);
}
$gparams = array('grid_column_type_id' => $grid_column_type_id, 'user_id' => $this->current_user->user_id);
if (_check_company_user_access()) {
$gparams['company_id'] = $this->current_user->company_id;
}
$grid_columns = $this->setting_m->user_grid_columns_by_many($this->current_user->company_id, $gparams);
$output['message'] = 'Setting Saved';
$output['status'] = SUCCESS_MESSAGE;
$output['grid_columns'] = $grid_columns;
//$output['redirect'] = $redirect_url;
$this->_output_request($output, $redirect_url);
} else {
if (validation_errors()) {
$output['message'] = validation_errors();
$output['status'] = ERROR_MESSAGE;
}
}
$details = $this->company_m->company_settings($company_id);
$data = array('form_action' => site_url('settings/gcolumns/index/' . $pkey), 'cancel_url' => $redirect_url, 'page' => 'settings/my_grid_permission', 'title' => 'Grid Setting', 'submit_btn_text' => 'Save Changes', 'company_id' => $company_id, 'grid_columns' => $grid_columns->columns, 'js_files' => array('settings/gcolumns.js'), 'hiddenvars' => array('redirect_url' => $redirect_url));
if ($this->input->is_ajax_request()) {
$html = $this->template->raw_view('pages/settings/my_grid_permission_modal', $data, TRUE);
if ($method == "ajax") {
$output['html'] = $html;
$this->_output_request($output, $redirect_url);
} else {
echo $html;
}
} else {
$this->template->load('default', $data);
}
}