示例#1
0
/**
 *
 * Te trae el último pedido del cliente que está en el get
 */
function getUltimoPedidoDelCliente() {
  if(getIdCliente() != 0) {
    return dbManager::getInstance()->getArrayFromQuery("select * from pedidos where IdCliente = ".getIdCliente()." order by IdPedido desc limit 1");
  } else {
    return false;
  }
}
 public function Register($_user, $_password)
 {
     if (!dbManager::ExecuteVoid("CreateUser ('{$_user->login}', '{$_password}', '{$_user->username}', '{$_user->address}')")) {
         return false;
     }
     return $this->Login($_user->login, $_password);
 }
示例#3
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
示例#4
0
 private function __construct() {
   $config = parse_ini_file('config.ini', true);
   $this->_connection = mysql_connect(
   $config['db']['server'],
   $config['db']['user'],
   $config['db']['password']
   ) or die('Verifique los datos de conexión');
   mysql_select_db($config['db']['db-name']) or die('Verifique nombre de la DB');
   $this->query("SET NAMES utf8");
   self::$_instance = $this;
 }
 public static function excluirEvento($args)
 {
     $id_evento = $args['id_evento'];
     $rs = empresaBusiness::getAllEmpresasByEvento($id_evento);
     if ($rs == false) {
         dbManager::deleteByFilter(new Evento(), ' id_evento =  ' . $id_evento);
         return true;
     } else {
         return false;
     }
 }
示例#6
0
<?php

// Use Composer to autoload DB Manager
require_once 'vendor/autoload.php';
// Require the Configuration file
require_once 'conf/config.db.inc.php';
$db = new dbManager(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_SCHEMA);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo Page</title>
</head>
<body>
<?php 
$sql = "SELECT * FROM some_table WHERE 1";
$rs = $db->query($sql);
// loop to get values
while ($row = $db->result($rs)) {
    // get row value
    $val = $row['column_name'];
}
// or ... get 1 row only
// $row = $db->result($rs);
// or ... fetch total row count
// $num = $db->result($rs, 'num_rows');
?>
</body>
</html>
<?php

