Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Last active December 16, 2015 12:08
Show Gist options
  • Select an option

  • Save maimai-swap/5432188 to your computer and use it in GitHub Desktop.

Select an option

Save maimai-swap/5432188 to your computer and use it in GitHub Desktop.
monetdb php sample
<?php
/**
* Connect to a database and perform a query.
*/
error_reporting(E_ALL);
require '/usr/local/share/php/monetdb/php_monetdb.php';
define("DB", "maxroach");
/* Establish a connection and report errors in case they occour */
echo function_exists("monetdb_connect");
echo function_exists("monetdb_last_error");
$db = monetdb_connect("sql" , "192.168.222.211", 50000, "username" , "password", "detabase_name" );
$err = monetdb_last_error();
/* Fire a query */
$query = "SELECT count(1) FROM adcloud";
$res = monetdb_query($db, monetdb_escape_string($query)) or trigger_error(monetdb_last_error());
/* Print the number of rows in the result set */
print "Rows: " . monetdb_num_rows($res) . "\n";
/* Iterate over the result set returning rows as objects */
while ( $row = monetdb_fetch_object($res) )
{
print_r($row);
}
/* Free the result set */
monetdb_free_result($res);
/* Disconnect from the database */
if (monetdb_connected($db)) {
monetdb_disconnect($db);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment