Пример #1
9
function execute_multi($link, $arr_sqls, &$error)
{
    $sqls = implode(';', $arr_sqls) . ';';
    if (mysqli_multi_query($link, $sqls)) {
        $data = array();
        $i = 0;
        //计数
        do {
            if ($result = mysqli_store_result($link)) {
                $data[$i] = mysqli_fetch_all($result);
                mysqli_free_result($result);
            } else {
                $data[$i] = null;
            }
            $i++;
            if (!mysqli_more_results($link)) {
                break;
            }
        } while (mysqli_next_result($link));
        if ($i == count($arr_sqls)) {
            return $data;
        } else {
            $error = "sql语句执行失败:<br />&nbsp;数组下标为{$i}的语句:{$arr_sqls[$i]}执行错误<br />&nbsp;错误原因:" . mysqli_error($link);
            return false;
        }
    } else {
        $error = '执行失败!请检查首条语句是否正确!<br />可能的错误原因:' . mysqli_error($link);
        return false;
    }
}
Пример #2
0
 function execSP($sql)
 {
     $this->connMySQL();
     $this->sql = $sql;
     $i = 0;
     $result_ = null;
     if (mysqli_multi_query($this->conn, $this->sql)) {
         do {
             if ($this->resultado = mysqli_store_result($this->conn)) {
                 while ($row = mysqli_fetch_array($this->resultado)) {
                     $result_ = $row;
                 }
                 mysqli_free_result($this->resultado);
             }
             $i++;
         } while (mysqli_next_result($this->conn));
         mysqli_close($this->conn);
     } else {
         echo mysqli_error($this->conn);
         $this->closeConnMySQL();
         exit;
     }
     $this->closeConnMySQL();
     return $result_;
 }
Пример #3
0
 function finalize_order($eid, $details_xml)
 {
     //	$sql = sprintf("Call finalize_order(%s,%s)",$eid, $details_xml);
     //	if (!mysqli_multi_query($_SESSION['mysqli_link'], $sql )) echo "<div style='z-index:1500'>ERROR! (UpdaterSprocsContainer:aassdskarek)".mysqli_error($_SESSION['mysqli_link'])."</div>";
     //<<<EOT
     $QUERY = sprintf("Call finalize_order(%s,%s,@out_order_id);", $eid, $details_xml) . "SELECT @out_order_id as order_id;";
     //EOT;
     $mysqli = $_SESSION['mysqli_link'];
     $query = mysqli_multi_query($mysqli, $QUERY) or die("error 9832lkjaklh3" . mysqli_error($mysqli));
     if ($query) {
         do {
             if ($result = mysqli_store_result($mysqli)) {
                 $subresult = mysqli_fetch_assoc($result);
                 if (!isset($subresult['order_id'])) {
                     continue;
                 }
                 $_SESSION['finalized_order_id'] = $subresult['order_id'];
                 // foreach( $subresult AS $k => $v )
                 //  {
                 //   var_dump( $k , $v );
                 //  }
             }
         } while (mysqli_next_result($mysqli));
     }
 }
Пример #4
0
 function cloneDB($database_name = false)
 {
     $this->db->query('CREATE DATABASE ' . $database_name);
     if ($_SERVER['HTTP_HOST'] == "localhost") {
         //$dbname=$database_name;
         $password = "";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiondev.cloudapp.net") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiontech.in") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     $connect = mysqli_connect('localhost', $username, $password, $database_name);
     $db_file = file_get_contents('school_mgt.sql');
     mysqli_multi_query($connect, $db_file);
     do {
         mysqli_store_result($connect);
     } while (mysqli_more_results($connect) && mysqli_next_result($connect));
 }
 function clone_db($database_name = false, $organization_id = false)
 {
     $qry = $this->db->query('CREATE DATABASE ' . $database_name);
     if (!$qry) {
         $value = array('code' => '500', 'organization_id' => $organization_id);
         $json_data = json_encode($value);
         redirect('http://junctiondev.cloudapp.net/appmanager/login/result_application?json=' . $json_data);
     }
     $this->session->set_userdata('db_name', $database_name);
     $this->session->userdata('db_name');
     if ($_SERVER['HTTP_HOST'] == "localhost") {
         //$dbname=$database_name;
         $password = "";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiondev.cloudapp.net") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiontech.in") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     $connect = mysqli_connect('localhost', $username, $password, $database_name);
     $db_file = file_get_contents('junctionerp.sql');
     mysqli_multi_query($connect, $db_file);
     do {
         mysqli_store_result($connect);
     } while (mysqli_more_results($connect) && mysqli_next_result($connect));
     return true;
 }