include_once 'entity.php';
include_once 'dbManager.php';
$usuario = new Usuario();
$usuario->login = '******';
$usuario->senha = 'teste';
$usuario->id_pessoa_fisica = 1;
dbManager::persist($usuario);
示例#8
0
 /**
  * @brief Returns an upload job status in html
  * @param $jobData, $page, $allusers
  * @return Returns an upload job status in html
  **/
 protected function getShowJobsForEachJob($jobData, $page, $allusers)
 {
     $outBuf = '';
     $pagination = '';
     $uploadtree_pk = 0;
     $numJobs = count($jobData);
     if ($numJobs == 0) {
         return array('showJobsData' => "There are no jobs to display");
     }
     $uri = Traceback_uri() . "?mod=showjobs";
     $uriFull = $uri . Traceback_parm_keep(array("upload"));
     $uriFullMenu = $uri . Traceback_parm_keep(array("allusers"));
     /* Next/Prev menu */
     $next = $numJobs > $this->maxUploadsPerPage;
     if ($numJobs > $this->maxUploadsPerPage) {
         $pagination .= MenuEndlessPage($page, $next, $uriFullMenu);
     }
     /*****************************************************************/
     /* Now display the summary */
     /*****************************************************************/
     $uploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:white;'";
     $noUploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:black;'";
     $jobStyle = "style='font:bold 8pt verdana, arial, helvetica; background:lavender; color:black;'";
     $prevupload_pk = "";
     $firstJob = $page * $this->maxUploadsPerPage;
     $lastJob = $page * $this->maxUploadsPerPage + $this->maxUploadsPerPage;
     $jobNumber = -1;
     /** if $single_browse is 1, represent alread has an upload browse link, if single_browse is 0, no upload browse link */
     $single_browse = 0;
     foreach ($jobData as $job) {
         /* Upload  */
         if (!empty($job["upload"])) {
             $uploadName = GetArrayVal("upload_filename", $job["upload"]);
             $uploadDesc = GetArrayVal("upload_desc", $job["upload"]);
             $upload_pk = GetArrayVal("upload_pk", $job["upload"]);
             $jobId = GetArrayVal("job_pk", $job["job"]);
             /** the column pfile_fk of the record in the table(upload) is NULL when this record is inserted */
             if (!empty($upload_pk) && $prevupload_pk != $upload_pk || empty($upload_pk) && 0 == $single_browse) {
                 $prevupload_pk = $upload_pk;
                 $jobNumber++;
                 /* Only display the jobs for this page */
                 if ($jobNumber >= $lastJob) {
                     break;
                 }
                 if ($jobNumber < $firstJob) {
                     continue;
                 }
                 /* blank line separator between pfiles */
                 $outBuf .= "<tr><td colspan=8> <hr> </td></tr>";
                 $outBuf .= "<tr>";
                 $outBuf .= "<th {$uploadStyle}></th>";
                 $outBuf .= "<th colspan=6 {$uploadStyle}>";
                 if (!empty($job['uploadtree'])) {
                     $uploadtree_pk = $job['uploadtree']['uploadtree_pk'];
                     $outBuf .= "<a title='Click to browse' href='" . Traceback_uri() . "?mod=browse&upload=" . $job['job']['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>";
                 } else {
                     $outBuf .= "<a {$noUploadStyle}>";
                 }
                 /* get $userName if all jobs are shown */
                 $userName = "";
                 if ($allusers > 0) {
                     $statementName = __METHOD__ . "UploadRec";
                     $uploadRec = $this->dbManager->getSingleRow("select user_fk from upload where upload_pk=\$1", array($job['job']['job_upload_fk']), $statementName);
                     if (!empty($uploadRec['user_fk'])) {
                         $userName = $this->userDao->getUserName($uploadRec['user_fk']);
                     } else {
                         $userName = $this->userDao->getUserName($job['job']['job_user_fk']);
                     }
                     $userName = "******" . htmlentities($userName, ENT_QUOTES) . ")";
                 }
                 $outBuf .= htmlentities($uploadName, ENT_QUOTES) . $userName;
                 if (!empty($uploadDesc)) {
                     $outBuf .= " (" . $uploadDesc . ")";
                 }
                 $outBuf .= "</a>";
                 $outBuf .= "</th>";
                 $outBuf .= "<th {$uploadStyle}><a>" . $this->showJobsDao->getEstimatedTime($jobId) . "</a></th>";
                 $outBuf .= "</tr>";
                 $single_browse = 1;
             } else {
                 if ($jobNumber < $firstJob) {
                     continue;
                 }
             }
         } else {
             /* Show Jobs that are not attached to an upload */
             $jobNumber++;
             /* Only display the jobs for this page */
             if ($jobNumber >= $lastJob) {
                 break;
             }
             if ($jobNumber < $firstJob) {
                 continue;
             }
             /* blank line separator between pfiles */
             $outBuf .= "<tr><td colspan=8> <hr> </td></tr>";
             $outBuf .= "<tr>";
             $outBuf .= "<th {$noUploadStyle}></th>";
             $outBuf .= "<th colspan=6 {$noUploadStyle}>";
             $outBuf .= htmlentities($job["job"]["job_name"], ENT_QUOTES);
             $outBuf .= "</th>";
             $outBuf .= "<th {$noUploadStyle}></th>";
             $outBuf .= "</tr>";
         }
         /* Job data */
         $outBuf .= "<tr>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Job/Dependency");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Status");
         $outBuf .= "</th>";
         $outBuf .= "<th colspan=3 {$jobStyle}>";
         $outBuf .= htmlentities($job["job"]["job_name"], ENT_QUOTES);
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Average items/sec");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("ETA");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= "</th></tr>";
         /* Job queue */
         foreach ($job['jobqueue'] as $jq_pk => $jobqueueRec) {
             $varJobQueueRow = array('jqId' => $jq_pk, 'jobId' => $jobqueueRec['jq_job_fk'], 'class' => $this->getClass($jobqueueRec), 'uriFull' => $uriFull, 'depends' => $jobqueueRec['jdep_jq_depends_fk'] ? $jobqueueRec['depends'] : array(), 'status' => $jobqueueRec['jq_endtext'], 'agentName' => $jobqueueRec['jq_type'], 'itemsProcessed' => $jobqueueRec['jq_itemsprocessed'], 'startTime' => substr($jobqueueRec['jq_starttime'], 0, 16), 'endTime' => empty($jobqueueRec["jq_endtime"]) ? '' : substr($jobqueueRec['jq_endtime'], 0, 16), 'endText' => $jobqueueRec['jq_endtext'], 'page' => $page, 'allusers' => $allusers);
             if (!empty($jobqueueRec["jq_endtime"])) {
                 $numSecs = strtotime($jobqueueRec['jq_endtime']) - strtotime($jobqueueRec['jq_starttime']);
             } else {
                 $numSecs = time() - strtotime($jobqueueRec['jq_starttime']);
             }
             $itemsPerSec = null;
             if ($jobqueueRec['jq_starttime']) {
                 $itemsPerSec = $this->showJobsDao->getNumItemsPerSec($jobqueueRec['jq_itemsprocessed'], $numSecs);
                 $varJobQueueRow['itemsPerSec'] = $itemsPerSec;
             }
             if (empty($jobqueueRec['jq_endtime'])) {
                 $varJobQueueRow['eta'] = $this->showJobsDao->getEstimatedTime($jobId, $jobqueueRec['jq_type'], $itemsPerSec, $job['job']['job_upload_fk']);
             }
             $varJobQueueRow['canDoActions'] = $_SESSION[Auth::USER_LEVEL] == PLUGIN_DB_ADMIN || Auth::getUserId() == $job['job']['job_user_fk'];
             $varJobQueueRow['isInProgress'] = $jobqueueRec['jq_end_bits'] == 0;
             $varJobQueueRow['isReady'] = $jobqueueRec['jq_end_bits'] == 1;
             switch ($jobqueueRec['jq_type']) {
                 case 'readmeoss':
                     $varJobQueueRow['download'] = "ReadMeOss";
                     break;
                 case 'spdx2':
                     $varJobQueueRow['download'] = "SPDX2 report";
                     break;
                 case 'spdx2tv':
                     $varJobQueueRow['download'] = "SPDX2 tag/value report";
                     break;
                 case 'dep5':
                     $varJobQueueRow['download'] = "DEP5 copyright file";
                     break;
                 default:
                     $varJobQueueRow['download'] = "";
             }
             $outBuf .= $this->renderString('ui-showjobs-jobqueue-row.html.twig', $varJobQueueRow);
         }
     }
     if ($numJobs > $this->maxUploadsPerPage) {
         $pagination = "<p>" . MenuEndlessPage($page, $next, $uriFullMenu);
     }
     return array('showJobsData' => $outBuf, 'pagination' => $pagination);
 }
