コード例 #1
0
    public function getModelConfigImposto($id){
        $sql = "SELECT 
		CONFIG_IMPOSTO_ID,
		NOME_TABELA,
		COALESCE(ISS,0) AS ISS,
		COALESCE(INSS,0) AS INSS,
		COALESCE(PIS,0) AS PIS,
		COALESCE(COFINS,0) AS COFINS,
		COALESCE(CSLL,0) AS CSLL,
		COALESCE(IRPJ,0) AS IRPJ,
		COALESCE(RETENCAO_FONTE,'N') AS RETENCAO_FONTE  
		FROM CONFIG_IMPOSTO  
		WHERE CONFIG_IMPOSTO.CONFIG_IMPOSTO_ID =".$id;
        $rs = parent::execute_query($sql);
        while($row = ibase_fetch_assoc($rs)){
            $this->CONFIG_IMPOSTO_ID = $row['CONFIG_IMPOSTO_ID'];
            $this->NOME_TABELA = $row['NOME_TABELA'];
            $this->ISS = $row['ISS'];
            $this->PIS = $row['PIS'];
            $this->INSS= $row['INSS'];
            $this->COFINS = $row['COFINS'];
            $this->CSll = $row['CSLL'];
            $this->IRPJ = $row['IRPJ'];
            $this->RENTENCAO_FONTE = $row['RETENCAO_FONTE'];
            $this->SYNC = $rs['SYNC'];
        }
        return  $this;
    }
コード例 #2
0
ファイル: database.php プロジェクト: ofarias/phpPegaso
 function FetchAs($result)
 {
     if (!is_resource($result)) {
         return false;
     }
     return ibase_fetch_assoc($result);
 }
コード例 #3
0
ファイル: Driver.php プロジェクト: reoring/sabel
 public function execute($sql, $bindParams = array(), $additionalParameters = array())
 {
     $connection = $this->connection;
     if (empty($bindParams)) {
         $result = ibase_query($connection, $sql);
     } else {
         $holderRegex = "/@[a-zA-Z0-9_]+@/";
         preg_match_all($holderRegex, $sql, $matches);
         $args = array($connection, preg_replace($holderRegex, "?", $sql));
         foreach ($matches[0] as $holder) {
             $args[] = $bindParams[$holder];
         }
         $result = call_user_func_array("ibase_query", $args);
     }
     if (!$result) {
         $this->executeError($sql);
     }
     $rows = array();
     if (is_resource($result)) {
         while ($row = ibase_fetch_assoc($result, IBASE_TEXT)) {
             $rows[] = array_change_key_case($row);
         }
         ibase_free_result($result);
     } else {
         $this->affectedRows = $result === true ? 0 : $result;
     }
     if ($this->autoCommit) {
         ibase_commit($connection);
     }
     return empty($rows) ? null : $rows;
 }
コード例 #4
0
 function select_sql($sql)
 {	$j=1;
    $Row=array(array());
	$this->sql_connect();
    $this->sql_query=$sql;
    $this->sql_execute();
	while($Mas = ibase_fetch_assoc($this->sql_result))
	{$i=0;
		foreach($Mas  as $key => $value) {
		$Row[0][$i] = $key;
		$Row[$j][$i] = $value;
			//echo $key.": ".$value.", ";
			$i++;
		}   
	$j++; 		
    }
    return $Row;
 } 
