function show_css_page($dbconn, $diary_login)
{
    $sql = "SELECT u.uid, s.page_css FROM " . TABLE_SETTINGS . " AS s, " . TABLE_USERS . " AS u WHERE u.login='******' AND s.uid=u.uid LIMIT 1";
    $result = pg_query($dbconn, $sql) or die(pg_last_error($dbconn));
    $data = pg_fetch_object($result, NULL);
    echo $data->page_css;
}
 function fetchObject()
 {
     if (($object = pg_fetch_object($this->res)) != false) {
         return $object;
     } else {
         return false;
     }
 }
 public function fetch()
 {
     if ($this->_fetchMode == jDbConnection::FETCH_CLASS) {
         if ($this->_fetchModeCtoArgs) {
             $res = pg_fetch_object($this->_idResult, null, $this->_fetchModeParam, $this->_fetchModeCtoArgs);
         } else {
             $res = pg_fetch_object($this->_idResult, null, $this->_fetchModeParam);
         }
     } else {
         if ($this->_fetchMode == jDbConnection::FETCH_INTO) {
             $res = pg_fetch_object($this->_idResult);
             $values = get_object_vars($res);
             $res = $this->_fetchModeParam;
             foreach ($values as $k => $value) {
                 $res->{$k} = $value;
             }
         } else {
             $res = pg_fetch_object($this->_idResult);
         }
     }
     if ($res && count($this->modifier)) {
         foreach ($this->modifier as $m) {
             call_user_func_array($m, array($res, $this));
         }
     }
     return $res;
 }
