本文整理汇总了PHP中db::sql方法的典型用法代码示例。如果您正苦于以下问题:PHP db::sql方法的具体用法?PHP db::sql怎么用?PHP db::sql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db
的用法示例。
在下文中一共展示了db::sql方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql
public function sql()
{
$escape = !empty($this->query['escape']);
$query = $this->__build_a_query();
$this->query = array();
return db::sql(self::Q_GET_BY_ATTR, $query, $escape);
}
示例2: rows
protected static function rows($sql)
{
$return = array();
if (null != self::row($sql)) {
$rows = self::execute($sql);
while ($row = $rows->fetch_assoc()) {
$return[] = $row;
}
}
if (self::instance()->db_obj->error) {
throw new MySQLiException("sql_error", self::instance()->db_obj);
}
if (defined('DEBUG') && DEBUG) {
self::$sql = $sql;
}
return $return;
}
示例3: db
</select>
<input type='submit' value='OK' disabled='disabled' name='tombol' class="btn btn-success" >
</form>
</td>
</tr>
<tr style='background-color: gray; color: #808080;'>
<td width='20'>No</td><td width='150'>Tanggal</td><td>Uraian</td><td>Masuk</td><td>Keluar</td><td>Saldo</td>
</tr>
<?php
$hel = new db();
$bts = 50;
$jumlah = $hel->baris("SELECT * FROM tbl_kas");
$jhal = ceil($jumlah / $bts);
$hal = $jhal - 1;
$mulai = $hal * $bts;
$kas->sql("SELECT * FROM tbl_kas LIMIT {$mulai}, {$bts}");
$no = 1;
while ($kas->hasil()) {
echo "<tr style='background-color: #E1E1E1;'>";
echo "<td>{$no}</td>";
echo "<td>" . $kas->hasil['tgl'] . "</td>";
echo "<td>" . $kas->hasil['ket'] . "</td>";
echo "<td align='right'><script type='text/javascript'>document.write(uang(" . $kas->hasil['masuk'] . "))</script></td>";
echo "<td align='right'><script type='text/javascript'>document.write(uang(" . $kas->hasil['keluar'] . "))</script></td>";
echo "<td align='right'><script type='text/javascript'>document.write(uang(" . $kas->hasil['saldo'] . "))</script></td>";
//echo $kas->hasil['saldo'];
$no++;
}
?>
<tr style='background-color: gray; color: black;'>
<td colspan='3' align='center'>Total</td>
示例4: load
public function load($filters = false, $sort = false, $slice = false)
{
$matchs = array();
$condition = "";
$filter = db::digestWhere($filters);
$condition = $filter['sql'];
$matchs = array_merge($matchs, $filter['args']);
$order = db::digestOrder($sort);
$slice = db::digestLimit($slice);
$limit = $slice['sql'];
$matchs = array_merge($matchs, $slice['args']);
//print_r("SELECT * FROM " . $this->table . $condition . $order . $limit);
$sql = "SELECT * FROM " . $this->table . $condition . $order . $limit;
//print_r($sql);
//print_r($matchs);
$matchs = db::sql($sql, $matchs);
$ret = array();
foreach ($matchs as $key => $line) {
$newItem = clone $this->model;
$newItem->update($line);
if (method_exists($this, 'processLoad')) {
$newItem = call_user_method('processLoad', $this, $newItem, $line);
}
$ret[] = $newItem;
//$pegar[$key] = (object) $pegar[$key];
}
$this->models = $ret;
return $ret;
}
示例5: db
?>
</table><!--Tabel anak-->
</div>
<div class="tab-pane" id="tab4">
<!--jatuh tempo-->
<table class="table table-striped table-hover" width='100%' style='font-size: 12px; border: 1px inset;' cellspacing='1' cellpadding='2'>
<thead>
<tr align='center' style="font-weight: bold;">
<td>No</td><td>Kode Buku</td><td>Judul Buku</td><td>Peminjam</td><td width="100px">Tanggal</td>
</tr>
</thead>
<?php
$jatuh = new db();
$saiki = sekarang();
$jatuh->sql("SELECT * FROM tbl_telat");
$jum = $jatuh->getJml();
if ($jum != '0') {
$noer = 1;
while ($jatuh->hasil()) {
echo "<tr id='pop' title='Kode Buku " . $jatuh->hasil['buku'] . "'>";
echo "<td>{$noer}</td>";
echo "<td>" . $jatuh->hasil['buku'] . "</td>";
echo "<td>" . $jatuh->hasil['judul'] . "</td>";
echo "<td><a href='peminjaman.php?pencarian=" . $jatuh->hasil['induk'] . "'>" . $jatuh->hasil['siswa'] . "</a></td>";
echo "<td>" . date('d M Y', strtotime($jatuh->hasil['tanggal'])) . "</td>";
echo "</tr>";
$noer++;
}
} else {
echo "<tr id='pop' align='center'><td colspan='5' id='res'><a class='btn' href='#' id='tempo'>Tidak Ada</a></td></tr>";
示例6: test_fragments
private static function test_fragments()
{
$tests = array('value - string' => array(db::val("test'test"), "'test\\'test'"), 'value - integer' => array(db::val(10), "10"), 'value - array' => array(db::val(array("test'test", 10)), "('test\\'test',10)"), 'value - float' => array(db::val(10.5), "10.5"), 'value - boolean' => array(db::val(false), "FALSE"), 'value - null' => array(db::val(null), "NULL"), 'template - simple' => array(db::sql("test template"), "test template"), 'template - complex' => array(db::sql("test `q'sdf``a'zer``` testtest 'q`sdf''a`zer'''"), "test `q'sdf``a'zer``` testtest 'q`sdf\\'a`zer\\''"), 'template - complex with replacements' => array(db::sql("? test ? `q'?sd!f``a'zer``` test ! test ? 'q`sdf''a`zer''' !", 'a', 'b', 'c', 'd', array('e', 'f')), "'a' test 'b' `q'?sd!f``a'zer``` test `c` test 'd' 'q`sdf\\'a`zer\\'' `e`.`f`"), 'template - nested' => array(db::sql("? test ? ?", db::sql('toast'), db::sql('toast'), 10), "toast test toast 10"), 'boolean - simple' => array(db::bool("'test' = ?", "qsdf")->or("'test' IN ?", array('azer', 'qsdf')), "('test' = 'qsdf') OR ('test' IN ('azer','qsdf'))"), 'boolean - nested' => array(db::bool(db::bool("1=1")->or("2=2"))->and("3=3"), "((1=1) OR (2=2)) AND (3=3)"), 'boolean - not' => array(db::bool("1=1")->not(), "NOT ((1=1))"), 'boolean - not not' => array(db::bool("1=1")->not()->not(), "(1=1)"), 'table' => array($t = db::table('glusers', 'myalias'), "`glusers` AS `myalias`"), 'template - columns' => array(db::sql("{$t->id} < {$t->password} qsdf"), "`myalias`.`id` < `myalias`.`password` qsdf"));
$join = db::join(db::table('glusers', 't1'))->left(db::table('glprofiles', 't2'))->on('?=?', 'test1', 'test2')->or('2=2')->and('3=3')->right(db::table('glposts', 't3'))->on('1=1');
$tests['join simple'] = array($join, "`glusers` AS `t1` LEFT OUTER JOIN `glprofiles` AS `t2` ON ('test1'='test2') OR (2=2) AND (3=3) RIGHT OUTER JOIN `glposts` AS `t3` ON (1=1)");
$join2 = db::join(db::table('glusers', 't3'))->left($join)->on('5=5');
$tests['join nested'] = array($join2, "`glusers` AS `t3` LEFT OUTER JOIN (`glusers` AS `t1` LEFT OUTER JOIN `glprofiles` AS `t2` ON ('test1'='test2') OR (2=2) AND (3=3) RIGHT OUTER JOIN `glposts` AS `t3` ON (1=1)) ON (5=5)");
$alias = db::table('glusers', 'myalias');
$join3 = db::join(db::table('glprofiles', 't3'))->left($alias)->on('1=1');
$tests['join alias'] = array($join3, "`glprofiles` AS `t3` LEFT OUTER JOIN `glusers` AS `myalias` ON (1=1)");
$orderby = new \Glue\DB\Fragment_Builder_Orderby();
$orderby->orderby($t->login, array($t->password, \Glue\DB\DB::DESC))->orderby(array($t->email, \Glue\DB\DB::ASC));
$tests['orderby'] = array($orderby, "`myalias`.`login`, `myalias`.`password` DESC, `myalias`.`email` ASC");
$groupby = new \Glue\DB\Fragment_Builder_Groupby();
$groupby->groupby($t->login, DB::sql("({$t->password} || 'qsdf')"))->groupby($t->email);
$tests['groupby'] = array($groupby, "`myalias`.`login`, (`myalias`.`password` || 'qsdf'), `myalias`.`email`");
$select = new \Glue\DB\Fragment_Builder_SelectList();
$select->columns($t->login, DB::sql($t->password))->columns(array($t->email, 'myemail'))->columns($t->login);
$tests['select'] = array($select, "`myalias`.`login` AS ```myalias``.``login```, `myalias`.`password`, `myalias`.`email` AS `myemail`");
$select1 = db::select(array('users', 'test'))->where("1=1")->andwhere("2=2")->orwhere("3=3")->distinct();
$tests['query select basic'] = array($select1, "SELECT DISTINCT 1 FROM `users` AS `test` WHERE (1=1) AND (2=2) OR (3=3)");
$select2 = db::select(array('users', 'myusers'), $u)->where("{$u->login} = 'mylogin'");
$tests['query select alias'] = array($select2, "SELECT 1 FROM `users` AS `myusers` WHERE (`myusers`.`login` = 'mylogin')");
$select3 = db::select(array('users', null), $a)->left(array('users', 'myusers'), $b)->on("{$a->login} = {$b->login}");
$tests['query select no alias'] = array($select3, "SELECT 1 FROM `users` LEFT OUTER JOIN `users` AS `myusers` ON (`users`.`login` = `myusers`.`login`)");
$select4 = db::select(array('users', 'myusers'), $a)->orderby($a->login)->limit(30)->offset(20);
$tests['query select limit offset'] = array($select4, "SELECT 1 FROM `users` AS `myusers` ORDER BY `myusers`.`login` LIMIT 30 OFFSET 20");
$select5 = db::select(array('users', 'myusers'), $a)->groupby($a->login, $a->password)->having("count(*) > 1")->orderby($a->login, $a->password)->columns($a->login, $a->password);
$tests['query select group by having'] = array($select5, "SELECT `myusers`.`login` AS ```myusers``.``login```, `myusers`.`password` AS ```myusers``.``password``` FROM `users` AS `myusers` GROUP BY `myusers`.`login`, `myusers`.`password` HAVING (count(*) > 1) ORDER BY `myusers`.`login`, `myusers`.`password`");
$select5 = db::select(array('users', 'myusers'), $a)->groupby($a->login, $a->password)->having("count(*) > 1")->orderby($a->login, $a->password)->columns($a->login, $a->password);
$tests['query select group by having'] = array($select5, "SELECT `myusers`.`login` AS ```myusers``.``login```, `myusers`.`password` AS ```myusers``.``password``` FROM `users` AS `myusers` GROUP BY `myusers`.`login`, `myusers`.`password` HAVING (count(*) > 1) ORDER BY `myusers`.`login`, `myusers`.`password`");
$select6 = db::select(array('users', 'a'), $a)->left(array('users', 'b'), $b)->on("1=1")->andon("2=2")->right(array('users', 'c'), $c)->on("3=3")->oron("4=4");
$tests['query select andon oron'] = array($select6, "SELECT 1 FROM `users` AS `a` LEFT OUTER JOIN `users` AS `b` ON (1=1) AND (2=2) RIGHT OUTER JOIN `users` AS `c` ON (3=3) OR (4=4)");
$delete1 = db::delete('users', $a)->where("{$a->login} = 'test'")->orderby($a->login)->limit(30)->offset(20);
$tests['query delete'] = array($delete1, "DELETE FROM `users` WHERE (`users`.`login` = 'test') ORDER BY `users`.`login` LIMIT 30 OFFSET 20");
$update1 = db::update('users', $a)->set('login', 'test')->set('password', \Glue\DB\DB::sql(':pass'))->where("{$a->login} = 'test'")->orderby($a->login)->limit(30)->offset(20);
$tests['query update'] = array($update1, "UPDATE `users` SET `login` = 'test', `password` = :pass WHERE (`users`.`login` = 'test') ORDER BY `users`.`login` LIMIT 30 OFFSET 20");
$update2 = db::update('users', $a)->set(array('login' => 'test', 'password' => \Glue\DB\DB::sql(':pass')))->where("{$a->login} = 'test'")->orderby($a->login)->limit(30)->offset(20);
$tests['query update array'] = array($update2, "UPDATE `users` SET `login` = 'test', `password` = :pass WHERE (`users`.`login` = 'test') ORDER BY `users`.`login` LIMIT 30 OFFSET 20");
$insert1 = db::insert('users')->columns('login', 'password')->columns(array('id'))->values("test'1", "test'2", \Glue\DB\DB::sql(':test'))->values(array("a", "b", "c"), array("d", "e", "f"))->values(array(array("a", "b", "c"), array("d", "e", "f")));
$tests['query insert'] = array($insert1, "INSERT INTO `users` (`login`, `password`, `id`) VALUES ('test\\'1','test\\'2',:test),('a','b','c'),('d','e','f'),('a','b','c'),('d','e','f')");
// Checks :
foreach ($tests as $type => $data) {
list($f, $target) = $data;
echo "Testing fragments : " . $type . " ...";
if (db::cn()->compile($f) === $target) {
echo "ok \n";
} else {
echo '<b style="color:blue">error ! ' . db::cn()->compile($f) . " doesn't match target " . $target . "\n</b>";
return false;
}
}
return true;
}
示例7: db
<?php
session_start();
/*
File: log.php
Fungsi: File untuk melihat aktivitas aplikasi.
Auth: ShowCheap
*/
require 'sistem/config.php';
cek_user();
sambung();
get_kepala();
$log = new db();
if (isset($_GET['reset']) && isset($_SESSION['level'])) {
$log->sql("TRUNCATE log");
catat($_SESSION['nama'], "Menghapus Log/Aktivitas");
}
$lihat = mysql_real_escape_string($_GET['item']);
$tambah = $lihat + 50;
if ($lihat == '') {
$lihat = '100';
}
$log->sql("SELECT * FROM log ORDER BY id ASC LIMIT 0, {$lihat}");
?>
<script type='text/javascript'>
function reset(){
var tanya = confirm('Yakin Reset Semua Aktivitas??');
if(tanya){
window.location='?reset';
}
}
示例8: db
</table><!--Tabel anak2-->
</td>
</tr>
<tr>
<td colspan='2'><!--Tabel anak2.1-->
<table width='100%' style='font-size: 12px;' cellspacing='1' cellpadding='2'>
<tr>
<td colspan='4'><b>Daftar Buku Yang Telah Jatuh Tempo</b></td>
</tr>
<tr style='background-color: orange;' align='center'>
<td>No</td><td>Kode Buku</td><td>Judul Buku</td><td>Peminjam</td><td>Tanggal</td>
</tr>
<?php
$jatuh = new db();
$saiki = sekarang();
$jatuh->sql("select * from tempo");
$jum = $jatuh->getJml();
if ($jum != '0') {
$noer = 1;
while ($jatuh->hasil()) {
echo "<tr id='pop' title='Kode Buku " . $jatuh->hasil['buku'] . "'>";
echo "<td>{$noer}</td>";
echo "<td>" . $jatuh->hasil['buku'] . "</td>";
echo "<td>" . $jatuh->hasil['judul'] . "</td>";
echo "<td>" . $jatuh->hasil['siswa'] . "</td>";
echo "<td>" . $jatuh->hasil['tanggal'] . "</td>";
echo "</tr>";
$noer++;
}
} else {
echo "<tr id='pop' align='center'><td colspan='5' id='res'>Tidak Ada</td></tr>";
示例9: db
<?php
require '../sistem/config.php';
sambung();
$induk = mysql_real_escape_string($_POST['siswo']);
$siswa = new db();
$siswa->sql("SELECT * FROM tbl_anggota WHERE no_induk = '{$induk}'");
$siswa->hasil();
?>
<table cellpadding='1' cellspacing='3' id="tabel_ajax">
<tr>
<td>Nama</td><td>:</td><td><?php
echo $siswa->hasil['nama'];
?>
</td>
</tr>
<tr>
<td>No Induk</td><td>:</td><td><?php
echo $siswa->hasil['kelas'];
?>
<?php
echo $siswa->hasil['jurusan'];
?>
</td>
</tr>
<tr>
<td>Meminjam</td><td>:</td><td><?php
echo $meminjam;
?>
</td>
</tr>
示例10: db
<?php
@($peminjam = new db());
@($blm_kmbl = new db());
@$blm_kmbl->sql("SELECT * FROM tbl_peminjaman WHERE kembali = '0'");
@$peminjam->sql("SELECT * FROM tbl_peminjaman");
?>
<h2>Statistik</h2><br>
<form action='<?php
echo $_SERVER['REQUEST_URI'];
?>
' method='get' name='frmthn'>
<select name='thn' onchange='document.forms["frmthn"].submit()'>
<option value='' selected>Pilih Tahun</option>
<?php
$sekarang = date('Y');
$tahun = $_GET['thn'];
for ($i = 2011; $i <= $sekarang; $i++) {
echo "<option value='{$i}' >Tahun {$i}</option> ";
}
$peminjam = new db();
?>
</select>
<input type='hidden' name='stat' value=''>
<input type='submit' value='OK' class="btn btn-primary" style="margin-top:-8px">
</form>
<div style='margin: auto;'><img src='grafik/tahun.php?thn=<?php
echo $_GET['thn'];
?>
示例11: delete
/**
* 删除记录
*/
public function delete($table, $condition)
{
$where = '';
if (!empty($condition)) {
foreach ($condition as $k => $v) {
$where .= $k . "='" . $v . "' and ";
}
$where = 'where ' . $where . '1=1';
}
self::$sql = "delete from {$table} {$where}";
return mysql_query(self::$sql);
}
示例12: tambah
if (!isset($dari)) {
$dari = 'no_induk';
}
$kelas = $_GET['kelas'];
if ($kelas == '') {
$kelas = '%%';
}
$jur = $_GET['jurusan'];
$lim = $_GET['jumlah'];
if (isset($lim)) {
$s = "limit 0,";
$limit = $s . $lim;
} else {
$limit = "limit 0,40";
}
$siswa->sql("SELECT * FROM tbl_anggota WHERE {$dari} LIKE '%{$cari}%' && kelas LIKE '{$kelas}' && jurusan LIKE '%{$jur}%' {$limit}");
?>
<style>
tr#row:hover{
background-color: gray;
color: white;
}
</style>
<script type='text/javascript'>
function tambah(){
document.forms["frm-tambah"]["no_induk"].disabled=false;
document.forms["frm-tambah"]["nama"].disabled=false;
document.forms["frm-tambah"]["kelas"].disabled=false;
document.forms["frm-tambah"]["jurusan"].disabled=false;
document.forms["frm-tambah"]["tambah"].disabled=false;
示例13: sql
function sql($mode)
{
switch ($mode) {
case 'i':
self::$sql = "INSERT `" . self::$table . "` VALUES (" . self::$values . "); ";
self::query(self::$sql);
break;
case 's':
self::$res = self::query(self::selectSql());
if (!self::$res) {
return false;
}
self::$rows = mysql_num_rows(self::$res);
return self::$res;
break;
case 'assoc':
self::$res = self::query(self::selectSql());
if (!self::$res) {
return false;
}
self::$rows = mysql_num_rows(self::$res);
return mysql_fetch_assoc(self::$res);
break;
case 'get':
self::$res = self::query(self::selectSql());
if (!self::$res) {
return false;
}
self::$rows = mysql_num_rows(self::$res);
$row = mysql_fetch_assoc(self::$res);
return $row[self::$assoc_get];
break;
case 'u':
self::$sql = "UPDATE `" . self::$table . "` SET " . self::$values . " " . self::buildWhere() . "";
self::query(self::$sql);
break;
case 'd':
self::$sql = "DELETE FROM `" . self::$table . "` " . self::buildWhere() . " " . self::$order . " " . self::$limit . "";
self::query(self::$sql);
break;
case 'c':
self::$sql = "CREATE TABLE `" . self::$table . "` (\r\n\t\t\t\t" . self::$create_fields . "\r\n\t\t\t\t) CHARACTER SET " . self::$c_charset . " COLLATE " . self::$c_charset_col . ";";
self::query(self::$sql);
break;
case 'drop':
self::$sql = "DROP TABLE IF EXISTS `" . self::$table . "`";
self::query(self::$sql);
break;
case 'truncate':
self::$sql = "TRUNCATE TABLE `" . self::$table . "`";
self::query(self::$sql);
break;
}
}