1 回答
TA贡献1793条经验 获得超6个赞
您使用了错误的数据库表函数,请尝试以下操作:
$db = \Config\Database::connect(); // optional; init database if not created yet
$builder = $db->table('proses_cutting');
$builder->select('RIGHT(proses_cutting.kode_packing_list,6) as kode');
$builder->orderBy('kode_packing_list','DESC');
$builder->limit(1);
if($builder->countAllResults() > 0) {
$query = $builder->get();
$result = $query->getResult(); // Result as objects eg; $result->kode
$kode = $result->kode;
}
// Other option: I believe you can do this too
$builder = $db->table('proses_cutting');
$builder->select('RIGHT(proses_cutting.kode_packing_list,6) as kode');
$builder->orderBy('kode_packing_list','DESC');
$builder->limit(1);
$query = $builder->get();
$result = $query->getResult('array');
if(is_array($result) && count($array) > 0) {
$kode = $result['kode'];
}
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报