public function build_director()
 {
     $sql_builder = new SQLBuilder();
     $data = $this->get_data();
     $input = SQLLexical::make_product_list($data['list_product']);
     return $sql_builder->sql_insert('tam_an.product', array('Name', 'Bought', 'Price', 'Unit'))->sql_insert_values_recursive($input)->end_query()->to_string();
 }
 public function build_director()
 {
     //get data from SQL
     $data = $this->get_data();
     $input = SQLLexical::make_product_list($data['list_product']);
     //use sql builder
     $sql_builder = new SQLBuilder();
     $id_array = array("Name", "Bought", "Price", "Unit");
     foreach ($input as $key => $value) {
         $sql_builder->update('tam_an.product')->set($id_array, $value)->where()->equals('ID', $key)->end_query();
     }
     return $sql_builder->to_string();
 }
 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();
 }
Ejemplo n.º 4
0
 /**
  * @covers SQLBuilder::getParamTypes
  */
 public function testGetParamTypes()
 {
     $condition = "id in ? OR email like ?";
     $this->sql->filter($condition, 'as', array(1, 2), 'fr');
     $params = $this->sql->getParamTypes();
     $this->assertEquals('iis', $params);
 }
Ejemplo n.º 5
0
 public function generateItemSetTable()
 {
     $SQLBuilder = new SQLBuilder($this->Patch, $this->Build, 'itemset');
     $SQLBuilder->addDataSource('ItemSet.dbc');
     $SQLBuilder->addDataSource('ItemSetSpell.dbc');
     $SQLBuilder->addRelation('freedomcore_itemset', 'freedomcore_itemsetspell', 'id', 'set_id', 'item10');
     $SQLBuilder->generateNewStructure();
     $SQLBuilder->generateCreationQuery();
     $SQLBuilder->populateDatabase();
     return $SQLBuilder;
 }
 public function build_director()
 {
     $sql_builder = new SQLBuilder();
     $data = $this->get_data();
     return $sql_builder->sql_delete()->from("tam_an.product")->where()->in('ID', $data)->to_string();
 }
<?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");
}
Ejemplo n.º 8
0
 public function delete($data)
 {
     $data = $this->processData($data);
     $sql = new SQLBuilder($this->conn, $this->getFullyQualifiedTableName());
     $sql->delete($data);
     $values = $sql->bindValues();
     return $this->conn->query($this->lastSql = $sql->toS(), $values);
 }