コード例 #5
0
 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = ibase_fetch_assoc($this->handle))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         if ('TIMESTAMP' == $this->fields[$key]) {
             $row[$key] = Date::fromString($row[$key], $this->tz);
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
コード例 #6
0
 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  [:var]
  */
 public function next($field = null)
 {
     if (!is_resource($this->handle) || false === ($row = ibase_fetch_assoc($this->handle))) {
         return null;
     }
     foreach (array_keys($row) as $key) {
         if (null === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         if ('TIMESTAMP' == $this->fields[$key]) {
             $row[$key] = new \util\Date($row[$key], $this->tz);
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
コード例 #7
0
ファイル: firebird.inc.php プロジェクト: dieface/testenv
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
    if ($show_errors) {
        error_reporting(E_ALL);
    } else {
        error_reporting(E_PARSE);
    }
    // Connect to the Firebird/Interbase Sybase database management system
    $link = ibase_pconnect("/var/www/sqlmap/dbs/firebird/testdb.fdb", "SYSDBA", "testpass");
    if (!$link) {
        die(ibase_errmsg());
    }
    // Print results in HTML
    print "<html><body>\n";
    // Print SQL query to test sqlmap '--string' command line option
    //print "<b>SQL query:</b> " . $query . "<br>\n";
    // Perform SQL injection affected query
    $result = ibase_query($link, $query);
    if (!$result) {
        if ($show_errors) {
            print "<b>SQL error:</b> " . ibase_errmsg() . "<br>\n";
        }
        exit(1);
    }
    print "<b>SQL results:</b>\n";
    print "<table border=\"1\">\n";
    while ($line = ibase_fetch_assoc($result)) {
        // This must stay here for Firebird
        if (!$show_output) {
            exit(1);
        }
        print "<tr>";
        foreach ($line as $col_value) {
            print "<td>" . $col_value . "</td>";
        }
        print "</tr>\n";
        if (!$all_results) {
            break;
        }
    }
    print "</table>\n";
    print "</body></html>";
}
コード例 #8
0
    private function VerificaCalculo($id) {
	$SQL = "
        SELECT imposto.imposto_id
        FROM  F_REL_F_LANCA_CR2_F_IMPOSTO RELIMP
        INNER JOIN imposto ON imposto.imposto_id = RELIMP.imposto_id
        WHERE RELIMP.F_LANCA_CR2_ID =
            (
                SELECT MAX(CR2.F_LANCA_CR2_ID)
                FROM  F_LANCA_CR CR
                INNER JOIN  F_LANCA_CR2 CR2 ON CR2.f_lanca_cr_id = CR.f_lanca_cr_id
                INNER JOIN  F_REL_F_LANCA_CR2_F_IMPOSTO RELIMP ON RELIMP.f_lanca_cr2_id = CR2.f_lanca_cr2_id
                INNER JOIN imposto IMP ON IMP.imposto_id = RELIMP.imposto_id
                WHERE CR.f_lanca_cr_id = $id
                AND CR2.acao_faturar = 'S'
            )";
	$rsVerificaCalcular = ibase_fetch_assoc(parent::execute_query($SQL));
	if (count($rsVerificaCalcular) > 0) {
	    return true;
	} else {
	    return false;
	}
    }
コード例 #9
0
ファイル: Ibase.php プロジェクト: saqar/tc_aowow
 function _performFetch($result)
 {
     // Select fetch mode.
     $flags = $this->fetchFlags;
     if (empty($this->attributes['BLOB_OBJ'])) {
         $flags = $flags | IBASE_TEXT;
     } else {
         $flags = $flags & ~IBASE_TEXT;
     }
     $row = @ibase_fetch_assoc($result, $flags);
     if (ibase_errmsg()) {
         return $this->_setDbError($this->_lastQuery);
     }
     if ($row === false) {
         return null;
     }
     return $row;
 }
コード例 #10
0
 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws Zend_Db_Statement_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmtResult) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = ibase_fetch_row($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOTH:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             if ($row !== false) {
                 $row = array_merge($row, array_values($row));
             }
             break;
         case Zend_Db::FETCH_OBJ:
             $row = ibase_fetch_object($this->_stmtResult, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOUND:
             $row = ibase_fetch_assoc($this->_stmtResult, IBASE_TEXT);
             if ($row !== false) {
                 $row = array_merge($row, array_values($row));
                 $row = $this->_fetchBound($row);
             }
             break;
         default:
             /**
              * @see ZendX_Db_Adapter_Firebird_Exception
              */
             require_once 'ZendX/Db/Statement/Firebird/Exception.php';
             throw new ZendX_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     return $row;
 }
コード例 #11
0
 /**
 +----------------------------------------------------------
 * 获得所有的查询数据
 +----------------------------------------------------------
 * @access private
 +----------------------------------------------------------
 * @return array
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 private function getAll()
 {
     //返回数据集
     $result = array();
     while ($row = ibase_fetch_assoc($this->queryID)) {
         $result[] = $row;
     }
     //剑雷 2007.12.30 自动解密BLOB字段
     //取BLOB字段清单
     $bloblist = array();
     $fieldCount = ibase_num_fields($this->queryID);
     for ($i = 0; $i < $fieldCount; $i++) {
         $col_info = ibase_field_info($this->queryID, $i);
         if ($col_info['type'] == 'BLOB') {
             $bloblist[] = trim($col_info['name']);
         }
     }
     //如果有BLOB字段,就进行解密处理
     if (!empty($bloblist)) {
         $i = 0;
         foreach ($result as $row) {
             foreach ($bloblist as $field) {
                 if (!empty($row[$field])) {
                     $result[$i][$field] = $this->BlobDecode($row[$field]);
                 }
             }
             $i++;
         }
     }
     return $result;
 }
コード例 #12
0
ファイル: db_firebird.php プロジェクト: mmendoza000/freekore
 /**
  *@package db_firebird
  *@method fetch_array()
  *@desc Fetch a result row as an associative array, a numeric array, or both depending on query() or query_assoc() method
  *@since v0.3.1
  * */
 public function fetch_array($rs = '')
 {
     $Resource = $rs != '' ? $rs : $this->resource;
     if ($this->query_is_assoc == true) {
         return ibase_fetch_assoc($Resource);
     } else {
         return ibase_fetch_row($Resource);
     }
 }
コード例 #13
0
ファイル: Firebird.php プロジェクト: bladerangel/aplicacao
 /**
  * Retorna o ultimo ID da tabela para campos auto-increment
  * @author Hugo Ferreira da Silva
  * @param string $campo Nome do campo da tabela de auto-increment
  * @return int Valor da ultima insercao
  */
 public function getLastId($campo)
 {
     //////////////////////////////////////////////////////////////////
     // GAMBIARRA FORTE!
     // Aqui pegamos as triggers relacionadas a tabela
     // e procuramos no corpo da trigger uma linha semelhante a
     // new.nome_campo = gen_id(nome_sequencia, 1)
     // para pegarmos o nome da sequencia e consequentemente
     // podermos recuperar o ultimo valor
     //////////////////////////////////////////////////////////////////
     $cn = $this->getConnection();
     $sql = "SELECT RDB\$TRIGGER_SOURCE AS triggers FROM RDB\$TRIGGERS\n\t\t\t\t WHERE (RDB\$SYSTEM_FLAG IS NULL\n\t\t\t\t\tOR RDB\$SYSTEM_FLAG = 0)\n\t\t\t\t   AND RDB\$RELATION_NAME='" . $this->getTablename() . "'";
     $rs = $cn->executeSQL($sql);
     while ($row = ibase_fetch_assoc($rs, IBASE_FETCH_BLOBS)) {
         // oba! achamos o lance
         $exp = '@new\\.' . $campo . '\\s+=\\s+gen_id\\((\\w+)@is';
         $res = preg_match($exp, trim($row['TRIGGERS']), $reg);
         if ($res) {
             ibase_free_result($rs);
             $sql = "SELECT GEN_ID(" . $reg[1] . ", 0) as lastid FROM RDB\$DATABASE";
             $rs = $cn->executeSQL($sql);
             $row = ibase_fetch_row($rs);
             ibase_free_result($rs);
             return $row[0];
         }
     }
     ibase_free_result($rs);
     return 0;
 }
コード例 #14
0
function gcms_fetch_assoc($nresult)
{
    return ibase_fetch_assoc($nresult);
}
コード例 #15
0
ファイル: ibase_result.php プロジェクト: sacsand/abcd
 /**
  * Result - associative array
  *
  * Returns the result set as an array
  *
  * @return	array
  */
 protected function _fetch_assoc()
 {
     return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS);
 }
コード例 #16
0
 /**
  * Devuelve $limit filas encontradas a partir de la fila $offset
  * Este metodo es similar a fetchResult.
  * @param integer $limit
  * @param integer $offset
  * @return array Las filas encontradas
  */
 public function fetchResultLimit($limit, $rowNumber = '')
 {
     $rows = array();
     $nfilas = 0;
     if ($rowNumber < 0) {
         $rowNumber = 1;
     }
     switch (self::$dbEngine) {
         case 'mysql':
             @mysql_data_seek($this->result, $rowNumber);
             while ($row = mysql_fetch_array($this->result, MYSQL_ASSOC) and $nfilas < $limit) {
                 $nfilas++;
                 $rows[] = $row;
             }
             break;
         case 'mssql':
             //NO ESTA BIEN IMPLEMENTADO
             while ($row = mssql_fetch_array($this->result, MYSQL_ASSOC)) {
                 $rows[] = $row;
             }
             break;
         case 'interbase':
             //NO ESTA BIEN IMPLEMENTADO
             while ($row = ibase_fetch_assoc($this->result)) {
                 $rows[] = $row;
             }
             break;
         case 'pgsql':
             $valores = explode(",", $limit);
             if (count($valores) == 1) {
                 $limit = "LIMIT {$valores[0]}";
             } elseif (count($valores) == 2) {
                 $limit = "LIMIT {$valores[1]} OFFSET {$valores[0]}";
             }
             $query = "{$select} WHERE {$filtro} ORDER BY {$orderBy} {$limit}";
             break;
         default:
             $this->setError("fetchResultLimit", "No se ha indicado el tipo de base de datos");
             break;
     }
     return $rows;
 }
コード例 #17
0
 /**
  * Result - associative array
  *
  * Returns the result set as an array
  *
  * @return	array
  */
 protected function _fetch_assoc()
 {
     if (($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE) {
         //Increment row count
         $this->num_rows++;
     }
     return $row;
 }
コード例 #18
0
    function GeraVersaoRelatorios() {




	//Cria as tabelas 
	$Script = '
	    SET SQL DIALECT 3;


	    DROP TABLE "webreport_admin";

	    DROP TABLE "webreport_settings";

	    DROP TABLE "webreport_sql";

	    DROP TABLE "webreport_style";

	    DROP TABLE "webreport_users";

	    DROP TABLE "webreports";

	    DROP SEQUENCE "g_webreport_admin";

	    DROP SEQUENCE "g_webreport_settings";

	    DROP SEQUENCE "g_webreport_sql";

	    DROP SEQUENCE "g_webreport_style";

	    DROP SEQUENCE "g_webreport_users";

	    DROP SEQUENCE "g_webreports";


	    CREATE GENERATOR "g_webreport_admin";

	    CREATE TABLE "webreport_admin" (
		"id"          INTEGER NOT NULL,
		"tablename"   VARCHAR(250),
		"db_type"     VARCHAR(10),
		"group_name"  VARCHAR(250)
	    );



	    ALTER TABLE "webreport_admin" ADD PRIMARY KEY ("id");


	    SET TERM ^ ;


	    /* Trigger: "t_webreport_admin" */
	    CREATE OR ALTER TRIGGER "t_webreport_admin" FOR "webreport_admin"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."id" IS NULL)
		THEN NEW."id" = GEN_ID("g_webreport_admin", 1);
	    END
	    ^


	    SET TERM ; ^


	    SET SQL DIALECT 3;



	    CREATE GENERATOR "g_webreport_settings";

	    CREATE TABLE "webreport_settings" (
		"id"       INTEGER NOT NULL,
		"version"  VARCHAR(10)
	    );




	    ALTER TABLE "webreport_settings" ADD PRIMARY KEY ("id");


	    SET TERM ^ ;

	    CREATE OR ALTER TRIGGER "t_webreport_settings" FOR "webreport_settings"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."id" IS NULL)
		THEN NEW."id" = GEN_ID("g_webreport_settings",1);
	    END
	    ^


	    SET TERM ; ^


	    SET SQL DIALECT 3;


	    CREATE GENERATOR "g_webreport_sql";

	    CREATE TABLE "webreport_sql" (
		"id"          INTEGER NOT NULL,
		"sqlname"     VARCHAR(100),
		"sqlcontent"  BLOB SUB_TYPE 1 SEGMENT SIZE 80
	    );

	    ALTER TABLE "webreport_sql" ADD PRIMARY KEY ("id");

	    SET TERM ^ ;

	    CREATE OR ALTER TRIGGER "t_webreport_sql" FOR "webreport_sql"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."id" IS NULL)
		THEN NEW."id" = GEN_ID("g_webreport_sql", 1);
	    END
	    ^


	    SET TERM ; ^


	    SET SQL DIALECT 3;


	    CREATE GENERATOR "g_webreport_style";

	    CREATE TABLE "webreport_style" (
		"report_style_id"  INTEGER NOT NULL,
		"type"             VARCHAR(6),
		"field"            INTEGER,
		"group"            INTEGER,
		"style_str"        BLOB SUB_TYPE 1 SEGMENT SIZE 80,
		"uniq"             INTEGER,
		"repname"          VARCHAR(255),
		"styletype"        VARCHAR(40)
	    );


	    ALTER TABLE "webreport_style" ADD PRIMARY KEY ("report_style_id");

	    SET TERM ^ ;

	    CREATE OR ALTER TRIGGER "t_webreport_style" FOR "webreport_style"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."report_style_id" IS NULL)
		THEN NEW."report_style_id" = GEN_ID("g_webreport_style", 1);
	    END
	    ^


	    SET TERM ; ^

	    SET SQL DIALECT 3;



	    CREATE GENERATOR "g_webreport_users";

	    CREATE TABLE "webreport_users" (
		"id"        INTEGER NOT NULL,
		"username"  VARCHAR(200),
		"password"  VARCHAR(200),
		"email"     VARCHAR(200)
	    );


	    ALTER TABLE "webreport_users" ADD PRIMARY KEY ("id");

	    SET TERM ^ ;

	    CREATE OR ALTER TRIGGER "t_webreport_users" FOR "webreport_users"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."id" IS NULL)
		THEN NEW."id" = GEN_ID("g_webreport_users", 1);
	    END
	    ^


	    SET TERM ; ^

	    SET SQL DIALECT 3;


	    CREATE GENERATOR "g_webreports";

	    CREATE TABLE "webreports" (
		"rpt_id"       INTEGER NOT NULL,
		"rpt_name"     VARCHAR(100),
		"rpt_title"    VARCHAR(500),
		"rpt_cdate"    TIMESTAMP NOT NULL,
		"rpt_mdate"    TIMESTAMP,
		"rpt_content"  BLOB SUB_TYPE 1 SEGMENT SIZE 80,
		"rpt_owner"    VARCHAR(100),
		"rpt_status"   VARCHAR(10),
		"rpt_type"     VARCHAR(10) NOT NULL
	    );


	    ALTER TABLE "webreports" ADD PRIMARY KEY ("rpt_id");

	    SET TERM ^ ;

	    CREATE OR ALTER TRIGGER "t_webreports" FOR "webreports"
	    ACTIVE BEFORE INSERT POSITION 0
	    AS
	    BEGIN
	      IF (NEW."rpt_id" IS NULL)
		THEN NEW."rpt_id" = GEN_ID("g_webreports", 1);
	    END
	    ^


	    SET TERM ; ^
	    ';



