public function insert(&$data, $pk = null, $sequence_name = null) { $data = $this->process_data($data); $sql = new SQLBuilder($this->conn, $this->get_fully_qualified_table_name()); $sql->insert($data, $pk, $sequence_name); $values = array_values($data); return $this->conn->query($this->last_sql = $sql->to_s(), $values); }
include 'includes/clientlogin.php'; include 'includes/sql.php'; include 'includes/file.php'; // Construct an HTTP POST request $clientlogin_url = "https://www.google.com/accounts/ClientLogin"; $clientlogin_post = array("accountType" => "HOSTED_OR_GOOGLE", "Email" => "*****@*****.**", "Passwd" => "Moloko6+7", "service" => "fusiontables", "source" => "your application name"); // Initialize the curl object $curl = curl_init($clientlogin_url); // Set some options (some for SHTTP) curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Execute $response = curl_exec($curl); // Get the Auth string and save it preg_match("/Auth=([a-z0-9_\\-]+)/i", $response, $matches); $auth = $matches[1]; echo "The auth string is: " . $auth; $ftclient = new FTClientLogin($auth); //show all tables echo $ftclient->query(SQLBuilder::showTables()); echo "<br />"; //describe a table echo $ftclient->query(SQLBuilder::describeTable(674831)); echo "<br />"; //insert into table (test, test2, 'another test') values (12, 3.3333, 'bob') echo $ftclient->query(SQLBuilder::insert(674831, array('AgendaDate' => 'May 11, 2001', 'AgendaItem' => 'JPA Bridge', 'Presenter' => 'Hardy Whitten', 'URL' => 'http://www.google.com')));
$ftclient = new FTClientLogin($token); //show all tables echo $ftclient->query(SQLBuilder::showTables()); echo "<br />"; //describe a table echo $ftclient->query(SQLBuilder::describeTable(358077)); echo "<br />"; //select * from table echo $ftclient->query(SQLBuilder::select(358077)); echo "<br />"; //select * from table where test=1 echo $ftclient->query(SQLBuilder::select(358077, null, "'test'=1")); echo "<br />"; //select test from table where test = 1 echo $ftclient->query(SQLBuilder::select(358077, array('test'), "'test'=1")); echo "<br />"; //select rowid from table echo $ftclient->query(SQLBuilder::select(358077, array('rowid'))); echo "<br />"; //delete row 401 echo $ftclient->query(SQLBuilder::delete(358077, '401')); echo "<br />"; //drop table echo $ftclient->query(SQLBuilder::dropTable(358731)); echo "<br />"; //update table test=1 where rowid=1 echo $ftclient->query(SQLBuilder::update(358077, array('test' => 12), 1)); echo "<br />"; //insert into table (test, test2, 'another test') values (12, 3.3333, 'bob') echo $ftclient->query(SQLBuilder::insert(358077, array('test' => 12, 'test2' => 3.33333, 'another test' => 'bob')));
public function insert(&$data, $pk = null, $sequenceName = null) { $data = $this->processData($data); $sql = new SQLBuilder($this->conn, $this->getFullyQualifiedTableName()); $sql->insert($data, $pk, $sequenceName); $values = array_values($data); return $this->conn->query($this->lastSql = $sql->toS(), $values); }
include 'fusion-tables-client-php/clientlogin.php'; include 'fusion-tables-client-php/sql.php'; include 'fusion-tables-client-php/file.php'; // Table id $tableid = 750563; //Enter your username and password $username = "******"; $password = "******"; // Get auth token - it would be better to save the token in a secure database // rather than requesting it with every page load. $token = ClientLogin::getAuthToken($username, $password); $ftclient = new FTClientLogin($token); // If the request is a post, insert the data into the table if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Insert form data into table $insertresults = $ftclient->query(SQLBuilder::insert($tableid, array('Name' => $_POST['name'], 'Value' => $_POST['result'], 'Location' => $_POST['location'], 'Timestamp' => time()))); $insertresults = explode("\n", $insertresults); $rowid1 = $insertresults[1]; } ?> <head> <title>Simple Form Example</title> <style> body { font-family: Arial, sans-serif; } #map_canvas { height: 300px; width:400px; } </style> <!-- Import Google Maps API JavaScript --> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>