Пример #6
0
 public function ResistMenuLog($_uid, $_log)
 {
     $query = "TRUNCATE TABLE UM" . $_uid . ";";
     $result = $this->_db_throw_query("Users_Geo", $query);
     $query = "";
     $tmp = "INSERT INTO UM" . $_uid . " VALUES ( '";
     for ($i = 0; $i < 7; $i++) {
         for ($j = 0; $j < 3; $j++) {
             if ($j == 2) {
                 if (strpos($_log[$this->week[$i]][$this->kind[$j]], '|') !== false) {
                     $div = explode('|', $_log[$this->week[$i]][$this->kind[$j]]);
                     $size = count($div);
                     for ($k = 0; $k < $size; $k++) {
                         $query = $query . $tmp . $div[$k] . "', '" . $this->kind[$j] . "', ( NOW() + INTERVAL " . $i . " DAY ) );";
                     }
                     break;
                 }
             }
             $query = $query . $tmp . $_log[$this->week[$i]][$this->kind[$j]] . "', '" . $this->kind[$j] . "', ( NOW() + INTERVAL " . $i . " DAY ) );";
         }
     }
     $this->_db_select("Users_Geo");
     $result = mysqli_multi_query($this->_connection, $query);
     if (!$result) {
         print "Quely Failed.\n" . mysqli_error($this->_connection);
         return false;
     }
     do {
         mysqli_store_result($this->_connection);
     } while (mysqli_next_result($this->_connection));
     return true;
 }
function task_optimize($connection, $settings, $time, $table = false, $and_default = true)
{
    require_once $settings['functions'] . 'function.task.log.php';
    if ($table) {
        $tables[] = $table;
    }
    if ($and_default) {
        $tables[] = 'peers';
        $tables[] = 'tasks';
        $tables[] = 'torrents';
    }
    $sql = '';
    foreach ($tables as $table) {
        $sql .= 'CHECK TABLE `' . $settings['db_prefix'] . $table . '`;' . 'ANALYZE TABLE `' . $settings['db_prefix'] . $table . '`;' . 'REPAIR TABLE `' . $settings['db_prefix'] . $table . '`;' . 'OPTIMIZE TABLE `' . $settings['db_prefix'] . $table . '`;';
    }
    $result = mysqli_multi_query($connection, $sql);
    if ($result) {
        while (mysqli_more_results($connection)) {
            mysqli_next_result($connection);
            mysqli_store_result($connection);
        }
    }
    if ($result) {
        task_log($connection, $settings, 'optimize', $time);
    }
    return $result;
}
Пример #8
0
function sqllogin($host, $dbuser, $dbpass, $dbname)
{
    // connectivity
    //mysql connections for stacked query examples.
    $con1 = mysqli_connect($host, $dbuser, $dbpass, $dbname);
    $username = mysqli_real_escape_string($con1, $_POST["login_user"]);
    $password = $_POST["login_password"];
    // Check connection
    if (mysqli_connect_errno($con1)) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    } else {
        @mysqli_select_db($con1, $dbname) or die("Unable to connect to the database ######: ");
    }
    /* execute multi query */
    $sql = "SELECT * FROM users WHERE username='******' and password='******'";
    if (@mysqli_multi_query($con1, $sql)) {
        /* store first result set */
        if ($result = @mysqli_store_result($con1)) {
            if ($row = @mysqli_fetch_row($result)) {
                if ($row[1]) {
                    return $row[1];
                } else {
                    return 0;
                }
            }
        }
    }
}
Пример #9
0
 public function ClearStoredResults($link)
 {
     while (mysqli_next_result($link)) {
         if ($resultval = mysqli_store_result($link)) {
             $this->free_result($resultval);
         }
     }
 }