//Populando a tabela webreports webreport_admin
	$sqlQuery = "SELECT * FROM " . '"webreport_admin"';

	if ($result = parent::execute_query($sqlQuery)) {

	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){

		$Script .= 'INSERT INTO'
			. '"webreport_admin"'
			. '('
			. '"id", '
			. '"tablename", '
			. '"db_type" , '
			. '"group_name" '
			. ')'
			. 'VALUES'
			. '('
			. $linha['id'] . ', '
			. "'" . $linha['tablename'] . "'" . ','
			. "'" . $linha['db_type'] . "'" . ','
			. "'" . $linha['group_name'] . "'"
			. ");";

		//echo $Insert . "<br>";
	    }
	}

########################################################################################
//Populando a tabela webreport_settings
	$sql = "SELECT * FROM " . '"webreport_settings"';

	if ($result = parent::execute_query($sql)) {


	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){

		$Script .= 'INSERT INTO'
			. '"webreport_settings" '
			. '("id", '
			. '"version" '
			. ')'
			. 'VALUES'
			. '('
			. $linha['id'] . ', '
			. "'" . $linha['version'] . "'"
			. ");";

		//echo $Insert . "<br>";
	    }
	}

########################################################################################
//Populando a tabela webreport_sql
	$sqlQuery = "SELECT * FROM " . '"webreport_sql"';

	if ($result = parent::execute_query($sqlQuery)) {

	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){

		$Script .= 'INSERT INTO'
			. '"webreport_sql"'
			. '("id", '
			. '"sqlname", '
			. '"sqlcontent" '
			. ' ) '
			. 'VALUES'
			. '('
			. $linha['id'] . ', '
			. "'" . $linha['sqlname'] . "'" . ','
			. "'" . $linha['sqlcontent'] . "'"
			. ");";

		//echo $Insert . "<br><br>";
	    }
	}

	########################################################################################
	//Populando a tabela webreport_style

	$sql = "SELECT * FROM " . '"webreport_style"';


	if ($result = parent::execute_query($sql)) {



	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){
	
		$Script .= 'INSERT INTO'
			. '"webreport_style" '
			. '('
			. '"report_style_id", '
			. '"type", '
			. '"field", '
			. '"group", '
			. '"style_str", '
			. '"uniq", '
			. '"repname", '
			. '"styletype"'
			. ')'
			. 'VALUES'
			. '('
			. $linha['report_style_id'] . ', '
			. "'" . $linha['type'] . "'" . ','
			. $linha['field'] . ', '
			. $linha['group'] . ', '
			. "'" . $linha['style_str'] . "'" . ', '
			. $linha['uniq'] . ', '
			. "'" . $linha['repname'] . "'" . ','
			. "'" . $linha['styletype'] . "'"
			. ');';

		//echo $Insert . "<br><br>";
	    }
	}

	########################################################################################
	//Populando a tabela webreport_users
	$sql = "SELECT * FROM " . '"webreport_users"';

	if ($result = parent::execute_query($sql)) {

	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){

		$Script .= 'INSERT INTO'
			. '"webreport_users"'
			. '("id", '
			. '"username", '
			. '"password", '
			. '"email" '
			. ') '
			. 'VALUES'
			. '('
			. $linha['id'] . ', '
			. "'" . $linha['username'] . "'" . ','
			. "'" . $linha['password'] . "'" . ','
			. "'" . $linha['email'] . "'"
			. ");";


		//echo $Insert . "<br>";
	    }
	}

	########################################################################################
	//Populando a tabela webreports
	$sql = "SELECT * FROM " . '"webreports"';

	if ($result = parent::execute_query($sql)) {

	    while ($linha = ibase_fetch_assoc($result, IBASE_TEXT)){

	

		$Script .= 'INSERT INTO '
			. '"webreports"'
			. '('
			. '"rpt_id", '
			. '"rpt_name", '
			. '"rpt_title", '
			. '"rpt_cdate", '
			. '"rpt_mdate", '
			. '"rpt_content", '
			. '"rpt_owner", '
			. '"rpt_status", '
			. '"rpt_type"'
			. ') '
			. 'VALUES'
			. '('
			. $linha['rpt_id'] . ', '
			. "'" . $linha['rpt_name'] . "'" . ','
			. "'" . $linha['rpt_title'] . "'" . ','
			. "'" . $linha['rpt_cdate'] . "'" . ','
			. "'" . $linha['rpt_mdate'] . "'" . ','
			. "'" . $linha['rpt_content'] . "'" . ','
			. "'" . $linha['rpt_owner'] . "'" . ','
			. "'" . $linha['rpt_status'] . "'" . ','
			. "'" . $linha['rpt_type'] . "'"
			. ");";

		//echo $Insert . "<br><br>";
	    }
	}

	//Abre o arquivo
	$Scriptt = $this->removerAcento($Script);
	$fp = fopen("C:\\BHSistemas\\SGMO\\teste\\teste.sql", "w");

	
	// grava no arquivo.
	fwrite($fp, "$Scriptt");

	// fecha o arquivo
	fclose($fp);


    }
