本文整理汇总了PHP中objectToArray函数的典型用法代码示例。如果您正苦于以下问题:PHP objectToArray函数的具体用法?PHP objectToArray怎么用?PHP objectToArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了objectToArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculoAportacionCiudadano
/**
*
* @param array $param
* <br>Parámetros de entrada.
* @return array
*/
function calculoAportacionCiudadano($param)
{
global $respError, $farmacia;
$param = objectToArray($param);
//die(print_r($param));
if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
if (DEBUG & DEBUG_LOG) {
$mensaje = print_r($param, TRUE);
$mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
}
unset($param["farmacia"]);
unset($param["DNI"]);
$client = new SoapClient(END_POINT, array("location" => LOCATION, "trace" => true, "exceptions" => false));
$result = $client->__soapCall(__FUNCTION__, array($param));
//die(print_r($result));
if (is_soap_fault($result)) {
if ($farmacia == FARMACIA_DEBUG or strlen(FARMACIA_DEBUG) == 0) {
if (DEBUG & DEBUG_LOG) {
$mensaje = "REQUEST:\n" . $client->__getLastRequest() . "\n";
$mensaje .= "RESPONSE:\n" . $client->__getLastResponse() . "\n";
$mensaje .= "RESULT:\n" . $result . "\n";
$mensaje .= "--SOAP FAULT, llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__ . "\n";
error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
}
return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => array("codigoResultadoOperacion" => -9000, "mensajeResultadoOperacion" => $result->faultstring)));
}
return array(__FUNCTION__ . "Result" => array("return" => $result->return, "resultadoOperacion" => $respError->sinErrores()));
}
示例2: getRecommendation
function getRecommendation($json = TRUE)
{
/**
* Gets the recommendation
* @author Germán Sánchez (GREC-ESADE), Collage
* @version march 2014
*/
global $debugar;
$reqs = objectToArray(json_decode(file_get_contents("php://input")));
if ($debugar) {
echo '<p>Recommender starts. Requirements received:</p>';
echo '<pre>';
var_dump($reqs);
echo '</pre>';
}
// Check inputs and return error if so
// Start recommendation
// 1.- Identification module: list of initial candidates
$initialCandidates = getFeasibleCandidates($reqs);
if ($debugar) {
echo '<h2>Initial candidates:</h2><pre>' . print_r($initialCandidates, TRUE) . '</pre>';
}
// 2.- Selection module: assess candidates and rank them
$finalCandidates = assessAndRank($initialCandidates, $reqs);
if ($debugar) {
echo '<h2>Final candidates:</h2><pre>' . print_r($finalCandidates, TRUE) . '</pre>';
}
if ($json) {
$output = json_encode($finalCandidates);
} else {
$output = $finalCandidates;
}
return $output;
}
示例3: seleccionarRegistro
function seleccionarRegistro($param)
{
$select = array("farmacia", "idDispensable", "codigoNacionalPrescrito", "codigoNacional", "envases", "dni", "contenido", "pvpComer", "pvpCalculado", "aportacionProducto", "codigoAportacion", "idActoDispensacion", "idDispensacion", "farmaceutico", "CONVERT(nvarchar(30), fechaGrabacion, 126) as fechaGrabacion", "CONVERT(nvarchar(30), fechaAnulacion, 126) as fechaAnulacion", "CONVERT(nvarchar(30), fechaFirma, 126) as fechaFirma", "origen", "firma", "firmaFacturacion", "validado", "firmado", "borrado");
global $respError, $conn, $SQLserverName;
$param = objectToArray($param);
$farmacia = $param["farmacia"];
$DNIFarmacia = $param["DNIFarmacia"];
$where = array("farmacia =" => $farmacia);
if (isset($param["idDispensable"])) {
$idDispensable = $param["idDispensable"];
$where["idDispensable like"] = "%{$idDispensable}%";
}
if (isset($param["fechaGrabacion"])) {
$fechaGrabacion = $param["fechaGrabacion"];
$where["fechaGrabacion ="] = $fechaGrabacion;
}
if (DEBUG & DEBUG_LOG) {
$mensaje = print_r($param, TRUE);
$mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
$tabla = PREFIJO_TABLA_DISPENSACION . date("ym");
$resultadoSelect = querySelect($conn, $tabla, $select, $where);
if ($resultadoSelect["columnasAfectadas"] === NULL) {
$resultadoOperacion = array("codigoResultadoOperacion" => $resultadoSelect[0]["code"], "mensajeResultadoOperacion" => $resultadoSelect[0]["message"]);
return array(__FUNCTION__ . "Result" => array("columnasAfectadas" => $resultadoSelect["columnasAfectadas"], "resultadoSelect" => $resultadoSelect["resultset"], "resultadoOperacion" => $resultadoOperacion));
}
return array(__FUNCTION__ . "Result" => array("columnasAfectadas" => $resultadoSelect["columnasAfectadas"], "resultadoSelect" => $resultadoSelect["resultset"], "resultadoOperacion" => $respError->sinErrores()));
}
示例4: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
//
$tutorials = objectToArray(DB::select(DB::raw('select id from tutorials')));
$tutorials = array_dot($tutorials);
$students = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id` from `students`'))));
$teachers = array_dot(objectToArray(DB::select(DB::raw('SELECT `user_id` as `id` from `teachers`'))));
$subjects = array_dot(objectToArray(DB::select(DB::raw('SELECT id from subjects'))));
$minimum = $this->option('minimum');
$assessmenttitle = "This is a {title|heading|header} for Assessment.";
$assessmentdesc = "This is a sample {data|words|description} for Assessment.";
for ($i = 1; $i <= $minimum; $i++) {
$assessment = new Assessments();
$assessment->title = self::spintax($assessmenttitle);
$assessment->description = self::spintax($assessmentdesc);
$assessment->assessmenttype = "presentation";
$assessment->tutorialid = rand(1, 100);
$assessment->teacherid = array_rand($teachers);
$assessment->subjectid = rand(1, 55);
$assessment->studentid = array_rand($students);
$assessment->marks = rand(75, 100);
$assessment->created_at = self::randDate('10th January 2013', date('jS F o'));
$assessment->save();
}
}
示例5: asd
function asd($hastag = null, $since = null)
{
$key = 'WDTlXe9etTsofPrDtZskFzKwf';
$secret = 'YTQp3f2KLC02pTMylDDkfGPVEYq1u886p8FDBdpZHUTTrMNuVT';
$api_endpoint2 = $hastag == null ? $since : '?q=%40' . $hastag . '&src=savs&max_position&result_type=mixed';
$api_endpoint = 'https://api.twitter.com/1.1/search/tweets.json' . $api_endpoint2;
// request token
$basic_credentials = base64_encode($key . ':' . $secret);
$tk = curl_init('https://api.twitter.com/oauth2/token');
$proxy = "172.16.224.4:8080";
curl_setopt($tk, CURLOPT_PROXY, $proxy);
curl_setopt($tk, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $basic_credentials, 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'));
curl_setopt($tk, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
curl_setopt($tk, CURLOPT_RETURNTRANSFER, true);
$token = json_decode(curl_exec($tk));
curl_close($tk);
// use token
if (isset($token->token_type) && $token->token_type == 'bearer') {
$br = curl_init($api_endpoint);
curl_setopt($br, CURLOPT_PROXY, $proxy);
curl_setopt($br, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token->access_token));
curl_setopt($br, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($br);
curl_close($br);
// do_something_here_with($data);
return objectToArray(json_decode($data));
}
}
示例6: getlist_json_employee
function getlist_json_employee($employee, $bool)
{
$list = $this->base_model->getLeaveCreditsByEmployee($employee, $bool);
$date = $this->mod->getHireDateByEmployee(getUserId($this));
$arrayList = objectToArray($list);
$newArray = array();
foreach ($arrayList as $key => $value) {
$dayval = $value['days'];
$usercount = 0;
if ($value['date'] != '0000-00-00' && $value['date'] != '') {
$hired = strtotime($date);
$setdate = strtotime($value['date']);
if ($hired > $setdate) {
$dayval = $value['days_after'];
} else {
if ($hired < $setdate) {
$dayval = $value['days_before'];
}
}
}
if ($value['schoolyear'] === getSchoolYear($this)) {
$usercount = $value['usecount'];
}
array_push($newArray, array('id' => $value['id'], 'ltid' => $value['ltid'], 'title' => $value['title'], 'days' => $dayval, 'date' => $value['date'], 'days_before' => $value['days_before'], 'days_after' => $value['days_after'], 'usecount' => $usercount));
}
echo json_encode($newArray);
}
示例7: insertAgreement
/**
* The student inserts this initially once he/she accepts a project offer
* @param unknown $props
* @param unknown $proposal_id
* @return boolean|unknown
*/
static function insertAgreement($props)
{
if (!$props) {
drupal_set_message(t('Insert requested with empty (filtered) data set'), 'error');
return false;
}
if (!isset($props['proposal_id'])) {
drupal_set_message(t('Insert requested with no proposal set'), 'error');
return false;
}
global $user;
$txn = db_transaction();
try {
$proposal = objectToArray(Proposal::getInstance()->getProposalById($props['proposal_id']));
$project = objectToArray(Project::getProjectById($proposal['pid']));
if (!isset($props['student_id'])) {
$props['student_id'] = $user->uid;
}
if (!isset($props['supervisor_id'])) {
$props['supervisor_id'] = $proposal['supervisor_id'];
}
if (!isset($props['mentor_id'])) {
$props['mentor_id'] = $project['mentor_id'];
}
$props['project_id'] = $proposal['pid'];
if (!isset($props['description'])) {
$props['description'] = '';
}
if (!isset($props['student_signed'])) {
$props['student_signed'] = 0;
}
if (!isset($props['supervisor_signed'])) {
$props['supervisor_signed'] = 0;
}
if (!isset($props['mentor_signed'])) {
$props['mentor_signed'] = 0;
}
/*
if (! testInput($props, array('owner_id', 'org_id', 'inst_id', 'supervisor_id','pid', 'title'))){
return FALSE;
}
*/
try {
$id = db_insert(tableName(_AGREEMENT_OBJ))->fields($props)->execute();
} catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
}
if ($id) {
drupal_set_message(t('You have created your agreement: you can continue editing it later.'));
return $id;
} else {
drupal_set_message(t('We could not add your agreement. ') . (_DEBUG ? '<br/>' . getDrupalMessages() : ""), 'error');
}
return $result;
} catch (Exception $ex) {
$txn->rollback();
drupal_set_message(t('We could not add your agreement.') . (_DEBUG ? $ex->__toString() : ''), 'error');
}
return FALSE;
}
示例8: obtenerCN
/**
*
* @param array $param
* @return array
*/
function obtenerCN($param)
{
$select = array("CN");
global $respError, $conn, $SQLserverName;
$param = objectToArray($param);
$farmacia = $param["farmacia"];
$DNIFarmacia = $param["DNIFarmacia"];
if (DEBUG & DEBUG_LOG) {
$mensaje = print_r($param, TRUE);
$mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
$tabla = "catalogo";
$resultadoSelect = querySelect($conn, $tabla, $select);
if ($resultadoSelect["columnasAfectadas"] === NULL) {
$resultadoOperacion = array("codigoResultadoOperacion" => $resultadoSelect[0]["code"], "mensajeResultadoOperacion" => $resultadoSelect[0]["message"]);
return array(__FUNCTION__ . "Result" => array("resultadoOperacion" => $resultadoOperacion));
} elseif ($resultadoSelect["columnasAfectadas"] === 0) {
return $respError->noHayRegistros($tabla, __FUNCTION__);
}
$CN = array();
foreach ($resultadoSelect["resultset"] as $value) {
$CN[] = $value["CN"];
}
return array(__FUNCTION__ . "Result" => array("CN" => $CN, "resultadoOperacion" => $respError->sinErrores()));
}
示例9: Moodle_GetUserId
function Moodle_GetUserId($usert)
{
/**
* Returns the moodle id of the username $usert
* @author Germán Sánchez (GREC-ESADE), Collage
* @version 24.04.2014
*/
global $debugar;
$moodleUsers = Moodle_GetUsersList();
$moodleUsers = objectToArray($moodleUsers);
// $moodleUsers es un array con 'users, que es otro array:
// [0][1]... con [id] y [username]
//echo '<pre>'.print_r($moodleUsers['users'], TRUE).'</pre>';
$key = array_search($usert, array_column($moodleUsers['users'], 'username'));
if ($debugar) {
echo '<h1>key = ' . $key . '</h1>';
}
if ($key != NULL) {
$userid = $moodleUsers['users'][$key]['id'];
} else {
$userid = NULL;
}
if ($debugar) {
echo '<h1>userid = ' . $userid . '</h1>';
}
if ($debugar) {
echo '<pre>' . print_r($moodleUsers['users'], TRUE) . '</pre>';
}
return $userid;
}
示例10: my_init
function my_init()
{
$args = objectToArray(get_post_type_object('post'));
$args['has_archive'] = 'news';
$args['rewrite'] = array('slug' => 'news', 'with_front' => false);
register_post_type('post', $args);
}
示例11: listarClientes
function listarClientes($categoria, $buscar)
{
$array_json = lerJson("json/clientes.json");
$arrya_filtrado = objectToArray($array_json->cliente);
if (isset($buscar) && $buscar != "") {
$palavra_chave = $buscar;
$palavra_chave = explode(" ", $palavra_chave);
}
if ($categoria == '0') {
$operador = ArraySearcher::OPERATOR_NOT;
} else {
$operador = ArraySearcher::OPERATOR_EQUALS;
}
$arrya_filtrado = array_filter($arrya_filtrado, new ArraySearcher('categoria', $operador, $categoria));
foreach ($arrya_filtrado as $campo) {
if (isset($palavra_chave)) {
if (procurarpalavras($campo["tag"], $palavra_chave)) {
echo "<a href='pagina.php?id=" . $campo["nome"] . "' target='_blank'><img class='imgCliente' src='" . $campo["logo"] . "' style='padding-left:10px; padding-top:10px'></a>";
}
} else {
echo "<fieldset id='gpbInformaçõesAnuncio'>";
echo "<a href='pagina.php?id=" . $campo["nome"] . "' target='_blank'><img class='imgCliente'' src='" . $campo["logo"] . "' style='padding-left:10px; padding-top:10px'></a>";
echo "<p align='justify'>" . $campo["descricao"] . "</p>";
echo "<a id='contato' href='pagina.php?id=" . $campo["nome"] . "' target='_blank'>Contato</a>";
echo "</fieldset>";
}
}
}
示例12: readfromDB
function readfromDB($filename)
{
$file = $filename;
$fh = fopen($file, 'r');
$data = fread($fh, filesize($file));
fclose($fh);
return objectToArray(json_decode($data));
}
示例13: obtenerDatosDispensaciones
/**
*
* @param date $fechaInicio
* fecha incio de la consulta.
* @param date $fechaFin.
* @param string $Id_Receta
* @param string $farmacia
* @param string $DNI
*
* @return string XML de salida.
*/
function obtenerDatosDispensaciones($param)
{
global $respError, $conn, $SQLserverName;
$param = objectToArray($param);
$fechaInicio = $param["fechaInicio"];
$fechaFin = $param["fechaFin"];
$Id_Receta = $param["Id_Receta"];
$farmacia = $param["farmacia"];
$DNI = $param["DNI"];
//die(print_r($param));
// Comprobar formato fecha sea correcto (AAAA-MM-DD)
if (!strtotime($fechaInicio) or !strtotime($fechaFin)) {
$result = array(__FUNCTION__ . "Result" => array('resultadoOperacion' => $respError->errorFormatoFecha()));
return $result;
}
// Comprobar que fechas no sean mayores que hoy
if ($fechaInicio > date('Y-m-d') or $fechaFin > date('Y-m-d')) {
$result = array(__FUNCTION__ . "Result" => array('resultadoOperacion' => $respError->errorFechaMayorHoy()));
return $result;
}
//Comprobar que fecha inicial no el mayor que fecha final
if (strtotime($fechaInicio) > strtotime($fechaFin)) {
$result = array(__FUNCTION__ . "Result" => array('resultadoOperacion' => $respError->errorFechaInicioMayor()));
return $result;
}
//Comprobar que mes incio y fin sean el mismo
if (date('m', strtotime($fechaInicio)) != date('m', strtotime($fechaFin))) {
$result = array(__FUNCTION__ . "Result" => array('resultadoOperacion' => $respError->errorMesInicioMesFinDistintos()));
return $result;
}
//Comprobar que fecha sea superior a 31/01/2013
if (date('Y-m-d', strtotime($fechaInicio)) <= date('Y-m-d', strtotime('2013-01-31'))) {
$result = array(__FUNCTION__ . "Result" => array('resultadoOperacion' => $respError->errorMesInicioMenorFecha()));
return $result;
}
if (DEBUG & DEBUG_LOG) {
$mensaje = print_r($param, TRUE);
$mensaje .= "--Llamada hecha en el fichero: " . __FILE__ . ", en la línea: " . __LINE__;
error_log("[" . date("c") . "] \r\n {$mensaje}", 3, DIRECTORIO_LOG . __FUNCTION__ . "_" . date("YmdH") . ".log");
}
$diaInicio = date('d', strtotime($fechaInicio));
$diaFin = date('d', strtotime($fechaFin));
if (date('ym', strtotime($fechaInicio)) < "1506") {
$tabla = PREFIJO_TABLA_DISPENSACION . date('Ym', strtotime($fechaInicio));
} else {
$tabla = PREFIJO_TABLA_DISPENSACION . date('ym', strtotime($fechaInicio));
}
$select = array("Farmacia", "idtx", "Dni", "Codfarmacia", "Codcolegiado", "Numcolegiado", "Tsi", "Id_Receta", "Pvpcalculadoaport", "Pvptotal", "Euros_receta", "Envases", "Codnacional", "Pvpcomerenv", "Aportacionproducto", "Check_atep", "indicador_euro", "Check_objecion", "Check_visado", "CONVERT(nvarchar(30), FechaGrabacion, 126) as FechaGrabacion");
$where = array("day(FechaGrabacion) >=" => $diaInicio, "day(FechaGrabacion) <=" => $diaFin, "Id_Receta like" => "%{$Id_Receta}%", "Farmacia =" => $farmacia);
$resultadoSelect = querySelect($conn, $tabla, $select, $where);
if ($resultadoSelect["columnasAfectadas"] === NULL) {
$resultadoOperacion = array("codigoResultadoOperacion" => $resultadoSelect[0]["code"], "mensajeResultadoOperacion" => $resultadoSelect[0]["message"]);
return array(__FUNCTION__ . "Result" => array("columnasAfectadas" => $resultadoSelect["columnasAfectadas"], "listaDatosDispensacion" => $resultadoSelect["resultset"], "resultadoOperacion" => $resultadoOperacion));
}
return array(__FUNCTION__ . "Result" => array("columnasAfectadas" => $resultadoSelect["columnasAfectadas"], "listaDatosDispensacion" => $resultadoSelect["resultset"], "resultadoOperacion" => $respError->sinErrores()));
}
示例14: getCandidateProfile
function getCandidateProfile($username)
{
global $conn, $debugar, $versionDataBase;
// Obtenemos el id del usuario
$sql = 'SELECT * FROM ' . TABLE_USERS . ' WHERE username =\'' . $username . '\'';
$result = consulta($sql, $conn);
$obj = pg_fetch_object($result);
$userid = $obj->userid;
if ($debugar) {
echo 'getCandidateProfile: $sql; userid = ' . $userid . '.<br />' . "\n";
}
// Lista de skills
$sql = 'SELECT * FROM ' . TABLE_PROFILE_SKILLS . ' WHERE userid =' . $userid;
$result = consulta($sql, $conn);
while ($obj = pg_fetch_object($result)) {
$skills[] = $obj;
}
if ($debugar) {
echo 'getCandidateProfile: $sql; nrows = ' . pg_num_rows($result) . '.<br />' . "\n";
}
// Lista de subskills
$sql = 'SELECT * FROM ' . TABLE_PROFILE_SUBSKILLS . ' WHERE userid =' . $userid;
$result = consulta($sql, $conn);
$subskills = array();
while ($obj = pg_fetch_object($result)) {
$subskills[] = $obj;
}
if ($debugar) {
echo 'getCandidateProfile: $sql; nrows = ' . pg_num_rows($result) . '.<br />' . "\n";
}
// Department
if ($versionDataBase == 'waag') {
$sql = 'SELECT id FROM ' . TABLE_PROFILE_DEPARTMENT . ' WHERE userid =' . $userid;
$result = consulta($sql, $conn);
$obj = pg_fetch_object($result);
//$dept = int2dept($obj->id);
$dept = $obj->id;
} else {
$sql = 'SELECT dept FROM ' . TABLE_PROFILE_DEPARTMENT . ' WHERE userid =' . $userid;
$result = consulta($sql, $conn);
$obj = pg_fetch_object($result);
$dept = $obj->dept;
}
if ($debugar) {
echo 'getCandidateProfile: $sql; dept(' . $obj->id . ') = ' . $dept . '.<br />' . "\n";
}
// Availability
$sql = 'SELECT * FROM ' . TABLE_PROFILE_AVAILABILITY . ' WHERE userid =' . $userid;
$result = consulta($sql, $conn);
$obj = pg_fetch_object($result);
$avail = $obj->level;
if ($debugar) {
echo 'getCandidateProfile: $sql; availability = ' . $avail . '.<br />' . "\n";
}
return objectToArray(array('skills' => $skills, STRING_SUBSKILLS => $subskills, 'department' => $dept, 'availability' => $avail));
}
示例15: objectToArray
/**
* Convert an object to associative array
*
* @param object $object
* @return array
*/
function objectToArray($object)
{
$data = (array) $object;
foreach ($data as $key => $value) {
if (is_object($value) || is_array($value)) {
$data[$key] = objectToArray($value);
}
}
return $data;
}