本文整理汇总了PHP中obj::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::num_rows方法的具体用法?PHP obj::num_rows怎么用?PHP obj::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::num_rows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}