Пример #10
0
 function freeDBResource($dbh)
 {
     while (mysqli_next_result($dbh)) {
         if ($l_result = mysqli_store_result($dbh)) {
             mysqli_free_result($l_result);
         }
     }
 }
Пример #11
0
 public static function fnc($f, $p)
 {
     if (self::$msql == NULL) {
         self::$msql = mysqli_connect(self::$host, self::$user, self::$pass, self::$base);
         mysqli_query(self::$msql, 'SET NAMES UTF8');
     }
     mysqli_multi_query(self::$msql, "CALL {$f}({$p})");
     $result = mysqli_store_result(self::$msql);
     $r = self::fetch_r($result);
     return $r;
 }
Пример #12
0
function getGenres()
{
    global $db;
    $stmt = mysqli_prepare($db, 'SELECT id, name FROM genres');
    mysqli_stmt_execute($stmt);
    mysqli_store_result($db);
    mysqli_stmt_bind_result($stmt, $id, $genre);
    while (mysqli_stmt_fetch($stmt)) {
        $genres[$id] = $genre;
    }
    return $genres;
}
function callStoredProcedure($procedure)
{
    global $link;
    // if (DEBUGGING) { echo  "CALL ".$procedure ."<BR>";}
    $resultset = mysqli_multi_query($link, "CALL " . $procedure) or die(__FILE__ . __LINE__ . mysqli_error($link) . $procedure);
    $data = mysqli_store_result($link);
    // clear remaining sets in the resultset before returning
    while (mysqli_more_results($link)) {
        mysqli_next_result($link);
    }
    return $data;
}
Пример #14
0
 public function query($SQL)
 {
     if ($SQL !== "") {
         if (stristr($SQL, "call") and stripos($SQL, "call") === 0) {
             mysqli_multi_query(self::$connection, $SQL);
             $this->query = mysqli_store_result(self::$connection);
             if (mysqli_more_results(self::$connection)) {
                 mysqli_next_result(self::$connection);
             }
         } else {
             $this->query = mysqli_query(self::$connection, $SQL);
         }
     }
     return $this->query ? $this->query : false;
 }
Пример #15
0
 function query($query)
 {
     $args = array();
     if (is_array($query)) {
         $args = $query;
         // only use arg 1
     } else {
         $args = func_get_args();
     }
     $query = $this->_format_query($args);
     $this->querycount++;
     if (isset($this->get['debug'])) {
         $this->debug($query);
     }
     mysqli_real_query($this->connection, $query) or error(QUICKSILVER_QUERY_ERROR, mysqli_error($this->connection), $query, mysqli_errno($this->connection));
     return mysqli_store_result($this->connection);
 }
Пример #16
0
function executeQuery($query, $host, $user, $pass, $db, $port, $link = null)
{
    if (!$link && !connect($link, $host, $user, $pass, $db, $port)) {
        return false;
    } else {
        if (isset($db) && !mysqli_select_db($link, $db)) {
            return false;
        }
    }
    if (!mysqli_multi_query($link, $query) || $link->error != '') {
        return false;
    }
    while (mysqli_more_results($link) && mysqli_next_result($link)) {
        $discard = mysqli_store_result($link);
    }
    $link->commit();
    return true;
}
Пример #17
0
function sql($string)
{
    global $db;
    global $result;
    if (trim($string) === '') {
        return;
    }
    mysqli_multi_query($db, $string) or die("MySQL Error when executing: {$string} <br/>\n" . mysqli_error($db) . "\n");
    $test = true;
    while (mysqli_more_results($db)) {
        $test = false;
        $result = mysqli_store_result($db);
        mysqli_next_result($db) or die("MySQL Error when executing: {$string} <br/>\n" . mysqli_error($db) . "\n");
    }
    if ($test) {
        $result = mysqli_store_result($db);
    }
}
Пример #18
0
 function multi_query($queryString, $params = NULL)
 {
     $queryString = isset($params) ? str_format($queryString, $params) : $queryString;
     $outputArray = array();
     if (mysqli_multi_query($this->connection, $queryString)) {
         do {
             if ($queryResult = mysqli_store_result($this->connection)) {
                 $array = array();
                 while ($row = mysqli_fetch_assoc($queryResult)) {
                     $array[] = $row;
                 }
                 $outputArray[] = $array;
                 mysqli_free_result($queryResult);
             }
         } while (mysqli_next_result($this->connection));
         return $outputArray;
     }
     return FALSE;
 }