function show_main_page($dbconn, $diary_login)
{
    $sql = "SELECT u.uid, s.page_main, s.format_note FROM " . TABLE_SETTINGS . " AS s, " . TABLE_USERS . " AS u WHERE u.login='******' AND s.uid=u.uid LIMIT 1";
    $result = pg_query($dbconn, $sql) or die(pg_last_error($dbconn));
    $data = pg_fetch_object($result, NULL);
    echo assign_vars($data->page_main, array('{login}' => $diary_login, '{diary}' => get_last_notes($dbconn, $diary_login, $data->format_note), '{hrefguestbook}' => 'http://' . $_SERVER['SERVER_NAME'] . '/' . PAGE_GUESTBOOK, '{archive}' => get_archive($dbconn, $diary_login), '{links}' => get_links($dbconn, $diary_login)));
}
function daemon_scanTime()
{
    require "daemon_db_init.php";
    // to initialize database connection
    // 1, get timestamp
    // $time = date("j F Y h:i:s A");
    // $timestamp = "'" . date('YmdGis') . "'";
    global $timestamp;
    // 2, check if the table "dameontimestamp" in the database "vanguardhe"
    $query_exist = "SELECT relname FROM pg_class \n\tWHERE relname = 'dameontimestamp';";
    $result_exist = pg_query($query_exist) or die('Query failed: ' . pg_last_error());
    $exist = '';
    while ($row_exist = pg_fetch_object($result_exist)) {
        $exist = $row_exist->relname;
    }
    // // 3, if not existed, create it
    if ($exist != "dameontimestamp") {
        # code...
        $query_construct = "CREATE TABLE PUBLIC.dameontimestamp(\n\t\t\tscanid SERIAL PRIMARY KEY,\n\t\t\ttime           TEXT,\n\t\t\talarmcount           TEXT );";
        $result_construct = pg_query($query_construct) or die('Query failed: ' . pg_last_error());
        pg_free_result($result_construct);
    }
    // 4, insert data into the table
    $query_insert = "INSERT INTO PUBLIC.dameontimestamp (time) VALUES ({$timestamp});";
    $result_insert = pg_query($query_insert) or die('Query failed: ' . pg_last_error());
    pg_free_result($result_exist);
    pg_free_result($result_insert);
}
Example #6
0
function getSubskills($json = TRUE)
{
    /**
     * Gets the list of available subskills
     * @author  Germán Sánchez (GREC-ESADE), Collage
     * @version march 2014
     */
    global $conn;
    $sql = 'SELECT * FROM ' . TABLE_SUBSKILLS . ' ORDER BY lower(text) ASC';
    $result = consulta($sql, $conn);
    $out = array();
    while ($obj = pg_fetch_object($result)) {
        $out[] = $obj;
    }
    if (FALSE) {
        # hand-build
        $out = array();
        $out[] = array('id' => 1, 'text' => 'quick response');
        $out[] = array('id' => 2, 'text' => 'prolific');
        $out[] = array('id' => 3, 'text' => 'extensive');
    }
    if ($json) {
        $out = json_encode($out);
    }
    return $out;
}
function show_guestbook_add_page($dbconn, $diary_login)
{
    $sql = "SELECT u.uid, s.page_guestbook_add FROM " . TABLE_USERS . " AS u, " . TABLE_SETTINGS . " AS s WHERE s.uid=u.uid AND u.login='******' LIMIT 1";
    $result = pg_query($sql) or die(pg_last_error($dbconn));
    $data = pg_fetch_object($result, NULL);
    echo assign_vars($data->page_guestbook_add, array('{login}' => $diary_login, '{hrefguestbook}' => 'http://' . $_SERVER['SERVER_NAME'] . '/' . PAGE_GUESTBOOK));
}
function vencimento($dv, $cli_id, $ano_mes, $parcela, $id_servidor)
{
    $dados = @Comando::Executar("Select * from  evento_calc_mes\r\n    where cli_id = {$cli_id}\r\n \t\t\tand ano_mes = '{$ano_mes}'\r\n \t\t\tand parcela = '{$parcela}'\r\n\t\t\tand id_servidor = {$id_servidor}\r\n\t\t\tand tipo_evento ='{$dv}'\r\n \t");
    $lista_dados = "";
    while ($objx = @pg_fetch_object($dados)) {
        if ($objx->tipo_evento == 'V') {
            //&& (strcmp($dv,"V"))){
            $valor = valorM($objx->valor);
            $lista_dados .= "<tr>\r\n              <td class='codigo border centerText vertTop'>\r\n                {$objx->cod_evento}\r\n              </td>\r\n              <td class='descricao border vertTop'>\r\n                {$objx->descricao}\r\n              </td>\r\n              <td class='quantidade border rightText vertTop'>\r\n                {$objx->ref_qtd}\r\n              </td>\r\n              <td class='valor border rightText vertTop'>\r\n                {$valor}\r\n              </td>\r\n            </tr>";
            // $lista_dados.=	"
            // 	<div class='leftx' style='width:8%'>$objx->cod_evento</div>
            // 	<div class='leftx' style='width:58%'>$objx->descricao</div>
            //    	<div class='leftx' style='width:14%'>$objx->ref_qtd</div>
            //    	<div class='leftx' style='width:20%' align='right'>".valorM($objx->valor)."</div>
            // ";
        } else {
            $valor = valorM($objx->valor);
            //if($objx->tipo_evento=='D'){// && (strcmp($dv,"D")) ){
            $lista_dados .= "<tr>\r\n        <td class='codigo border centerText vertTop'>\r\n        {$objx->cod_evento}\r\n        </td>\r\n        <td class='descricao border vertTop'>\r\n        {$objx->descricao}\r\n        </td>\r\n        <td class='quantidade border rightText vertTop'>\r\n        {$objx->ref_qtd}\r\n        </td>\r\n        <td class='valor border rightText vertTop'>\r\n        {$valor}\r\n        </td>\r\n        </tr>";
            // 			$lista_dados.= "
            //   <div class='leftx' style='width:8%'>$objx->cod_evento</div>
            //   <div class='leftx' style='width:58%'>$objx->descricao &nbsp; $objx->observacao</div>
            //   <div class='leftx' style='width:14%'>$objx->ref_qtd</div>
            //   <div class='leftx' style='width:20%' align='right'>".valorM($objx->valor)."</div>
            // ";
        }
    }
    return $lista_dados;
    /*
    <div class="leftx" style="width:8%">1</div>
     <div class="leftx" style="width:58%">2fgfgn</div>
         <div class="leftx" style="width:14%">3</div>
         <div class="leftx" style="width:20%">4</div>
    */
}
Example #9
0
function fetch_object($r)
{
    if ($pgsql) {
        return pg_fetch_object($r);
    } else {
        return mysql_fetch_object($r);
    }
}
Example #10
0
/**
 * returns the results as an object.
 *
 * Used like: while($row = result($information)){ print($row->name); }
 */
function result($stuff)
{
    if (server_type == "mysql") {
        return mysql_fetch_object($stuff);
    } elseif (server_type == "postgresql") {
        return pg_fetch_object($stuff);
    }
}
 public function fetch($res)
 {
     $result = array();
     while ($data = pg_fetch_object($res)) {
         $result[] = $data;
     }
     return $result;
 }
