本文整理汇总了PHP中TTransaction::get方法的典型用法代码示例。如果您正苦于以下问题:PHP TTransaction::get方法的具体用法?PHP TTransaction::get怎么用?PHP TTransaction::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTransaction
的用法示例。
在下文中一共展示了TTransaction::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setRowData
/**
* Assign values to the database columns
* @param $column Name of the database column
* @param $value Value for the database column
*/
public function setRowData($column, $value)
{
// get the current connection
$conn = TTransaction::get();
// store just scalar values (string, integer, ...)
if (is_scalar($value)) {
// if is a string
if (is_string($value) and !empty($value)) {
// fill an array indexed by the column names
$this->columnValues[$column] = $conn->quote($value);
} else {
if (is_bool($value)) {
// fill an array indexed by the column names
$this->columnValues[$column] = $value ? 'TRUE' : 'FALSE';
} else {
if ($value !== '') {
// fill an array indexed by the column names
$this->columnValues[$column] = $value;
} else {
// if the value is NULL
$this->columnValues[$column] = "NULL";
}
}
}
}
}
示例2: __construct
public function __construct()
{
parent::__construct();
try {
// connection info
$db = array();
$db['host'] = '';
$db['port'] = '';
$db['name'] = 'app/database/samples.db';
$db['user'] = '';
$db['pass'] = '';
$db['type'] = 'sqlite';
TTransaction::open(NULL, $db);
// open transaction
$conn = TTransaction::get();
// get PDO connection
// make query
$result = $conn->query('SELECT id, name from customer order by id');
// iterate results
foreach ($result as $row) {
print $row['id'] . '-';
print $row['name'] . "<br>\n";
}
TTransaction::close();
// close transaction
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例3: getSocial
public function getSocial()
{
//RECUPERA CONEXAO BANCO DE DADOS
TTransaction::open('my_bd_site');
//TABELA exposition_gallery
$criteria = new TCriteria();
$criteria->setProperty('order', 'nome ASC');
// instancia a instrução de SELECT
$sql = new TSqlSelect();
$sql->addColumn('*');
$sql->setEntity('social');
// atribui o critério passado como parâmetro
$sql->setCriteria($criteria);
// obtém transação ativa
if ($conn = TTransaction::get()) {
// registra mensagem de log
TTransaction::log($sql->getInstruction());
// executa a consulta no banco de dados
$result = $conn->Query($sql->getInstruction());
$this->results = array();
if ($result) {
// percorre os resultados da consulta, retornando um objeto
while ($row = $result->fetchObject()) {
// armazena no array $this->results;
$this->results[] = $row;
}
}
}
TTransaction::close();
return $this->results;
}
示例4: getFirst
public static function getFirst()
{
$conn = TTransaction::get();
// get PDO connection
// run query
$result = $conn->query('SELECT min(id) as min from category');
// show results
foreach ($result as $row) {
return $row['min'];
}
}
示例5: saveSale
public function saveSale($client_insert, $amount_insert)
{
try {
$conn = TTransaction::get();
// get PDO connection
// run query
$date = date('Y-m-d');
$result = $conn->query('INSERT INTO system_sales (date, client, amount) VALUES (' . $date . ', ' . $client_insert . ', ' . $amount_insert . ')');
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例6: getManuByRequisicao
public static function getManuByRequisicao(Manu $manu)
{
TTransaction::open('my_config');
if ($conn = TTransaction::get()) {
$sql = "SELECT M.*,U.nome_usuario FROM manutencoes M\r\n INNER JOIN usuarios U ON\r\n (U.id_usuario = M.responsavel_id)\r\n WHERE req_manutencao_id = ?";
$sth = $conn->prepare($sql);
$sth->execute(array($manu->getReqManutencaoId()));
$result = $sth->fetchALL(PDO::FETCH_OBJ);
return $result;
TTransaction::close();
}
}
示例7: getDataItem
public function getDataItem($id = NULL)
{
$conn = TTransaction::get();
// get PDO connection
// run query
$result = $conn->query('SELECT product, quantity, price from system_stock where id = ' . $id . ' order by id');
foreach ($result as $key) {
$this->product = $key['product'];
$this->quantity = $key['quantity'];
$this->price = $key['price'];
}
}
示例8: concluiEmp
public static function concluiEmp($id)
{
TTransaction::open('my_config');
if ($conn = TTransaction::get()) {
$sql = "UPDATE itens_emprestimos SET entregue = 1\r\n WHERE id_item = ?";
$sth = $conn->prepare($sql);
$sth->execute(array($id));
TTransaction::close();
} else {
echo 'Sem conexão com banco!';
}
}
示例9: CancelarStatus
function CancelarStatus($id)
{
TTransaction::open('my_config');
if ($conn = TTransaction::get()) {
$sql = 'UPDATE req_manutencao SET estado_id = 1
WHERE id_requisicao = ?';
$sth = $conn->prepare($sql);
$sth->execute(array($id));
TTransaction::close();
} else {
echo 'Sem conexão com banco!';
}
}
示例10: getInstruction
/**
* Returns the SELECT statement as an string according to the database driver
*/
public function getInstruction()
{
$conn = TTransaction::get();
$driver = $conn->getAttribute(PDO::ATTR_DRIVER_NAME);
if (in_array($driver, array('mssql', 'dblib', 'sqlsrv'))) {
return $this->getSqlServerInstruction();
}
if (in_array($driver, array('oci', 'oci8'))) {
return $this->getOracleInstruction();
} else {
return $this->getStandardInstruction();
}
}
示例11: ConcluiCrlChave
static function ConcluiCrlChave(CrlChave $ch)
{
TTransaction::open('my_config');
if ($conn = TTransaction::get()) {
$sql = "UPDATE laboratorios SET chave_laboratorio=0\r\n WHERE id_laboratorio = ?";
$sth = $conn->prepare($sql);
$sth->execute(array($ch->getLaboratorioId()));
$sql = "UPDATE ctrl_chaves SET dt_final_controle=?\r\n WHERE laboratorio_id = ?";
$sth = $conn->prepare($sql);
$sth->execute(array($ch->getDtFinalControle(), $ch->getLaboratorioId()));
TTransaction::close();
} else {
echo 'Sem conexão com banco!';
}
}
示例12: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
$sql = 'SELECT name, address FROM customer WHERE name like :name';
$conn = TTransaction::get();
$result = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$result->execute(array(':name' => 'And%'));
var_dump($result->fetchAll());
TTransaction::close();
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
示例13: count
function count(TCriteria $criteria)
{
$sql = new TSqlSelect();
$sql->addColumn(' count(*) ');
$sql->setEntity(constant($this->class . '::TABLENAME'));
$sql->setCriteria($criteria);
if ($conn = TTransaction::get()) {
TTransaction::log($sql->getInstruction());
$result = $conn->query($sql->getInstruction());
if ($result) {
$row = $result->fetch();
}
return $row[0];
} else {
throw new Exception('Não há transação ativa!');
}
}
示例14: InsertPermissoes
public static function InsertPermissoes($id, $arrayPost, $qtd_modulos_permissoes)
{
TTransaction::open('my_config');
if ($conn = TTransaction::get()) {
$sql = "DELETE FROM modulos_permissoes_usuarios\r\n WHERE usuario_id = ?";
$sth = $conn->prepare($sql);
$sth->execute(array($id));
for ($i = 0; $i < $qtd_modulos_permissoes; $i++) {
if ($arrayPost[$i] != 0) {
$sql = "INSERT INTO modulos_permissoes_usuarios (modulo_permissao_id,\r\n usuario_id) VALUE (?,?)";
$sth = $conn->prepare($sql);
$sth->execute(array($arrayPost[$i], $id));
}
}
TTransaction::close();
} else {
echo 'Sem conexão com banco!';
}
}
示例15: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
// open transaction
$conn = TTransaction::get();
// get PDO connection
// run query
$result = $conn->query('SELECT id, name from customer order by id');
// show results
foreach ($result as $row) {
print $row['id'] . '-';
print $row['name'] . "<br>\n";
}
TTransaction::close();
// close transaction
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}