Пример #19
0
 function clone_db($database_name = false)
 {
     //echo $database_name; return;
     $this->db->query('CREATE DATABASE ' . $database_name);
     if ($_SERVER['HTTP_HOST'] == "localhost") {
         //$dbname=$database_name;
         $password = "";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiondev.cloudapp.net") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     if ($_SERVER['HTTP_HOST'] == "junctiontech.in") {
         //$dbname=$database_name;
         $password = "******";
         $username = "******";
     }
     $connect = mysqli_connect('localhost', $username, $password, $database_name);
     $db_file = file_get_contents('school_mgt.sql');
     mysqli_multi_query($connect, $db_file);
     do {
         mysqli_store_result($connect);
     } while (mysqli_more_results($connect) && mysqli_next_result($connect));
     $query = "SELECT count(*) as 'Tables', table_schema as 'Database' FROM information_schema.TABLES WHERE table_schema= '" . $database_name . "' GROUP BY table_schema";
     $result = mysqli_query($connect, $query);
     $countTable = mysqli_fetch_assoc($result);
     //echo $countTable['Tables'];die;
     if (isset($countTable['Tables']) && $countTable['Tables'] == '76') {
         return true;
     } else {
         //$CII =& get_instance();
         // 	$CII->load->library('session'); //if it's not autoloaded in your CI setup
         //  	$database_name=$CII->session->userdata('db_name');
         // 	$CII->session->unset_userdata($database_name);
         // 	$CII->session->sess_destroy();
         echo 'database does not exist';
         return;
         die;
     }
 }
 /**
  * Execute a mySQL query or multi queries
  * @param string $query mySQL query, or multiple queries seperated by a ';'
  * @param array $db_params db parameters array 'db_host', 'db_user', 'db_pass', 'db_port'
  * @param string $db_name database name
  * @param mysqli $link mysqli link
  * @return true on success, false otherwise
  */
 public static function executeQuery($query, $db_params, $db_name, $link = null)
 {
     // connect if not yet connected
     if (!$link && !self::connect($link, $db_params, $db_name)) {
         return false;
     } else {
         if (isset($db_name) && !mysqli_select_db($link, $db_name)) {
             logMessage(L_ERROR, "Cannot execute query: could not find the db: {$db}");
             return false;
         }
     }
     // execute all queries
     if (!mysqli_multi_query($link, $query) || $link->error != '') {
         logMessage(L_ERROR, "Cannot execute query: error with query: {$query}, error: " . $link->error);
         return false;
     }
     // flush
     while (mysqli_more_results($link) && mysqli_next_result($link)) {
         $discard = mysqli_store_result($link);
     }
     $link->commit();
     return true;
 }
