本文整理汇总了PHP中Conexao::obterConexao方法的典型用法代码示例。如果您正苦于以下问题:PHP Conexao::obterConexao方法的具体用法?PHP Conexao::obterConexao怎么用?PHP Conexao::obterConexao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conexao
的用法示例。
在下文中一共展示了Conexao::obterConexao方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportarCSV
public static function exportarCSV($sql, $file)
{
$sql = $sql . " INTO OUTFILE '" . $file . "' CHARACTER SET utf16 FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n';";
$conn = Conexao::obterConexao();
return mysql_query($sql) or die(mysql_error());
}
示例2: queryExclusivaProducao
public static function queryExclusivaProducao($sql, $objeto)
{
$resultado = false;
$conn = Conexao::obterConexao();
$sql_count = str_replace(':paginacao', '', $sql);
$sql_count = self::prepare($sql_count, $objeto);
if (($from = stristr($sql_count, 'from')) !== false) {
$result_count = mysql_query('select count(1) ' . $from) or die(mysql_error());
$row = mysql_fetch_row($result_count);
if ($row) {
$colunas = stristr($sql, 'from', true);
$colunas .= ", " . $row[0] . " as pg_numero_registros ";
}
}
if (property_exists($objeto, 'pg_pagina') && $objeto->get("pg_pagina")) {
$itens_pagina = 25;
if ($objeto->get("pg_registros")) {
$itens_pagina = $objeto->get("pg_registros");
}
if ($objeto->get("pg_pagina") == 1) {
$inicio = 0;
} else {
$inicio = $itens_pagina * $objeto->get("pg_pagina") - $itens_pagina;
}
if (strpos($sql, ':paginacao') !== false) {
$sql = str_replace(':paginacao', 'limit ' . $inicio . ', ' . $itens_pagina, $sql);
}
$colunas .= ", " . $itens_pagina . " as pg_itens_pagina ";
$colunas .= ", " . $objeto->get("pg_pagina") . " as pg_pagina ";
}
$query = stristr($sql, 'from');
$sql = $colunas . $query;
$sql = self::prepare($sql, $objeto);
$stmt = mysql_query($sql) or die(mysql_error());
if ($stmt) {
while ($x = mysql_fetch_object($stmt, get_class($objeto))) {
$resultado[] = $x;
}
}
return $resultado;
}