示例#9
0
<?php

///
/// Main entry point of api.
///
if (!defined("ENTRY_POINT")) {
    define("ENTRY_POINT", true);
}
$_PROJECT_DIR = realpath(dirname(__FILE__));
require_once $_PROJECT_DIR . "/Classes/dbManager.php";
require_once $_PROJECT_DIR . "/Classes/userManager.php";
session_start();
$dbMamager = dbManager::getInstance();
$usrMngr = new userManager();
// ƒл¤ скорости упростим схему до CASE блока...
// ќбработаем запросы, выделим action и параметры по необходимости.
switch ($_REQUEST["action"]) {
    case "pingUser":
        echo json_encode($usrMngr->user);
        break;
    case "login":
        $usrMngr->Login(mysql_real_escape_string($_REQUEST["login"]), mysql_real_escape_string($_REQUEST["password"]));
        echo json_encode($usrMngr->user);
        break;
    case "logout":
        if ($usrMngr->LogOut()) {
            echo "Done.";
        }
        break;
    case "avatarUpload":
        $usrMngr->GetAvatar();
示例#10
0
insert into pedidos(
	IdCliente,
	IdInmuebleTipo,
	IdPedidoTipo,
	IdMoneda,
	RangoDesde,
	RangoHasta,
	IdPais,
	IdProvincia,
	IdPartido,
	IdEstado,
	Nombre
) values (
".$_GET['idcliente'].",
".$_GET['inmueblestipos'].",
".$_GET['pedidostipos'].",
".$_GET['monedas'].",
".$_GET['range-from'].",
".$_GET['range-to'].",
".$_GET['paises'].",
".$_GET['provincias'].",
".$_GET['partidos'].",
1,
'hola'
);";
$success = dbManager::getInstance()->query($insertPedidosSql);
if($success != false) {
  echo json_encode(array("success"=>true, "id" => mysql_insert_id()));
} else {
  echo json_encode(array("success"=>false));
}
示例#11
0
<?php
require_once('../component/functions.php');
require_once('../component/db.php');

$idPartido = getGetParameter('idProvincia');
if(!$idPartido) {
  $return = array('success' => false);
  echo json_encode($return);
  die();
}

$db = dbManager::getInstance();
$partidos_query= $db->query("select IdPartido, Partido from partidos where idProvincia= ".$idPartido ." order by Partido");

$partidos = array();
while($partido = mysql_fetch_array($partidos_query)) {
  $partidos[] = array('partido'=>$partido['Partido'],'idPartido'=>$partido['IdPartido']);
}
$return = array('partidos' => $partidos, 'success' => true);
echo json_encode($return);
示例#12
0
 /**
  * Compile a condition into SQL
  *
  * @param SugarQuery_Builder_Condition $condition
  * @param string $sql Current SQL string
  * @param string $operator Preceding logical operator - AND/OR
  *
  * @return string
  */
 public function compileCondition(SugarQuery_Builder_Condition $condition)
 {
     $sql = '';
     $field = $this->compileField($condition->field);
     if (empty($field)) {
         return false;
     }
     if ($condition->isNull) {
         $sql .= "{$field} IS NULL";
     } elseif ($condition->notNull) {
         $sql .= "{$field} IS NOT NULL";
     } else {
         switch ($condition->operator) {
             case 'IN':
                 $valArray = array();
                 if ($condition->values instanceof SugarQuery) {
                     $sql .= "{$field} IN (" . $condition->values->compileSql($this->sugar_query) . ")";
                 } else {
                     foreach ($condition->values as $val) {
                         $valArray[] = $this->prepareValue($val, $condition);
                     }
                     $sql .= "{$field} IN (" . implode(',', $valArray) . ")";
                 }
                 break;
             case 'NOT IN':
                 $valArray = array();
                 $sql .= "({$field} IS NULL OR {$field} NOT IN ";
                 if ($condition->values instanceof SugarQuery) {
                     $sql .= '(' . $condition->values->compileSql($this->sugar_query) . ')';
                 } else {
                     foreach ($condition->values as $val) {
                         $valArray[] = $this->prepareValue($val, $condition);
                     }
                     $sql .= '(' . implode(',', $valArray) . ')';
                 }
                 $sql .= ')';
                 break;
             case 'BETWEEN':
                 $value['min'] = $this->prepareValue($condition->values['min'], $condition);
                 $value['max'] = $this->prepareValue($condition->values['max'], $condition);
                 $sql .= "{$field} BETWEEN {$value['min']} AND {$value['max']}";
                 break;
             case 'STARTS':
             case 'CONTAINS':
             case 'DOES NOT CONTAIN':
             case 'ENDS':
                 //Handling for not contains
                 $comparitor = 'LIKE';
                 $chainWith = 'OR';
                 if ($condition->operator === 'DOES NOT CONTAIN') {
                     $comparitor = 'NOT LIKE';
                     $chainWith = 'AND';
                 }
                 if ($this->db->supports('case_insensitive')) {
                     $field = "UPPER({$field})";
                 }
                 if (is_array($condition->values)) {
                     $conditions = array();
                     foreach ($condition->values as $value) {
                         if ($this->db->supports('case_insensitive')) {
                             $value = strtoupper($value);
                         }
                         $val = $this->prepareValue($value, $condition);
                         $conditions[] = "{$field} {$comparitor} {$val}";
                     }
                     $sql .= '(' . implode(' ' . $chainWith . ' ', $conditions);
                     if ($condition->operator === 'DOES NOT CONTAIN') {
                         $sql .= " OR {$field} IS NULL";
                     }
                     $sql .= ') ';
                 } else {
                     $value = $this->db->supports('case_insensitive') ? strtoupper($condition->values) : $condition->values;
                     $value = $this->prepareValue($value, $condition);
                     $sql .= "{$field} {$comparitor} {$value}";
                 }
                 break;
             case 'EQUALFIELD':
                 $sql .= "{$field} = " . $this->compileField(new SugarQuery_Builder_Field_Condition($condition->values, $this->sugar_query));
                 break;
             case 'NOTEQUALFIELD':
                 $sql .= "{$field} != " . $this->compileField(new SugarQuery_Builder_Field_Condition($condition->values, $this->sugar_query));
                 break;
             case '=':
             case '!=':
             case '>':
             case '<':
             case '>=':
             case '<=':
             default:
                 if ($condition->values instanceof SugarQuery) {
                     $sql .= "{$field} {$condition->operator} (" . $condition->values->compileSql($this->sugar_query) . ")";
                 } else {
                     $value = $this->prepareValue($condition->values, $condition);
                     $sql .= "{$field} {$condition->operator} {$value}";
                 }
                 break;
         }
     }
     return $sql;
 }
<?php

include_once 'dbManager.php';
$sql = "SELECT * FROM information_schema.TABLES where TABLE_SCHEMA = 'retrospectiva'";
$tabelas = dbManager::getArrayObj($sql);
$texto = "<?   include_once 'entity_class.php'; \n";
foreach ($tabelas as $key => $value) {
    $ClassName = $value->TABLE_NAME;
    $ClassName = str_replace("_", " ", $ClassName);
    $ClassName = ucwords($ClassName);
    $ClassName = str_replace(" ", "", $ClassName);
    $texto .= " \nclass " . $ClassName . "  extends Entity {";
    //colunas = atributos
    $sql = "select * from information_schema.COLUMNS where TABLE_NAME = '{$value->TABLE_NAME}'";
    $colunas = dbManager::getArrayObj($sql);
    $primary = "";
    foreach ($colunas as $index => $valor) {
        $texto .= "\n  public \$" . $valor->COLUMN_NAME . " = null;";
        if ($valor->COLUMN_KEY == 'PRI') {
            $primary = $valor->COLUMN_NAME;
        }
    }
    $texto .= "\n  public static function getTableName(){ \n     return  '" . $value->TABLE_NAME . "'; \n   }";
    $texto .= "\n  public static function getPrimaryKey(){\n     return   '" . $primary . "'; \n   }";
    $texto .= "\n" . '  public static function getColumns(){' . "\n" . '   return array_keys(get_class_vars(get_class($this))); ' . "\n" . '   }';
    $texto .= " \n}; ";
}
$texto .= '?>';
$fp = fopen("entity.php", "wb");
fwrite($fp, $texto);
fclose($fp);