function func_test_mysqli_next_result($link, $query, $offset, $num_results, $strict_on)
{
    if (!mysqli_multi_query($link, $query)) {
        printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
    }
    $i = 0;
    if ($strict_on) {
        ob_start();
    }
    do {
        if ($res = mysqli_store_result($link)) {
            mysqli_free_result($res);
            $i++;
        }
    } while (true === mysqli_next_result($link));
    if ($strict_on) {
        $tmp = ob_get_contents();
        ob_end_clean();
        if (!preg_match('@Strict Standards: mysqli_next_result\\(\\): There is no next result set@ismU', $tmp)) {
            printf("[%03d] Strict Standards warning missing\n", $offset + 1);
        } else {
            $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\\(\\).*on line \\d+@ism', '', $tmp));
        }
        print trim($tmp) . "\n";
    }
    if ($i !== $num_results) {
        printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i);
    }
    if (mysqli_more_results($link)) {
        printf("[%03d] mysqli_more_results() indicates more results than expected\n", $offset + 3);
    }
    if (!($res = mysqli_query($link, "SELECT 1 AS b"))) {
        printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link));
    } else {
        mysqli_free_result($res);
    }
}
Пример #22
0
    die("连接数据库失败:" . mysql_error());
}
mysql_select_db("test", $conn);
//字符转换,读库
mysql_query("set character set 'gbk'");
//写库
mysql_query("set names 'gbk'");*/
$link = mysqli_connect("10.4.8.232", "root", "", "test");
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit;
}
//检测用户名及密码是否正确
$check_query = mysqli_multi_query($link, "select uid from user where username='******' and password='******'");
if ($result = mysqli_store_result($link)) {
    if ($row = mysqli_fetch_row($result)) {
        //登录成功
        //$_SESSION['username'] = $username;
        //$_SESSION['userid'] = $result['uid'];
        $userid = $row[0];
        //echo $userid,'hehehehhehehe</a><br />';
        //echo $username,' 欢迎你!进入 <a href=my.php?userid= ".$userid.">用户中心</a><br />';
        echo "<a href= 'my.php?userid= {$userid}'>我的可操作模块</a><br />";
        echo '点击此处 <a href="login.php?action=logout">注销</a> 登录!<br />';
        exit;
    }
} else {
    exit('登录失败!点击此处 <a href="javascript:history.back(-1);">返回</a> 重试');
}
//http://www.kuqin.com/php5_doc/function.mysqli-multi-query.html
Пример #23
0
        <h2>To reset your password, enter the email address you use to sign in.</h2>

        <?php 