function show_comment_add_page($dbconn, $diary_login)
{
    $nid = (int) $_GET['nid'];
    $sql = "SELECT u.uid, s.page_comment_add FROM " . TABLE_USERS . " AS u, " . TABLE_SETTINGS . " AS s WHERE s.uid=u.uid AND u.login='******' LIMIT 1";
    $result = pg_query($sql) or die(pg_last_error($dbconn));
    $data = pg_fetch_object($result, NULL);
    echo assign_vars($data->page_comment_add, array('{login}' => $diary_login, '{hrefcomment}' => 'http://' . $_SERVER['SERVER_NAME'] . '/' . PAGE_COMMENTS . '&nid=' . $nid, '{nid}' => $nid));
}
function show_error_page($dbconn, $diary_login, $message)
{
    $sql = "SELECT u.uid, s.page_error FROM " . TABLE_SETTINGS . " AS s, " . TABLE_USERS . " AS u WHERE u.login='******' AND s.uid=u.uid LIMIT 1";
    $result = pg_query($sql) or die(pg_last_error($dbconn));
    $data = pg_fetch_object($result, NULL);
    pg_free_result($result);
    echo assign_vars($data->page_error, array('{login}' => $diary_login, '{errormessage}' => $message));
}
Example #14
0
 public function next($object = false)
 {
     if ($object) {
         $this->current = pg_fetch_object($this->res);
     } else {
         $this->current = pg_fetch_assoc($this->res);
     }
     return $this->current;
 }
Example #15
0
 public function next($object = false, $result_type = MYSQL_BOTH)
 {
     if ($object) {
         $this->current = pg_fetch_object($this->res);
     } else {
         $this->current = pg_fetch_assoc($this->res);
     }
     return $this->current;
 }
Example #16
0
	function get_objects($query, $classname=NULL, $params=NULL)
	{
		// outputs normal array with std objects (unless classname is defined)
		$result = $this->do_query($query, $classname, $params);
		while ($row = pg_fetch_object($result))
			$r []= $row;
		pg_free_result($result);
		return $r;
	}
Example #17
0
 public function getId()
 {
     global $dbh;
     $q = pg_query($dbh, "SELECT id FROM id");
     print_r(pg_fetch_array($q));
     print_r(pg_fetch_array($q));
     $id = pg_fetch_object($q);
     var_dump($id);
     return $id->id;
 }
Example #18
0
function getTeam($name)
{
    global $db;
    $team = pg_fetch_object(pg_execute($db, "getTeam", array($name)));
    if ($team) {
        return new Team($team->name, $team->location, $team->summary);
    } else {
        return false;
    }
}
Example #19
0
function vencimento($dv, $cli_id, $ano_mes, $parcela)
{
    $resultado = Comando::Executar("Select * from  evento_calc_mes\n    where cli_id = {$cli_id}\n and ano_mes = '{$ano_mes}'\n and parcela = '{$parcela}'\n and id_servidor = {$id_servidor}");
    while ($obj = pg_fetch_object($dados)) {
        $nome = $obj->nome;
        $cpf = $obj->cpf;
        $pis = $obj->pis_pasep;
        $rg = $obj->rg;
        $lista_dados .= "<tr>\n          <td>" . substr($obj->ano_mes, 0, 4) . "/" . substr($obj->ano_mes, 4, 2) . "</td>\n          <td>R\$ {$obj->sal_liquido}</td>\n          <!--td>Visualizar</td-->\n        </tr>";
    }
}
 protected function _getRow($pointer)
 {
     if (isset($this->_results[$pointer])) {
         return $this->_results[$pointer];
     }
     $row = pg_fetch_object($this->_getQuery());
     if ($row) {
         $this->_results[$pointer] = $row;
     }
     return $row;
 }
