码迷,mamicode.com
首页 > Web开发 > 详细

php iquery

时间:2015-02-14 12:39:03      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:

<?php
/**
*
*/
function iQuery($sql) {
$dbcon = mysqli_connect("localhost", "root", "159753", "radius");
if ($dbcon->connect_error) {
return false;
}
if (!is_array($sql)) {
$res = $dbcon->query($sql);
if ($res) {
$arr = [];
while ($item = $res->fetch_array()) {
array_push($arr, $item);
}
$ttr = null;
if (preg_match("/SQL_CALC_FOUND_ROWS/i", $sql)) {
$qttr = $dbcon->query("select found_rows()");
if ($qttr) {
while ($atom = $qttr->fetch_array()) {
$ttr = $atom[0];
}
}

}
return ["insert_id" => $dbcon->insert_id, "affected_rows" => $dbcon->affected_rows, "result" => $arr, "total_rows" => $ttr];
} else {
return false;
}
} else {
$rtn_arr = [];
foreach ($sql as $s) {
$res = $dbcon->query($s);
if ($res) {
$arr = [];
while ($item = $res->fetch_array()) {
array_push($arr, $item);
}
$ttr = null;
if (preg_match("/SQL_CALC_FOUND_ROWS/i", $sql)) {
$qttr = $dbcon->query("select found_rows()");
if ($qttr) {
while ($atom = $qttr->fetch_array()) {
$ttr = $atom[0];
}
}

}
array_push($rtn_arr, ["insert_id" => $dbcon->insert_id, "affected_rows" => $dbcon->affected_rows, "result" => $arr, "total_rows" => $ttr]);
} else {
return false;
}
}
return $rtn_arr;
}

}

?>

php iquery

标签:

原文地址:http://www.cnblogs.com/sky-view/p/4291450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!