Ejemplo n.º 9
0
    public function set(array $fieldValues)
    {
    }
    public function into($table)
    {
    }
    public function query()
    {
    }
}
// Spl auto loader
require 'SplClassLoader.php';
$loader = new SplClassLoader(null, implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'src')));
$loader->register();
// SQL builder
$query = new SQLBuilder();
// Run some successful queries
$query->getBuilder()->select('*')->from('foo')->where('bar = 1')->query();
// SELECT * FROM foo WHERE bar = 1;
$query->getBuilder()->update('foo')->set(array('bar' => 2))->where('bar = 1')->query();
// UPDATE foo SET bar = 2 WHERE bar = 1;
$query->getBuilder()->insert(array('foo' => 3))->into('foo')->query();
// INSERT INTO foo (bar) VALUES (3);
$query->getBuilder()->delete()->from('foo')->where('bar = 2')->query();
// DELETE FROM foo WHERE bar = 2
$query->getBuilder()->delete()->from('foo')->where('bar = 2')->query();
// DELETE FROM foo WHERE bar = 2
// Try go against the hierarchy
try {
    $query->getBuilder()->select('*')->from('foo')->into('bar')->query();
} catch (\Chainnn\Exception\RuntimeException $e) {
Ejemplo n.º 10
0
 /**
  * Prepare the given query for execution.
  *
  * @param SQLBuilder|String $sql can be either:
  *          a. SQLBuilder: in which case it may contain parameters prepared
  *             statements.
  *          b. String: Plain SQL.
  * @param PagingInfo $paging
  * @return mysqli_stmt
  * @throws
  */
 public function prepare($sql, $paging = null)
 {
     if (!$sql) {
         throw new SQLException("Empty query");
     }
     # Keep the PagingInfo so we can set total rows later on.
     $this->paging = $paging;
     $queryPager = new QueryPager($sql, $paging);
     if ($this->debugOn) {
         Logger::debug("SQL: {$sql}");
     }
     # Create a prepared statement
     $stmt = $this->db->prepare($queryPager->getQuery());
     if (!$stmt) {
         throw new SQLException($this->db->error);
     }
     # Bind parameters, if there are any
     if ($sql instanceof SQLBuilder && $sql->hasParams()) {
         $refArgs = array($sql->getParamTypes());
         foreach ($sql->getParamList() as $param) {
             $refArgs[] = $param;
         }
         // Modify the values in the array to be referenced (ugly, but works).
         for ($i = 1; $i < count($refArgs); $i++) {
             $refArgs[$i] =& $refArgs[$i];
         }
         call_user_func_array(array($stmt, 'bind_param'), $refArgs);
         if ($this->debugOn) {
             Logger::debug("Query params: " . var_export($refArgs, true));
         }
     }
     return $stmt;
 }
Ejemplo n.º 11
0
 public function get_list_of_product_info($data = NULL)
 {
     $sqlbuilder = new SQLBuilder();
     if (is_null($data)) {
         $sql = mysqli_query($this->db, $sqlbuilder->get_list_of_product_info());
     } else {
         $sql = mysqli_query($this->db, $sqlbuilder->alter_product_query($data));
     }
     $result = NULL;
     if ($sql && mysqli_num_rows($sql) != 0) {
         $result = array();
         while ($rlt = mysqli_fetch_array($sql, MYSQL_ASSOC)) {
             $result[] = $rlt;
         }
     }
     return $result;
 }
Ejemplo n.º 12
0
 protected function create_conditions_from_keys(Model $model, $condition_keys = array(), $value_keys = array())
 {
     $condition_string = implode('_and_', $condition_keys);
     $condition_values = array_values($model->get_values_for($value_keys));
     // return null if all the foreign key values are null so that we don't try to do a query like "id is null"
     if (all(null, $condition_values)) {
         return null;
     }
     $conditions = SQLBuilder::create_conditions_from_underscored_string($condition_string, $condition_values);
     # DO NOT CHANGE THE NEXT TWO LINES. add_condition operates on a reference and will screw options array up
     if (isset($this->options['conditions'])) {
         $options_conditions = $this->options['conditions'];
     } else {
         $options_conditions = array();
     }
     return Utils::add_condition($options_conditions, $conditions);
 }
Ejemplo n.º 13
0
 /**
  * Find records in the database.
  *
  * Finding by the primary key:
  *
  * <code>
  * # queries for the model with id=123
  * YourModel::find(123);
  *
  * # queries for model with id in(1,2,3)
  * YourModel::find(1,2,3);
  *
  * # finding by pk accepts an options array
  * YourModel::find(123,array('order' => 'name desc'));
  * </code>
  *
  * Finding by using a conditions array:
  *
  * <code>
  * YourModel::find('first', array('conditions' => array('name=?','Tito'),
  *   'order' => 'name asc'))
  * YourModel::find('all', array('conditions' => 'amount > 3.14159265'));
  * YourModel::find('all', array('conditions' => array('id in(?)', array(1,2,3))));
  * </code>
  *
  * Finding by using a hash:
  *
  * <code>
  * YourModel::find(array('name' => 'Tito', 'id' => 1));
  * YourModel::find('first',array('name' => 'Tito', 'id' => 1));
  * YourModel::find('all',array('name' => 'Tito', 'id' => 1));
  * </code>
  *
  * An options array can take the following parameters:
  *
  * <ul>
  * <li><b>select:</b> A SQL fragment for what fields to return such as: '*', 'people.*', 'first_name, last_name, id'</li>
  * <li><b>joins:</b> A SQL join fragment such as: 'JOIN roles ON(roles.user_id=user.id)' or a named association on the model</li>
  * <li><b>include:</b> TODO not implemented yet</li>
  * <li><b>conditions:</b> A SQL fragment such as: 'id=1', array('id=1'), array('name=? and id=?','Tito',1), array('name IN(?)', array('Tito','Bob')),
  * array('name' => 'Tito', 'id' => 1)</li>
  * <li><b>limit:</b> Number of records to limit the query to</li>
  * <li><b>offset:</b> The row offset to return results from for the query</li>
  * <li><b>order:</b> A SQL fragment for order such as: 'name asc', 'name asc, id desc'</li>
  * <li><b>readonly:</b> Return all the models in readonly mode</li>
  * <li><b>group:</b> A SQL group by fragment</li>
  * </ul>
  *
  * @throws {@link RecordNotFound} if no options are passed or finding by pk and no records matched
  * @return mixed An array of records found if doing a find_all otherwise a
  *   single Model object or null if it wasn't found. NULL is only return when
  *   doing a first/last find. If doing an all find and no records matched this
  *   will return an empty array.
  */
 public static function find()
 {
     $class = get_called_class();
     if (func_num_args() <= 0) {
         throw new RecordNotFound("Couldn't find {$class} without an ID");
     }
     $args = func_get_args();
     $options = static::extract_and_validate_options($args);
     $num_args = count($args);
     $single = true;
     // if (isset ($options['enable_append_conditions']) && (($options['enable_append_conditions'] == '1') || ($options['enable_append_conditions'] == true))) {
     if (!isset($options['enable_append_conditions']) || ($options['enable_append_conditions'] == '1' || $options['enable_append_conditions'] == true)) {
         $append_conditions = static::table()->append_conditions;
         $columns = static::table()->columns;
         if (isset($append_conditions) && is_array($append_conditions) && count($append_conditions) && isset($columns) && is_array($columns) && count($columns)) {
             foreach ($append_conditions as $key => $append_condition) {
                 if (array_key_exists($key, $columns)) {
                     if (!isset($options['conditions']) || !is_array($options['conditions']) || !count($options['conditions'])) {
                         $options['conditions'] = array();
                         $options['conditions'][0] = '';
                     }
                     $options['conditions'][0] .= (isset($options['conditions'][0]) && $options['conditions'][0] != '' ? ' AND ' : '') . $key . ' = ? ';
                     array_push($options['conditions'], $append_condition);
                 }
             }
         }
     }
     if (isset($options['enable_append_conditions'])) {
         unset($options['enable_append_conditions']);
     }
     if ($num_args > 0 && ($args[0] === 'all' || $args[0] === 'first' || $args[0] === 'last')) {
         switch ($args[0]) {
             case 'all':
                 $single = false;
                 break;
             case 'last':
                 if (!array_key_exists('order', $options)) {
                     $options['order'] = join(' DESC, ', static::table()->pk) . ' DESC';
                 } else {
                     $options['order'] = SQLBuilder::reverse_order($options['order']);
                 }
                 // fall thru
             // fall thru
             case 'first':
                 $options['limit'] = 1;
                 $options['offset'] = 0;
                 break;
         }
         $args = array_slice($args, 1);
         $num_args--;
     } elseif (1 === count($args) && 1 == $num_args) {
         $args = $args[0];
     }
     // anything left in $args is a find by pk
     if ($num_args > 0 && !isset($options['conditions'])) {
         return static::find_by_pk($args, $options);
     }
     $options['mapped_names'] = static::$alias_attribute;
     $list = static::table()->find($options);
     return $single ? !empty($list) ? $list[0] : null : $list;
 }
Ejemplo n.º 14
0
 public function get_list_of_product_info()
 {
     return $this->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()->not_equals('Price', 0)->to_string();
 }
Ejemplo n.º 15
0
 public function delete($data)
 {
     $data = $this->process_data($data);
     $sql = new SQLBuilder($this->conn, $this->get_fully_qualified_table_name());
     $sql->delete($data);
     $values = $sql->bind_values();
     return $this->conn->query($this->last_sql = $sql->to_s(), $values);
 }
Ejemplo n.º 16
0
 */
include 'source/clientlogin.php';
include 'source/sql.php';
include 'source/connectioninfo.php';
function format_address($street, $city, $state, $zip)
{
    $result = str_replace(" ", "&nbsp;", $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">
 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();
 }
Ejemplo n.º 18
0
 public static function build(SQLBuilder $builder)
 {
     return $builder->execute();
 }
Ejemplo n.º 19
0
 /**
  * Find records in the database.
  *
  * Finding by the primary key:
  *
  * <code>
  * # queries for the model with id=123
  * YourModel::find(123);
  *
  * # queries for model with id in(1,2,3)
  * YourModel::find(1,2,3);
  *
  * # finding by pk accepts an options array
  * YourModel::find(123,array('order' => 'name desc'));
  * </code>
  *
  * Finding by using a conditions array:
  *
  * <code>
  * YourModel::find('first', array('conditions' => array('name=?','Tito'),
  *   'order' => 'name asc'))
  * YourModel::find('all', array('conditions' => 'amount > 3.14159265'));
  * YourModel::find('all', array('conditions' => array('id in(?)', array(1,2,3))));
  * </code>
  *
  * Finding by using a hash:
  *
  * <code>
  * YourModel::find(array('name' => 'Tito', 'id' => 1));
  * YourModel::find('first',array('name' => 'Tito', 'id' => 1));
  * YourModel::find('all',array('name' => 'Tito', 'id' => 1));
  * </code>
  *
  * An options array can take the following parameters:
  *
  * <ul>
  * <li><b>select:</b> A SQL fragment for what fields to return such as: '*', 'people.*', 'first_name, last_name, id'</li>
  * <li><b>joins:</b> A SQL join fragment such as: 'JOIN roles ON(roles.user_id=user.id)' or a named association on the model</li>
  * <li><b>include:</b> to do not implemented yet</li>
  * <li><b>conditions:</b> A SQL fragment such as: 'id=1', array('id=1'), array('name=? and id=?','Tito',1), array('name IN(?)', array('Tito','Bob')),
  * array('name' => 'Tito', 'id' => 1)</li>
  * <li><b>limit:</b> Number of records to limit the query to</li>
  * <li><b>offset:</b> The row offset to return results from for the query</li>
  * <li><b>order:</b> A SQL fragment for order such as: 'name asc', 'name asc, id desc'</li>
  * <li><b>readonly:</b> Return all the models in readonly mode</li>
  * <li><b>group:</b> A SQL group by fragment</li>
  * </ul>
  *
  * @throws {@link RecordNotFound} if no options are passed or finding by pk and no records matched
  * @return mixed An array of records found if doing a find_all otherwise a
  *   single Model object or null if it wasn't found. NULL is only return when
  *   doing a first/last find. If doing an all find and no records matched this
  *   will return an empty array.
  */
 public static function find()
 {
     $class = get_called_class();
     if (func_num_args() <= 0) {
         throw new RecordNotFound("Couldn't find {$class} without an ID");
     }
     $args = func_get_args();
     $options = static::extract_and_validate_options($args);
     $num_args = count($args);
     $single = true;
     if ($num_args > 0 && ($args[0] === 'all' || $args[0] === 'first' || $args[0] === 'last')) {
         switch ($args[0]) {
             case 'all':
                 $single = false;
                 break;
             case 'last':
                 if (!array_key_exists('order', $options)) {
                     $options['order'] = join(' DESC, ', static::table()->pk) . ' DESC';
                 } else {
                     $options['order'] = SQLBuilder::reverse_order($options['order']);
                 }
                 // fall thru
             // fall thru
             case 'first':
                 $options['limit'] = 1;
                 $options['offset'] = 0;
                 break;
         }
         $args = array_slice($args, 1);
         $num_args--;
     } elseif (1 === count($args) && 1 == $num_args) {
         $args = $args[0];
     }
     // anything left in $args is a find by pk
     if ($num_args > 0 && !isset($options['conditions'])) {
         return static::find_by_pk($args, $options);
     }
     $options['mapped_names'] = static::$alias_attribute;
     $list = static::table()->find($options);
     return $single ? !empty($list) ? $list[0] : null : $list;
 }
Ejemplo n.º 20
0
$error = "";
$repassword = true;
if ($v->fieldsExists()) {
    $repassword = $_POST["user_password"] == $_POST["user_repassword"];
    $email_available = Auth::user_exists($_POST["user_email"]) == 0;
    if (!$email_available) {
        $error = "E-Mail non disponible";
    } else {
        if (!$repassword) {
            $error = "Les mots de passe ne correspondent pas";
        } else {
            $error = "Champ(s) invalide(s)";
        }
    }
    if ($v->testAll() && $repassword && $email_available) {
        $statement = new SQLBuilder($_MYSQLI);
        $q = $statement->insertInto('user')->set($v->export($_MYSQLI, array("user_firstname", "user_lastname", "user_email", "user_schoolname"), array("user_photo_path" => "", "user_password" => Security::CryptPassword($_POST["user_password"]))))->build();
        $r = $_MYSQLI->query($q);
        Auth::login($_POST["user_email"], $_POST["user_password"]);
        header("Location: index.php");
        exit;
    }
}
?>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>QCManager</title>
		<link rel="stylesheet" type="text/css" href="css/auth.css">
Ejemplo n.º 21
0
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')));
 protected function createConditionsFromKeys(Model $model, $conditionKeys = array(), $valueKeys = array())
 {
     $conditionString = implode('_and_', $conditionKeys);
     $conditionValues = array_values($model->getValuesFor($valueKeys));
     // return null if all the foreign key values are null so that we don't try to do a query like "id is null"
     if (all(null, $conditionValues)) {
         return null;
     }
     $conditions = SQLBuilder::createConditionsFromUnderscoredString(Table::load(get_class($model))->conn, $conditionString, $conditionValues);
     # DO NOT CHANGE THE NEXT TWO LINES. add_condition operates on a reference and will screw options array up
     if (isset($this->options['conditions'])) {
         $optionsConditions = $this->options['conditions'];
     } else {
         $optionsConditions = array();
     }
     return Utils::addCondition($optionsConditions, $conditions);
 }
        }
    }
}
if ($error) {
    header("Location: 404.php");
    exit;
}
$_RULES = array("question_content" => Validation::$f->notEmpty_String, "question_type" => function ($d) {
    return $d == "checkbox" || $d == "radio";
}, "question_hint" => Validation::$f->String, "question_weight" => function ($d) {
    return is_numeric($d) && $d % 1 == 0 && $d >= 1 && $d <= 5;
});
$v = new Validation($_POST, array("question_content", "question_type", "question_hint", "question_weight"), $_RULES);
if ($own && Validation::Query($_POST, array("indexes", "correct_indexes", "labels")) && $v->fieldsExists()) {
    if ($v->testAll()) {
        $statement = new SQLBuilder($_MYSQLI);
        if ($new) {
            $q = $statement->insertInto('question')->set($v->export(null, array("question_content", "question_type", "question_hint", "question_weight"), array("question_questionnaire_id" => $_GET["qid"], "question_num" => $questionnaire->questionnaire_total_questions + 1)))->build();
            $_MYSQLI->query($q);
            $_GET["id"] = $_MYSQLI->insert_id;
        } else {
            $q = $statement->update('question')->set($v->export(null, array("question_content", "question_type", "question_hint", "question_weight")))->where("question_id", "=", $_GET["id"])->build();
            $_MYSQLI->query($q);
        }
        $insertions = array();
        $correct = array();
        $one_correct = false;
        foreach ($_POST["indexes"] as $k => $val) {
            $correct[$k] = in_array($val, $_POST["correct_indexes"]) ? 1 : 0;
        }
        foreach ($_POST["labels"] as $k => $lbl) {
</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>
Ejemplo n.º 25
0
<?php

include 'includes/clientlogin.php';
include 'includes/sql.php';
include 'includes/file.php';
echo "got here";
//get token
$token = ClientLogin::getAuthToken('*****@*****.**', 'Moloko6+7');
$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 />";
$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')));
$user = Auth::getUser();
$_RULES = array("user_firstname" => Validation::$f->notEmpty_String, "user_lastname" => Validation::$f->notEmpty_String, "user_email" => Validation::$f->Email, "user_schoolname" => Validation::$f->notEmpty_String);
$v = new Validation($_POST, array("user_firstname", "user_lastname", "user_email", "user_schoolname", "user_password", "user_repassword"), $_RULES);
if ($v->fieldsExists()) {
    $setrepassword = Validation::Query($_POST, array("user_password", "user_repassword"));
    $repassword = $setrepassword ? $_POST["user_password"] == $_POST["user_repassword"] : false;
    $email_available = Auth::user_exists($_POST["user_email"]) == 0 || $_POST["user_email"] == $user->user_email;
    if ($v->testAll() && $email_available) {
        $set = $v->export($_MYSQLI, array("user_firstname", "user_lastname", "user_email", "user_schoolname", "user_password"));
        if (false) {
            $set["user_photo_path"] = "";
        }
        if ($repassword) {
            $set["user_password"] = Security::CryptPassword($_POST["user_password"]);
        }
        $statement = new SQLBuilder($_MYSQLI);
        $q = $statement->update('user')->set($set)->where("user_id", "=", Auth::getUserId())->build();
        $r = $_MYSQLI->query($q);
    }
}
$user = Auth::getUser();
/*

$other_query_photo = 'SELECT user_photo_path
				FROM user
				WHERE user_id = '.Auth::getUserId();


$other_result_photo = $_MYSQLI->query($other_query_photo);

$row = $other_result_photo->fetch_object();*/
Ejemplo n.º 28
0
    header("Location: 404.php");
    exit;
}
$_RULES = array("questionnaire_title" => Validation::$f->notEmpty_String, "questionnaire_description" => Validation::$f->notEmpty_String, "questionnaire_start_date" => Validation::$f->datetime, "questionnaire_end_date" => Validation::$f->datetime);
$v = new Validation($_POST, array("questionnaire_title", "questionnaire_description", "questionnaire_start_date", "questionnaire_end_date"), $_RULES);
if ($v->fieldsExists()) {
    $startdate_instance = DateTime::createFromFormat('d/m/Y H:i', $_POST["questionnaire_start_date"]);
    $enddate_instance = DateTime::createFromFormat('d/m/Y H:i', $_POST["questionnaire_end_date"]);
    $datetimes = false;
    if ($startdate_instance instanceof DateTime && $enddate_instance instanceof DateTime) {
        $startdate = $startdate_instance->format('U');
        $enddate = $enddate_instance->format('U');
        $datetimes = $enddate > $startdate;
    }
    if ($v->testAll() && $datetimes) {
        $statement = new SQLBuilder($_MYSQLI);
        if ($new) {
            $inserted = true;
            $q = $statement->insertInto('questionnaire')->set($v->export(null, array("questionnaire_title", "questionnaire_description"), array("questionnaire_start_date" => $startdate, "questionnaire_end_date" => $enddate, "questionnaire_user_id" => Auth::getUserId())))->build();
            $_MYSQLI->query($q);
            echo "<html><head><title></title></head><body><script>parent.location.href='form.php?id=" . $_MYSQLI->insert_id . "';</script></body></html>";
            exit;
        } else {
            $q = $statement->update('questionnaire')->set($v->export(null, array("questionnaire_title", "questionnaire_description"), array("questionnaire_start_date" => $startdate, "questionnaire_end_date" => $enddate)))->where("questionnaire_id", "=", $_GET["id"])->build();
            $_MYSQLI->query($q);
            header("Location: frame_form_edit.php?refresh=true&id=" . $_GET["id"]);
            exit;
        }
    }
    if ($v->fail("questionnaire_title")) {
        echo "questionnaire_title fail";