コード例 #19
0
ファイル: ibase.php プロジェクト: amjadtbssm/website
 function fetchInto($result, &$ar, $fetchmode, $rownum = null)
 {
     if ($rownum !== NULL) {
         return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         if (function_exists('ibase_fetch_assoc')) {
             $ar = @ibase_fetch_assoc($result);
         } else {
             $ar = get_object_vars(ibase_fetch_object($result));
         }
         if ($ar && $this->options['optimize'] == 'portability') {
             $ar = array_change_key_case($ar, CASE_LOWER);
         }
     } else {
         $ar = @ibase_fetch_row($result);
     }
     if (!$ar) {
         if ($errmsg = ibase_errmsg()) {
             return $this->ibaseRaiseError(null, $errmsg);
         } else {
             return null;
         }
     }
     return DB_OK;
 }
コード例 #20
0
ファイル: class.db.php プロジェクト: roychoo/jstree
 public function nextr($result)
 {
     return ibase_fetch_assoc($result, IBASE_TEXT);
 }
コード例 #21
0
ファイル: firebird.php プロジェクト: BACKUPLIB/mwenhanced
 /**
  * Get last inserted id after insert statement
  */
 function sql_nextid()
 {
     $query_id = $this->query_result;
     if ($query_id !== false && $this->last_query_text != '') {
         if ($this->query_result && preg_match('#^INSERT[\\t\\n ]+INTO[\\t\\n ]+([a-z0-9\\_\\-]+)#i', $this->last_query_text, $tablename)) {
             $sql = 'SELECT GEN_ID(' . $tablename[1] . '_gen, 0) AS new_id FROM RDB$DATABASE';
             if (!($temp_q_id = @ibase_query($this->db_connect_id, $sql))) {
                 return false;
             }
             $temp_result = @ibase_fetch_assoc($temp_q_id);
             @ibase_free_result($temp_q_id);
             return $temp_result ? $temp_result['NEW_ID'] : false;
         }
     }
     return false;
 }
