Пример #1
0
<?php

require 'monetdb/php_monetdb.php';
$db = monetdb_connect("sql", "localhost", $argv[1], "monetdb", "monetdb", $argv[2]) or die(monetdb_last_error());
$packet_size = 20000;
$sql = 'select 1';
$sql = str_pad($sql, $packet_size, ' ');
echo strlen($sql) . "\n";
$res = monetdb_query($sql);
while ($row = monetdb_fetch_assoc($res)) {
    print_r($row);
}
monetdb_disconnect();
Пример #2
0
/**
 * Generates the next id in the sequence $seq
 *
 * @param resource connection instance
 * @param seq sequence whose next
 * value we want to retrieve
 * @return string the ID of the last tuple inserted. FALSE if an error occurs
 */
function monetdb_insert_id($connection = NULL, $seq)
{
    $num_args = func_num_args();
    if ($num_args == 1) {
        $connection = mapi_get_current_conn();
        $seq = func_get_arg(0);
    }
    if (is_string($seq)) {
        $query = "SELECT NEXT VALUE FOR " . monetdb_quote_ident($seq) . "";
        $res = monetdb_query($connection, $query);
        $row = monetdb_fetch_assoc($result);
        return $row[$seq];
    }
    return FALSE;
}
Пример #3
0
#!/usr/bin/php 

<?php 
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 2008-2015 MonetDB B.V.
?>

<?php 
require 'monetdb/php_monetdb.php';
$db = monetdb_connect("sql", "localhost", $argv[1], "monetdb", "monetdb", $argv[2]);
$tables = monetdb_query('SELECT name FROM tables LIMIT 10');
for ($i = 0; $line = @monetdb_fetch_assoc($tables); $i++) {
    print $line['name'] . "\n";
}
$result = monetdb_query('SELECT name, schema_id, query, type, system, commit_action, access, temporary FROM tables LIMIT 10');
$cols = monetdb_num_fields($result);
for ($i = 0; $i < $cols; $i++) {
    print monetdb_field_name($result, $i) . "\t";
}
print "\n";
while ($row = @monetdb_fetch_row($result)) {
    for ($i = 0; $i < $cols; $i++) {
        print $row[$i] . "\t";
    }
    print "\n";
}
Пример #4
0
<?php

error_reporting(E_ALL);
require 'php_monetdb.php';
define("DB", "demo");
echo function_exists("monetdb_connect");
echo function_exists("monetdb_last_error");
$db = monetdb_connect("sql", "127.0.0.1", 50000, "monetdb", "monetdb", "demo");
$err = monetdb_last_error();
$query = "SELECT * FROM demo.sys.word_asos where main_word = 'skull'";
$res = monetdb_query($db, $query) or trigger_error(monetdb_last_error());
echo "Rows: " . monetdb_num_rows($res) . "\n";
$row = monetdb_fetch_assoc($res);
var_dump($row);
foreach ($row as $rows) {
    if ($rows != null && $rows != '') {
        $assoc = "";
    }
}
monetdb_free_result($res);
if (monetdb_connected($db)) {
    monetdb_disconnect($db);
}