function db_query($query)
{
    global $quert_count;
    ++$quert_count;
    db_connect();
    $args = func_get_args();
    array_shift($args);
    if (isset($args[0]) and is_array($args[0])) {
        // 'All arguments in one array' syntax
        $args = $args[0];
    }
    _db_query_callback($args, TRUE);
    $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
    //echo $query;
    return _db_query($query);
}
Esempio n. 2
0
function _db_write($sql, $cluster, $shard)
{
    $cluster_key = _db_cluster_key($cluster, $shard);
    $ret = _db_query($sql, $cluster, $shard);
    if (!$ret['ok']) {
        return $ret;
    }
    return array('ok' => 1, 'affected_rows' => mysql_affected_rows($GLOBALS['db_conns'][$cluster_key]), 'insert_id' => mysql_insert_id($GLOBALS['db_conns'][$cluster_key]));
}
Esempio n. 3
0
	function _db_write($sql, $cluster, $k=null){

		$cluster_key = $k ? "{$cluster}-{$k}" : $cluster;

		$ret = _db_query($sql, $cluster, $k);

		if (!$ret['ok']) return $ret;

		return array(
			'ok'		=> 1,
			'affected_rows'	=> mysql_affected_rows($GLOBALS['db_conns'][$cluster_key]),
			'insert_id'	=> mysql_insert_id($GLOBALS['db_conns'][$cluster_key]),
		);
	}