$mess = "";
if (isset($_POST['SubButton'])) {
    $userNameIn = trim($_POST['myUname']);
    $userNameIn = mysqli_real_escape_string($con, $userNameIn);
    //now veriy the username and password
    if (emailcheck($userNameIn)) {
        $count = 0;
        //check if the username and password exists in the database
        $sql = "Call SP_COUNT_Aegis_Email('" . $userNameIn . "',@count);select @count as c";
        if (mysqli_multi_query($con, $sql)) {
            do {
                // Store first result set
                if ($result = mysqli_store_result($con)) {
                    // Fetch one and one row
                    while ($row = mysqli_fetch_row($result)) {
                        $count = $row[0];
                        //the second result is the count. It overwrites the first $count value.
                    }
                    // Free result set
                    mysqli_free_result($result);
                }
            } while (mysqli_next_result($con));
        }
        if ($count == 1) {
            $sql = "SELECT `Password` FROM `Aegis_Employee` WHERE `Email` = '" . $userNameIn . "'";
            $result = mysqli_query($con, $sql) or die("Error in the consult.." . mysqli_error($con));
            //send the query to the database or quit if cannot connect
            $row = $result->fetch_assoc();
Пример #24
0
 /**
  * Executes given SQL statement (procedure call).
  *
  * @param string $sql SQL statement (procedure call)
  * @return resource Result resource identifier for first recordset
  * @access protected
  */
 function _executeProcedure($sql)
 {
     $answer = mysqli_multi_query($this->connection, $sql);
     $firstResult = mysqli_store_result($this->connection);
     if (mysqli_more_results($this->connection)) {
         while ($lastResult = mysqli_next_result($this->connection)) {
         }
     }
     return $firstResult;
 }
Пример #25
0
 function NextRecordSet()
 {
     global $ADODB_COUNTRECS;
     mysqli_free_result($this->_queryID);
     $this->_queryID = -1;
     // Move to the next recordset, or return false if there is none. In a stored proc
     // call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result
     // returns false. I think this is because the last "recordset" is actually just the
     // return value of the stored proc (ie the number of rows affected).
     if (!mysqli_next_result($this->connection->_connectionID)) {
         return false;
     }
     // CD: There is no $this->_connectionID variable, at least in the ADO version I'm using
     $this->_queryID = $ADODB_COUNTRECS ? @mysqli_store_result($this->connection->_connectionID) : @mysqli_use_result($this->connection->_connectionID);
     if (!$this->_queryID) {
         return false;
     }
     $this->_inited = false;
     $this->bind = false;
     $this->_currentRow = -1;
     $this->Init();
     return true;
 }
Пример #26
0
 /**
  * 清空多余结果集
  * @return void
  * @since 1.0.0
  */
 private function clear_more_result()
 {
     while (mysqli_more_results($this->conn)) {
         mysqli_next_result($this->conn);
         if ($rs = mysqli_store_result($this->conn)) {
             mysqli_free_result($rs);
         }
     }
 }
Пример #27
0
 /**
  * Move the internal result pointer to the next available result
  *
  * @param a valid result resource
  * @return true on success, false if there is no more result set or an error object on failure
  * @access public
  */
 function nextResult()
 {
     $connection = $this->db->getConnection();
     if (PEAR::isError($connection)) {
         return $connection;
     }
     if (!@mysqli_more_results($connection)) {
         return false;
     }
     if (!@mysqli_next_result($connection)) {
         return false;
     }
     if (!($this->result = @mysqli_store_result($connection))) {
         return false;
     }
     return MDB2_OK;
 }
Пример #28
0
 /**
  * Store the result returned from multi query
  *
  * @param mysqli $link the mysqli object
  *
  * @return mixed false when empty results / result set when not empty
  */
 public function storeResult($link)
 {
     return mysqli_store_result($link);
 }
Пример #29
-1
function editEmployee($conn, $empAndTraits)
{
    $query = "UPDATE  `test_two`.`employee_info`" . " SET `first_name`='{$empAndTraits['firstName']}'," . "`last_name` = '{$empAndTraits['lastName']}'," . "`phone_number` = '{$empAndTraits['phoneNumber']}'," . "`address`='{$empAndTraits['address']}'," . "`age`='{$empAndTraits['age']}'" . "WHERE `idemployee_info` = '{$empAndTraits['idToEdit']}';";
    $query .= "UPDATE  `test_two`.`traits`" . " SET `hair_color`='{$empAndTraits['hairColor']}'," . "`eye_color` = '{$empAndTraits['eyeColor']}'," . "`weight` = '{$empAndTraits['weight']}'," . "`height`='{$empAndTraits['height']}'" . "WHERE `employee_id` = '{$empAndTraits['idToEdit']}';";
    if ($is_successful = mysqli_multi_query($conn, $query)) {
        do {
            if ($result = mysqli_store_result($conn)) {
                my_sqli_free_result($result);
            }
        } while (mysqli_next_result($conn));
    }
    if ($is_successful) {
        return showAllrows($conn);
    } else {
        return 'ERROR';
    }
}
Пример #30
-8
function fn_execSQL($sql, $r = 0)
{
    global $conexao;
    if (mysqli_multi_query($conexao, $sql)) {
        $resultado = mysqli_store_result($conexao);
        if ($resultado) {
            //prepara um array com os campos/colunas da consulta
            $i = 0;
            while ($obj = mysqli_fetch_field($resultado)) {
                $arrayCampos[$i] = $obj->name;
                $i++;
            }
            //prepara um array associativo com o resultado da consulta
            $i = 0;
            while ($linha = mysqli_fetch_array($resultado)) {
                for ($j = 0; $j < count($arrayCampos); $j++) {
                    $retorno[$i][$arrayCampos[$j]] = $linha[$arrayCampos[$j]];
                }
                $i++;
            }
            mysqli_free_result($resultado);
        }
        //mysqli_close($conexao_geral);
        if (isset($retorno)) {
            return $retorno;
        } else {
            return null;
        }
    } else {
        echo "<p>N�o foi poss�vel executar a seguinte instru��o SQL:</p><p><strong>{$sql}</strong></p>\n" . "<p>Erro MySQL: " . mysqli_error($conexao) . "</p>";
        exit;
        //mysqli_close($conexao_geral);
    }
}