/** * @covers SQLBuilder::__toString */ public function test__toStringWhere() { $this->sql->select('users', 'u', array('id', 'username', 'email')); $this->sql->filter("id > 11"); $actual = $this->sql->__toString(); $excepted = "select u.id u_id,u.username u_username,u.email u_email from users u where (id > 11)"; $this->assertSame($excepted, $actual); }
public function build_director() { $sql_builder = new SQLBuilder(); $data = $this->get_data(); ///format key word to tokens $keywords = SQLLexical::format_product_query_to_array($data); $keywords = SQLLexical::make_keywords($keywords); //make query $len = sizeof($keywords); $tempID = array(); for ($i = 0; $i < $len; $i++) { $tempID[$i] = 'Name'; } return $sql_builder->select(array("Name", SQLBuilder::sql_as("Unit", "UnitName"), "Price", SQLBuilder::sql_as("ID", "Id"), SQLBuilder::sql_as("Product_ID", "ProductId"), SQLBuilder::sql_as("Bought", "Import_Price")))->from("tam_an.product")->where()->or_recursive('like', $tempID, $keywords)->to_string(); }
public function options_to_sql($options) { $table = array_key_exists('from', $options) ? $options['from'] : $this->get_fully_qualified_table_name(); $sql = new SQLBuilder($this->conn, $table); if (array_key_exists('joins', $options)) { $sql->joins($this->create_joins($options['joins'])); // by default, an inner join will not fetch the fields from the joined table if (!array_key_exists('select', $options)) { $options['select'] = $this->get_fully_qualified_table_name() . '.*'; } } if (array_key_exists('select', $options)) { $sql->select($options['select']); } if (array_key_exists('conditions', $options)) { if (!is_hash($options['conditions'])) { if (is_string($options['conditions'])) { $options['conditions'] = array($options['conditions']); } call_user_func_array(array($sql, 'where'), $options['conditions']); } else { if (!empty($options['mapped_names'])) { $options['conditions'] = $this->map_names($options['conditions'], $options['mapped_names']); } $sql->where($options['conditions']); } } if (array_key_exists('order', $options)) { $sql->order($options['order']); } if (array_key_exists('limit', $options)) { $sql->limit($options['limit']); } if (array_key_exists('offset', $options)) { $sql->offset($options['offset']); } if (array_key_exists('group', $options)) { $sql->group($options['group']); } if (array_key_exists('having', $options)) { $sql->having($options['having']); } return $sql; }
<?php include '../oauth.php'; include '../sql.php'; include '../file.php'; $extra_options = array('server' => 'localhost', 'database' => 'mydatabase', 'username' => 'myusername', 'password' => 'mypassword'); $user_id = 1; if (empty($_GET["oauth_token"])) { $url = OAuthClient::getAuthURL("myconsumerkey", "myconsumersecret", "MySQL", $user_id, "http://mydomain.com/samples/oauth_example.php", $extra_options); header($url); } else { $oauth_token = $_GET['oauth_token']; $verifier = $_GET['oauth_verifier']; OAuthClient::authorize("myconsumerkey", "myconsumersecret", $oauth_token, $verifier, "MySQL", $user_id, $extra_options); $oauthClient = new FTOAuthClient("myconsumerkey", "myconsumersecret", "MySQL", $user_id, $extra_options); echo $oauthClient->query(SQLBuilder::showTables()); echo $oauthClient->query(SQLBuilder::select(197026)); echo FileUploader::uploadCSV($oauthClient, "testcsv.csv"); }
$token = ClientLogin::getAuthToken('username', 'password'); $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')));
</head> <body onload="initialize();"> <h1>Simple Form Example</h1> <h2>Insert data</h2> <form method="post" action="form_example.php" onsubmit="return check_form();"> Name: <input type="text" name="name" id="name" /><br /> Result: <input type="text" name="result" id="result" /><br /> <!-- Create the map here --> <div id="map_canvas"></div> <!-- Hidden input field for location selected on map --> <input type="hidden" name="location" id="location" /> <input type="submit" value="Submit" /> </form> <h2>Table data</h2> <p> <?php // Show the data from table $table_data = $ftclient->query(SQLBuilder::select($tableid)); $table_data = explode("\n", $table_data); for ($i = 0; $i < count($table_data); $i++) { echo $table_data[$i] . '<br />'; } ?> </p> </body> </html>
public function build_director() { $sql_builder = new SQLBuilder(); $data = $this->get_data(); return $sql_builder->select(array(SQLBuilder::sql_as('ID', 'Id'), 'Name', 'User_type'))->from('tam_an.user')->where()->and_recursive('LIKE', array('Username', 'Password'), array($data['username'], md5($data['password'])))->to_string(); }
*/ include 'source/clientlogin.php'; include 'source/sql.php'; include 'source/connectioninfo.php'; function format_address($street, $city, $state, $zip) { $result = str_replace(" ", " ", $street); $result = $result . "<br />{$city}, {$state} {$zip}"; return $result; } //phpinfo(); //get token $token = ClientLogin::getAuthToken(ConnectionInfo::$google_username, ConnectionInfo::$google_password); $ftclient = new FTClientLogin($token); //select * from table $result = $ftclient->query(SQLBuilder::select(ConnectionInfo::$fusionTableId)); ?> <!DOCTYPE html> <html> <head> <title>Health Clinics in Chicago - Full List</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link href='styles/master.css' media='all' rel='stylesheet' type='text/css' /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <!--<script src="/source/analytics_lib.js" type="text/javascript"></script>--> <script src="source/jquery.dataTables.min.js" type="text/javascript"></script> <script type="text/javascript">