コード例 #22
0
 function fetch_assoc()
 {
     return ibase_fetch_assoc($this->_result);
 }
コード例 #23
0
ファイル: firebird.php プロジェクト: slrondon/MikrotikCenter
 /**
  * Devuelve fila por fila el contenido de un select
  *
  * @param resource $result_query
  * @param int $opt
  * @return array
  */
 public function fetch_array($result_query = '', $opt = MYSQL_BOTH)
 {
     if (!$this->id_connection) {
         return false;
     }
     if (!$result_query) {
         $result_query = $this->last_result_query;
         if (!$result_query) {
             return false;
         }
     }
     if ($opt == db::DB_BOTH) {
         $fetch = ibase_fetch_assoc($result_query);
         $result = array();
         $i = 0;
         foreach ($fetch as $key => $value) {
             $result[$key] = $value;
             $result[$i++] = $value;
         }
         return $result;
     }
     if ($opt == db::DB_ASSOC) {
         return ibase_fetch_assoc($result_query);
     }
     if ($opt == db::DB_NUM) {
         return ibase_fetch_row($result_query);
     }
     return $result;
 }
コード例 #24
0
ファイル: Firebird.php プロジェクト: dalinhuang/popo
 /**
  * Fetches a row from the result set.
  *
  * @param int $style  OPTIONAL Fetch mode for this fetch operation.
  * @param int $cursor OPTIONAL Absolute, relative, or other.
  * @param int $offset OPTIONAL Number for absolute or relative cursors.
  * @return mixed Array, object, or scalar depending on fetch mode.
  * @throws Zend_Db_Statement_Exception
  */
 public function fetch($style = null, $cursor = null, $offset = null)
 {
     if (!$this->_stmt_result) {
         return false;
     }
     if ($style === null) {
         $style = $this->_fetchMode;
     }
     // @todo, respect the foldCase for column names
     switch ($style) {
         case Zend_Db::FETCH_NUM:
             $row = ibase_fetch_row($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_ASSOC:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOTH:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             $values = array_values($row);
             foreach ($values as $val) {
                 $row[] = $val;
             }
             break;
         case Zend_Db::FETCH_OBJ:
             $row = ibase_fetch_object($this->_stmt_result, IBASE_TEXT);
             break;
         case Zend_Db::FETCH_BOUND:
             $row = ibase_fetch_assoc($this->_stmt_result, IBASE_TEXT);
             $values = array_values($row);
             foreach ($values as $val) {
                 $row[] = $val;
             }
             if ($row !== false) {
                 return $this->_fetchBound($row);
             }
             break;
         default:
             /**
              * @see Zend_Db_Adapter_Firebird_Exception
              */
             require_once 'Zend/Db/Statement/Firebird/Exception.php';
             throw new Zend_Db_Statement_Firebird_Exception("Invalid fetch mode '{$style}' specified");
             break;
     }
     if (!$row && ($error = ibase_errcode())) {
         /**
          * @see Zend_Db_Adapter_Firebird_Exception
          */
         require_once 'Zend/Db/Statement/Firebird/Exception.php';
         throw new Zend_Db_Statement_Firebird_Exception($error);
     }
     /*
             switch ($this->_adapter->caseFolding) {
                 case Zend_Db::CASE_LOWER:
                     $r = array_change_key_case($row, CASE_LOWER);
                     break;
                 case Zend_Db::CASE_UPPER:
                     $r = array_change_key_case($row, CASE_UPPER);
                     break;
                 case default:
                     $r = $row;
                     break;
             }*/
     return $row;
 }
コード例 #25
0
ファイル: Standard.php プロジェクト: ruslankus/invoice-crm
 /**
  * This function advances the reader to the next record.
  *
  * @access public
  * @override
  * @return boolean                          whether another record was fetched
  *
  * @see http://php.net/manual/en/function.ibase-blob-get.php
  */
 public function read()
 {
     $this->record = @ibase_fetch_assoc($this->command);
     if ($this->record !== FALSE) {
         foreach ($this->blobs as $field) {
             $info = @ibase_blob_info($this->resource, $this->record[$field]);
             if (is_array($info) and !$info['isnull']) {
                 $buffer = '';
                 $handle = @ibase_blob_open($this->resource, $this->record[$field]);
                 if ($handle !== FALSE) {
                     for ($i = 0; $i < $info[1]; $i++) {
                         $size = $i == $info[1] - 1 ? $info[0] - $i * $info[2] : $info[2];
                         $value = @ibase_blob_get($handle, $size);
                         if ($value !== FALSE) {
                             $buffer .= $value;
                         }
                     }
                     @ibase_blob_close($handle);
                 }
                 $this->record[$field] = $buffer;
             } else {
                 $this->record[$field] = NULL;
             }
         }
         return TRUE;
     }
     return FALSE;
 }
コード例 #26
0
 /**
  * Fetches the row at current position and moves the internal cursor to the next position.
  * @param  bool     TRUE for associative array, FALSE for numeric
  * @return array    array on success, nonarray if no next record
  */
 public function fetch($assoc)
 {
     DibiDriverException::tryError();
     $result = $assoc ? ibase_fetch_assoc($this->resultSet, IBASE_TEXT) : ibase_fetch_row($this->resultSet, IBASE_TEXT);
     // intentionally @
     if (DibiDriverException::catchError($msg)) {
         if (ibase_errcode() == self::ERROR_EXCEPTION_THROWN) {
             preg_match('/exception (\\d+) (\\w+) (.*)/is', ibase_errmsg(), $match);
             throw new DibiProcedureException($match[3], $match[1], $match[2], dibi::$sql);
         } else {
             throw new DibiDriverException($msg, ibase_errcode(), dibi::$sql);
         }
     }
     return $result;
 }
コード例 #27
0
ファイル: ibase.php プロジェクト: ryo88c/BEAR.Saturday
 /**
  * Places a row from the result set into the given array
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * This method is not meant to be called directly.  Use
  * DB_result::fetchInto() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * @param resource $result    the query result resource
  * @param array    $arr       the referenced array to put the data in
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch (0 = first row)
  *
  * @return mixed  DB_OK on success, NULL when the end of a result set is
  *                 reached or on failure
  *
  * @see DB_result::fetchInto()
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         return $this->ibaseRaiseError(DB_ERROR_NOT_CAPABLE);
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         if (function_exists('ibase_fetch_assoc')) {
             $arr = @ibase_fetch_assoc($result);
         } else {
             $arr = get_object_vars(ibase_fetch_object($result));
         }
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @ibase_fetch_row($result);
     }
     if (!$arr) {
         return null;
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
コード例 #28
0
    $dados = array('nome' => filter_var($_POST['nome'], FILTER_SANITIZE_STRING), 'email' => filter_var($_POST['email'], FILTER_SANITIZE_EMAIL), 'senha' => empty($_POST['senha']) ? $usuario_logado->SENHA : sha1(md5($_POST['senha'])));
    $sql = "INSERT INTO usuarios(id, nome, email, senha) VALUES ((SELECT iif(MAX(id) > 0, MAX(id), 0) FROM usuarios) + 1, '{$dados['nome']}', '{$dados['email']}', '{$dados['senha']}') RETURNING id";
    if ($rotas['id']) {
        $sql = "UPDATE usuarios  SET nome = '{$dados['nome']}', email = '{$dados['email']}', senha = '{$dados['senha']}' WHERE id = '{$usuario_logado->ID}' RETURNING id";
    }
    $query = ibase_query($conexao, $sql);
    $resultado = ibase_fetch_object($query);
    if ($resultado) {
        header("Location: {$base}/index.php/{$rotas['pagina']}/formulario/{$resultado->ID}");
    }
    echo 'Houve um erro ao salvar os dados. Tente novamente.<br/>' . ibase_errmsg();
}
if ($rotas['id']) {
    $sql = "SELECT * FROM usuarios WHERE id = '{$rotas['id']}'";
    $query = ibase_query($conexao, $sql);
    $dados = ibase_fetch_assoc($query);
    $dados = array_change_key_case($dados, CASE_LOWER);
}
?>
<h2><?php 
echo $rotas['id'] ? 'Editar' : 'Criar novo';
?>
 usuario</h2>
<form action="" method="post">
    <label>Nome</label><br/>
    <input required name="nome" value="<?php 
echo $dados['nome'];
?>
" placeholder="Nome" type="text" /><br/><br/>
    <label>E-mail</label><br/>
    <input required name="email" value="<?php 
コード例 #29
0
ファイル: database_firebird.php プロジェクト: abdulghanni/gsm
function sti_firebird_get_data($connection_string, $data_source_name, $query)
{
    $info = sti_firebird_parse_connection_string($connection_string);
    $link = ibase_connect($info["host"] . ":" . $info["database"], $info["user_id"], $info["password"]) or die("ServerError:Could not connect to host '" . $info["host"] . "', database '" . $info["database"] . "'");
    $query = sti_parse_query_parameters($query);
    $result = ibase_query($link, $query) or die("ServerError:Data not found");
    $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Database>";
    $count = ibase_num_fields($result);
    for ($fid = 0; $fid < $count; $fid++) {
        $field_info = ibase_field_info($result, $fid);
        $columns[$fid] = $field_info['alias'];
    }
    while ($row = ibase_fetch_assoc($result)) {
        $xml_output .= "<{$data_source_name}>";
        foreach ($columns as $column) {
            $value = $row[$column];
            $value = str_replace("&", "&amp;", $value);
            $value = str_replace("<", "&lt;", $value);
            $value = str_replace(">", "&gt;", $value);
            $xml_output .= "<{$column}>{$value}</{$column}>";
        }
        $xml_output .= "</{$data_source_name}>";
    }
    $xml_output .= "</Database>";
    ibase_free_result($result);
    ibase_close($link);
    return $xml_output;
}
コード例 #30
0
 function GetAggregates($_arr)
 {
     $_tpl_select_command = "SELECT {text} FROM ({SelectCommand}) {where} {orderby} {groupby}";
     $_text = "";
     $_agg_result = array();
     foreach ($_arr as $_aggregate) {
         if (strpos("-|min|max|first|last|count|sum|avg|", "|" . strtolower($_aggregate["Aggregate"]) . "|") > 0) {
             $_text .= ", " . $_aggregate["Aggregate"] . "(" . $_aggregate["DataField"] . ") as " . $_aggregate["Key"];
         }
     }
     if ($_text != "") {
         $_text = substr($_text, 2);
         //Fill command and query
         //Filters
         $_where = "";
         $_filters = $this->Filters;
         for ($i = 0; $i < sizeof($_filters); $i++) {
             $_where .= " and " . $this->GetFilterExpression($_filters[$i]);
         }
         if ($_where != "") {
             $_where = "WHERE " . substr($_where, 5);
         }
         //Order
         $_orderby = "";
         $_orders = $this->Sorts;
         for ($i = 0; $i < sizeof($_orders); $i++) {
             $_orderby .= ", " . $_orders[$i]->Field . " " . $_orders[$i]->Order;
         }
         if ($_orderby != "") {
             $_orderby = "ORDER BY " . substr($_orderby, 2);
         }
         //Group
         $_groupby = "";
         $_groups = $this->Groups;
         for ($i = 0; $i < sizeof($_groups); $i++) {
             $_groupby .= ", " . $_groups[$i]->Field;
         }
         if ($_groupby != "") {
             $_groupby = "GROUP BY " . substr($_groupby, 2);
         }
         $_select_command = str_replace("{SelectCommand}", $this->SelectCommand, $_tpl_select_command);
         $_select_command = str_replace("{text}", $_text, $_select_command);
         $_select_command = str_replace("{where}", $_where, $_select_command);
         $_select_command = str_replace("{orderby}", $_orderby, $_select_command);
         $_select_command = str_replace("{groupby}", $_groupby, $_select_command);
         //echo $_select_command;
         $_result = ibase_query($this->_Link, $_select_command);
         $_agg_result = ibase_fetch_assoc($_result);
         //-----
     }
     return $_agg_result;
 }