本文整理汇总了PHP中obj::query方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::query方法的具体用法?PHP obj::query怎么用?PHP obj::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
/**
* @name query
* @desc 执行一条SQL语句
* @param string $sql 要执行的sql语句
* @return resource
* @access public
**/
public function query($sql)
{
$begin_microtime = Debug::getTime();
try {
$status = $this->db->query($sql);
} catch (Exception $e) {
$this->halt($e, $sql);
return false;
}
Debug::db($this->db_host, $this->db_name, $sql, Debug::getTime() - $begin_microtime, $status);
return $status;
}
示例2: findAll
/**
* Return all batch detail records for given product and warehouse
*
* @param obj $db database object
* @param int $fk_product_stock id product_stock for objet
* @param int $with_qty doesn't return line with 0 quantity
* @return int <0 if KO, >0 if OK
*/
public static function findAll($db, $fk_product_stock, $with_qty = 0)
{
global $langs;
$ret = array();
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.tms,";
$sql .= " t.fk_product_stock,";
$sql .= " t.sellby,";
$sql .= " t.eatby,";
$sql .= " t.batch,";
$sql .= " t.qty,";
$sql .= " t.import_key";
$sql .= " FROM " . MAIN_DB_PREFIX . self::$_table_element . " as t";
$sql .= " WHERE fk_product_stock=" . $fk_product_stock;
if ($with_qty) {
$sql .= " AND qty<>0";
}
dol_syslog("productbatch::findAll", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$tmp = new productbatch($db);
$tmp->id = $obj->rowid;
$tmp->tms = $db->jdate($obj->tms);
$tmp->fk_product_stock = $obj->fk_product_stock;
$tmp->sellby = $db->jdate($obj->sellby);
$tmp->eatby = $db->jdate($obj->eatby);
$tmp->batch = $obj->batch;
$tmp->qty = $obj->qty;
$tmp->import_key = $obj->import_key;
array_push($ret, $tmp);
$i++;
}
$db->free($resql);
return $ret;
} else {
$error = "Error " . $db->lasterror();
return -1;
}
}
示例3: getFields
/**
* 数据表 > (所有)字段
* @return array
*/
function getFields($pTable)
{
$this->db =& self::instance($this->_config);
$tQuery = $this->db->query("SHOW FULL FIELDS FROM `{$pTable}`");
return $tQuery ? $tQuery->fetchAll(2) : array();
}