Example #21
0
function load_puntos()
{
    $puntos = $_POST['comuna'];
    $sql = "Select x, y from casas_comunales where comunidad = '" . $puntos . "'";
    $rs = pg_query($sql) or die;
    while ($row = pg_fetch_object($rs)) {
        $x = $row->x;
        $y = $row->y;
        $result[] = array('x' => $x, 'y' => $y);
    }
    echo '{"success":true, "puntos":' . json_encode($result) . '}';
}
function getDeviceIdPerIp($ip)
{
    $ip = "'" . trim($ip) . "'";
    require "daemon_db_init.php";
    // to initialize database connection
    $query = "SELECT \n\t\tdaemondevice.id\n\t\tFROM \n\t\tpublic.daemondevice\n\t\tWHERE daemondevice.ip={$ip};";
    $id = 0;
    $result = pg_query($query) or die('Query failed: ' . pg_last_error());
    while ($row = pg_fetch_object($result)) {
        $id = $row->id;
    }
    return $id;
}
 public function retornaDados($tipo = NULL)
 {
     switch (strtolower($tipo)) {
         case "array":
             return pg_fetch_array($this->dataset);
         case "assoc":
             return pg_fetch_assoc($this->dataset);
         case "object":
             return pg_fetch_object($this->dataset);
         default:
             return pg_fetch_object($this->dataset);
     }
 }
Example #24
0
 function buscarDato($sql)
 {
     //echo ("<br>sql:".$sql);
     $result = pg_query($this->link, $sql);
     $devolver = null;
     if ($result) {
         // Si se encontró el registro, se obtiene un objeto en PHP con los datos de los campos:
         if (pg_num_rows($result) > 0) {
             $devolver = pg_fetch_object($result, 0);
         }
     }
     return $devolver;
 }
 public function fetch()
 {
     if ($this->_fetchMode == jDbConnection::FETCH_CLASS) {
         if ($this->_fetchModeCtoArgs) {
             $res = pg_fetch_object($this->_idResult, -1, $this->_fetchModeParam, $this->_fetchModeCtoArgs);
         } else {
             $res = pg_fetch_object($this->_idResult, -1, $this->_fetchModeParam);
         }
     } else {
         $res = pg_fetch_object($this->_idResult);
     }
     return $res;
 }
Example #26
0
function loadIndicadoresHasTema()
{
    $minhaConexao = new Conexao();
    $con = $minhaConexao->open();
    $sql = "SELECT fk_variavel,fk_tema FROM variavel_has_tema";
    $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!");
    $json = array();
    if (pg_num_rows($q) > 0) {
        while ($dados = pg_fetch_object($q)) {
            $json[] = array('variavel' => $dados->fk_variavel, 'tema' => $dados->fk_tema);
        }
    }
    return $json;
}
Example #27
0
 function buscarPersona($conexion, $id)
 {
     $sql = "SELECT * FROM tbl_personas WHERE id=" . $id . "";
     $devolver = null;
     // Ejecutar la consulta:
     $rs = pg_query($conexion, $sql);
     if ($rs) {
         // Si se encontró el registro, se obtiene un objeto en PHP con los datos de los campos:
         if (pg_num_rows($rs) > 0) {
             $devolver = pg_fetch_object($rs, 0);
         }
     }
     return $devolver;
 }
Example #28
0
function loadAreasTematicas()
{
    $minhaConexao = new Conexao();
    $con = $minhaConexao->open();
    $sql = "SELECT ri.id as id, ri.nome as nome, count(rihas.fk_municipio) as tam FROM regiao_interesse ri INNER JOIN regiao_interesse_has_municipio rihas ON ri.id = rihas.fk_regiao_interesse GROUP BY ri.id, ri.nome;";
    $q = pg_query($con, $sql) or die("Nao foi possivel executar a consulta!");
    $json = array();
    if (pg_num_rows($q) > 0) {
        while ($dados = pg_fetch_object($q)) {
            $json[] = array('n' => $dados->nome, 'id' => $dados->id, 'tam' => $dados->tam);
        }
    }
    return $json;
}
Example #29
0
	function get_objects($query, $classname=NULL, $params=NULL)
	{
		// outputs normal array with std objects (unless classname is defined)
		$result = pg_query($query);
		if($classname == NULL && $params== NULL)
			while ($row = pg_fetch_object($result))
				$r []= $row;
		else
			while ($row = pg_fetch_object($result,NULL,$classname,$params))
				$r []= $row;
		pg_free_result($result);
		
		return $r;
	}
 function query_fetch($output = OBJECT)
 {
     if ($row = @pg_fetch_object($this->result)) {
         $this->num_rows++;
         if ($output == OBJECT) {
             return $row;
         } elseif ($output == ARRAY_A) {
             return $this->convert_fieldname(get_object_vars($row));
         } elseif ($output == ARRAY_N) {
             return array_values(get_object_vars($row));
         }
     }
     return null;
 }