本文整理匯總了PHP中bd::cast_query_results方法的典型用法代碼示例。如果您正苦於以下問題:PHP bd::cast_query_results方法的具體用法?PHP bd::cast_query_results怎麽用?PHP bd::cast_query_results使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bd
的用法示例。
在下文中一共展示了bd::cast_query_results方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
static function get($id)
{
$sql = "SELECT a.id, (SELECT razon_social FROM cliente WHERE id=a.proveedor) AS proveedor, a.nombre, a.observaciones FROM articulo as a WHERE a.id=" . $id;
$resultado = mysqli_query(bd::$con, $sql);
if ($articulo = bd::cast_query_results($resultado)[0]) {
$sql = "SELECT *, (SELECT nombre FROM categoria WHERE id=s.id_categoria) AS categoria, (SELECT GROUP_CONCAT(`tag`) FROM `subarticulo_tag` WHERE `id_subarticulo` = s.id GROUP BY `id_subarticulo`) AS tags FROM subarticulo AS s WHERE s.id_articulo=" . $id;
$resultado2 = mysqli_query(bd::$con, $sql);
if ($subarticulos = bd::cast_query_results($resultado2)) {
foreach ($subarticulos as $subarticulo) {
$sql = "SELECT id_categoria AS id, (SELECT nombre FROM categoria WHERE id=sc.id_categoria) AS nombre FROM subarticulo_categoria AS sc WHERE id_subarticulo=" . $subarticulo["id"];
$resultado3 = mysqli_query(bd::$con, $sql);
$subarticulo["categorias"] = bd::cast_query_results($resultado3);
$sql = "SELECT tag FROM subarticulo_tag WHERE id_subarticulo=" . $subarticulo["id"];
$resultado3 = mysqli_query(bd::$con, $sql);
$subarticulo["tags"] = bd::cast_query_results($resultado3);
$articulo["subarticulos"][] = $subarticulo;
}
return json_encode($articulo);
} else {
$articulo = null;
}
} else {
$articulo = null;
}
return $articulo;
}