private static function query($sql) { if (self::$debug) { tprintWarning($sql); } return self::$DB_CONN->query($sql); }
/** * @param \MySQLi $mysql * @param string $query */ public function __construct(\MySQLi $mysql, $query) { $this->mysql = $mysql; $qobject = $this->mysql->query($query); if (substr($query, 0, strlen('INSERT INTO')) == 'INSERT INTO' || substr($query, 0, strlen('DELETE FROM')) == 'DELETE FROM') { $this->data = false; } else { while ($dat = $qobject->fetch_assoc()) { $this->data[] = $dat; } $qobject->close(); } }
/** * 数据库查询函数 * * @param string $sql 查询语句 * @return mixed */ public static function query($sql) { $sql = trim($sql); if (self::$db == NULL) { self::_init_mysql(); } self::$mysqli_rst = self::$db->query($sql); if (FALSE == self::$mysqli_rst) { echo 'MySQL query errno : ' . self::$db->errno . PHP_EOL; $backtrace = debug_backtrace(); var_dump($backtrace); return FALSE; } else { return self::$mysqli_rst; } }
function query($req) { // Si c'est la première requête if ($this->reqcount == 0) { // on ititialise les paramètres $this->initParams(); } // On incrémente le compteur de requêtes $this->reqcount++; // Si la requête n'arrive pas à s'exécuter if (!($res = parent::query($req))) { // On commencer à mettre la sortie dans un buffer (ob = output buffer) ob_start(); // On affiche l'état de la pile d'appel (pour savoir pourquoi ça plante, d'uù le script est lancé) debug_print_backtrace(); // On écrit tout ça dans un fichier de logs "mysql_errors" avec la date, l'erreur, la requête SQL associée et l'état de la pile d'appel dans le buffer file_put_contents(FONCTIONS . "mysql_errors", date('[d/m/Y - H:i:s]') . ' Erreur MySQL : ' . $this->error . ' pendant la requête ' . $req . ' Backtrace: ' . ob_get_contents()); // On termine la capture de la sortie et on efface ce qu'on a enregistré ob_end_clean(); // Et on termine le script. die("Une erreur s'est produite: " . $this->error); } // Sinon, tout va bien, on renvoie le résultat. return $res; }
public function query($sSQL, $log = true) { $start = microtime(true); $this->connect(); // Increase the counter $this->query_counter++; $result = $this->connection->query(trim($sSQL)); $duration = microtime(true) - $start; if ($log) { $this->addQueryLog($sSQL, $duration); } if (!$result) { //var_dump (debug_backtrace ()); //$data = debug_backtrace (); //print_r ($data); echo $sSQL; throw new DbException('MySQL Error: ' . $this->connection->error); } elseif ($result instanceof MySQLi_Result) { return new Result($result); } // Insert ID will return zero if this query was not insert or update. $this->insert_id = intval($this->connection->insert_id); // Affected rows $this->affected_rows = intval($this->connection->affected_rows); if ($this->insert_id > 0) { return $this->insert_id; } if ($this->affected_rows > 0) { return $this->affected_rows; } return $result; }
/** * Performs a query on the database * * @param string $query * @param int $resultmode * @throws MySQLi\QueryException * @return bool */ public function query($query, $resultmode = \MYSQLI_STORE_RESULT) { if (($result = parent::query($query, $resultmode)) === false) { throw new \mysqli_sql_exception($this->error); } return $result; }
public function fetchRelatedObjectRefsOfEntity(MySQLi $mySQLi, ObjectEntity $otherEntity, QueryContext $queryContext, Scope $scope, array &$fetchedObjectRefs) { // Find the corresponding relationship, ignoring link-relationships. $hasTerminatedObjects = FALSE; foreach ($this->objectEntity->getRelationships() as $relationship) { if ($relationship->getOppositeEntity($this->objectEntity) != $otherEntity) { continue; } // Select the id of the related object. $objectIdColumnName = $otherEntity->getObjectIdColumnName(); $query = new QueryRelatedEntity($this->objectEntity, $this->id, $relationship, $queryContext, $scope); $query->setPropertyNames(array($objectIdColumnName)); $queryString = $query->getQueryString(); $queryResult = $mySQLi->query($queryString); if (!$queryResult) { throw new Exception("Error fetching ObjectRefs of entity '" . $otherEntity->getName() . "', associated to '" . $this->objectEntity->getName() . "[{$this->id}]' - " . $mySQLi->error . "\n<!--\n{$queryString}\n-->"); } while ($dbObject = $queryResult->fetch_assoc()) { $objectRef = new ObjectRef($otherEntity, $dbObject[$objectIdColumnName]); if (!$queryContext->getParameterPublished() and isset($dbObject[QueryEntity::ID_TERMINATED])) { $hasTerminatedObjects = TRUE; } else { // Always use the objectRef if we're fetching published data or if it's not terminated. $fetchedObjectRefs[] = $objectRef; } } $queryResult->close(); } return $hasTerminatedObjects; }
public function getServerVersion() { $res = $this->dbcon->query("SELECT version() AS `version`"); if (!$res || $res->num_rows == 0) { return '[not connected]'; } $row = $res->fetch_assoc(); return $row['version']; }
/** * Executes a query which returns rows. Use it with SELECT statements. * @param string $query * @return DatabaseResult|bool */ public function query($query) { $this->lastQuery = $query; $result = parent::query($query); if ($result) { return is_bool($result) ? $result : new DatabaseResult($result); } return FALSE; }
function evaluate($stu_answers, $studentid, $quizid) { // $myo = new MySQL(); $some = new MySQLi('localhost', 'root', 'root', 'codefundo'); $res = $some->query("SELECT * FROM answers") or die('fatal'); $res2 = $some->query("SELECT * FROM marks") or die('fatal'); // print_r($res2); $result = array(); $marks = array(); if ($res) { while ($s = $res->fetch_object()) { foreach ($s as $key => $value) { if ($s->{$key}) { $result[$key] = $value; } } } } if ($res2) { while ($s = $res2->fetch_object()) { foreach ($s as $key => $value) { if ($s->{$key}) { $marks[$key] = $value; } } } } unset($result['quizid']); $mark = 0; foreach ($stu_answers as $quesid => $ans) { if ($result[$quesid] == $ans) { $mark += $marks[$quesid]; } } // var_dump($mark); echo 'Score is:'; echo $mark; echo '<Br><a href="dash.php">Continue-></a>'; if ($myo->Update($quizid, array('marks' => $mark), array('student_id' => $studentid))) { print_r('Marks'); } else { die('fatal'); } }
/** * Sends the query to Sphinx * @param string $query The query string * @return array The result array * @throws Miaox_SphinxQl_Connection_Exception If the executed query produced an error */ public function query($query) { $this->connect(); $resource = $this->_driver->query($query); if ($this->_driver->error) { throw new Miaox_SphinxQl_Connection_Exception('[' . $this->_driver->errno . '] ' . $this->_driver->error . ' [ ' . $query . ']'); } if ($resource instanceof mysqli_result) { $rows = array(); while (!is_null($row = $resource->fetch_assoc())) { $rows[] = $row; } $resource->free_result(); $result = $rows; } else { // sphinxql doesn't return insert_id because we always have to point it out ourselves! $result = array($this->_driver->affected_rows); } return $result; }
public function query($sql, $errorLevel = E_USER_ERROR) { $this->beforeQuery($sql); // Benchmark query $handle = $this->dbConn->query($sql, MYSQLI_STORE_RESULT); if (!$handle || $this->dbConn->error) { $this->databaseError($this->getLastError(), $errorLevel, $sql); return null; } // Some non-select queries return true on success return new MySQLQuery($this, $handle); }
public function query($sql) { $resource = $this->link->query($sql); if ($this->link->errno) { trigger_error('Error: ' . $this->link->error . '<br />Error No: ' . $this->link->errno . '<br />' . $sql); die; } if ($resource instanceof mysqli_result) { $i = 0; $data = array(); while ($result = $resource->fetch_assoc()) { $data[$i] = $result; $i++; } $resource->free(); $query = new stdClass(); $query->row = isset($data[0]) ? $data[0] : array(); $query->rows = $data; $query->num_rows = $i; unset($data); return $query; } return $resource; }
/** * Execute a query and return a result object * * @param String $query The query to execute * @return \r8\iface\DB\Adapter\Result */ public function query($query) { if (!isset($this->link)) { $this->connect(); } $result = $this->link->query($query); if ($result === FALSE) { throw new \r8\Exception\DB\Query($query, $this->link->error, $this->link->errno); } if (\r8\DB\Link::isSelect($query)) { return new \r8\DB\Result\Read(new \r8\DB\MySQLi\Result($result), $query); } else { return new \r8\DB\Result\Write($this->link->affected_rows, $this->link->insert_id, $query); } }
/** * Create a new annotation * * @param Struct\Annotation $annotation * @return void */ public function create(Struct\Annotation $annotation) { $this->connection->query(sprintf(' INSERT INTO `annotation` VALUES ( null, "%s", %s, %s, "%s", "%s", "%s", null )', $this->connection->escape_string($annotation->file), (int) $annotation->line, (int) $annotation->character, $this->connection->escape_string($annotation->type), $this->connection->escape_string($annotation->class), $this->connection->escape_string($annotation->message))); }
/** * Execute supplied query on the database. * * If $resultMode is set to MYSQLI_USE_RESULT the next call to this function will automatically * free the last result to prevent errors. * * @param string $query Sql query * @param int $resultmode [optional] <p> * Either the constant <b>MYSQLI_USE_RESULT</b> or * <b>MYSQLI_STORE_RESULT</b> depending on the desired * behavior. By default, <b>MYSQLI_STORE_RESULT</b> is used. * See MySQLi::query for more details. * </p> * @return mysqli_result|boolean Results from query or false on error. */ public function query($query, $resultMode = MYSQLI_STORE_RESULT) { if ($this->lastResult !== null) { // @ -> In case it has already been called @$this->lastResult->free(); $this->lastResult = null; } $result = parent::query($query, $resultMode); if ($result) { if ($resultMode === MYSQLI_USE_RESULT) { $this->lastResult = $result; } } else { echo $this->error . PHP_EOL; } return $result; }
/** * @param String $query * @param bool $group * @return Array */ public function getData($query, $group = true) { $queryReturn = $this->MySQLi->query($query); $data = []; if (false != $queryReturn) { while ($fetched = $queryReturn->fetch_assoc()) { $data[] = $fetched; } if (count($data) == 1 && true == $group) { $data = $data[0]; } } if ([] == $data) { $data = null; } return $data; }
function wikipediaParse() { $result = MySQLi::query('SELECT * FROM `addr_countries`'); while ($row = $result->fetch_assoc()) { echo $row['name'] . '<br>'; $page = file_get_contents('https://ru.wikipedia.org/wiki/' . $row['name']); if ($page === false) { continue; } preg_match_all('/<img(?:\\s[^<>]*?)?\\bsrc\\s*=\\s*(?|"([^"]*)"|\'([^\']*)\'|([^<>\'"\\s]*))[^<>]*>/i', $page, $allTags); $i = 0; foreach ($allTags[0] as $val) { if (!empty($val) && strpos($val, 'Flag of')) { $begin = strpos($val, 'src="') + 5; $end = strpos($val, 'png"') + 3; $url = 'https:' . substr($val, $begin, $end - $begin); $img = './img/countriesFlags/' . $row['id'] . '.png'; file_put_contents($img, file_get_contents($url)); $i++; } else { if (!empty($val) && strpos($val, 'Coat of')) { $begin = strpos($val, 'src="') + 5; $end = strpos($val, 'png"') + 3; $url = 'https:' . substr($val, $begin, $end - $begin); $img = './img/countriesCoats/' . $row['id'] . '.png'; file_put_contents($img, file_get_contents($url)); $i++; } } if ($i == 2) { break; } } preg_match('/<td>[A-Z]{2}<\\/td>/', $page, $tmp); $iso = substr($tmp[0], 4, 2); preg_match('/<td>[A-Z]{3}<\\/td>/', $page, $tmp); $mok = substr($tmp[0], 4, 3); preg_match('/\\+[0-9]{1,5}</', $page, $tmp); $phone = substr($tmp[0], 1, strpos($tmp[0], '<') - 1); if (!$phone) { $phone = 0; } MySQLi::query('UPDATE `addr_countries` SET `iso` = \'' . MySQLi::checkString($iso) . '\', `mok` = \'' . MySQLi::checkString($mok) . '\', `flag` = \'' . $row['id'] . '.png\', `emplem` = \'' . $row['id'] . '.png\', `phone` = ' . $phone . ' WHERE `name` = \'' . MySQLi::checkString($row['name']) . '\''); } }
private function _validateMysqli($data) { $conn = new \MySQLi($data['db_hostname'], $data['db_username'], $data['db_password']); if ($conn->connect_error) { $conn->close(); return false; } else { // Try to create database, if doesn't exist $sql = "CREATE DATABASE IF NOT EXISTS " . $data['db_database']; if ($conn->query($sql) === false) { // Couldn't create it, just check if exists $sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '" . $data['db_database'] . "'"; if (!$conn->query($sql)->num_rows) { $conn->close(); return false; } } $conn->close(); return true; } }
/** * Executes the given SQL query on the database. If a SELECT, SHOW, * DESCRIBE, or EXPLAIN query is run, this function will return an * RPG_Database_Result instance. Otherwise, it will return a boolean * value, signifying whether the query succeeded or not. To apply the * current table prefix to a table, surround it with braces: * * {table_name} => `prefix_table_name` * * @param string $sql * @param mixed $bind Array of param_name => value. :param_name in the SQL * will be replaced by value. ?param_name in the SQL * will be replaced by the raw uncleansed value. For * simple queries, you can also skip the param_name * and mark your placeholders as :0, :1, etc. You can * also put a static value, which will be converted * into an array with one element. * @return boolean|RPG_Database_Result */ public function query($sql, $bind = array()) { if (is_string($bind) or is_numeric($bind)) { $bind = array($bind); } // only run through the replacements if things can be done if (!empty($bind) or strpos($sql, '{') !== false) { $sql = $this->_processReplacements($sql, $bind); } $before = microtime(true); $result = $this->_mysqli->query($sql); $time = round(microtime(true) - $before, 5); $this->_queryCount++; $this->_writeDebug($sql, $time); if ($result === false) { throw new RPG_Exception('MySQLi query error: [' . $this->errno() . '] ' . $this->error() . "\n\nSQL: " . $sql); } // wrap MySQLi_Result with RPG_Database_Result if ($result instanceof MySQLi_Result) { $result = new RPG_Database_Result($result); } return $result; }
public function query($q, $resultmode=MYSQLI_STORE_RESULT) { if($this->live_log) echo $this->highlight_query($q).$this->colors['after_q']; $before = microtime(true); $r = parent::query($q, $resultmode); $after = microtime(true); $info = $this->info; $w = parent::query("SHOW WARNINGS"); $warnings = array(); if($w) while($wr = $w->fetch_assoc) $warnings[] = $wr; $log = array( 'query' => $q, 'time' => $after - $before, 'info' => $info, 'info_arr' => self::parse_info($info), 'warnings' => $warnings, 'error' => $this->error, 'errno' => $this->errno, 'affected_rows' => $this->affected_rows, 'insert_id' => $this->insert_id, 'num_fields' => is_bool($r) ? 0 : $r->num_fields, 'num_rows' => is_bool($r) ? 0 : $r->num_rows, ); if($this->keep_log) $this->query_log[] = $log; if($this->live_log) { printf("%s%04fs, %s%s%s", $this->colors['before_info'], $log['time'], $info, $this->colors['after_info'], $this->colors['after_q']); foreach($warnings as $warn) { echo $this->colors['before_warn'] . "Level $warn[Level] warning: $warn[Message] ($warn[Code])". $this->colors['after_warn'] . $this->colors['after_q']; } } if($this->file_log) { $f = fopen($this->file_log, "a"); fputs($f, array_export($log, true) . ";\n"); fclose($f); } if($r) return $r; throw new Exception("Query failed. ".var_export($log, true)); }
/** * Retorna dados pela chave primária. * Se a chave primária é composta, há duas opções: * 1. Fornecer os valores correspondentes na ordem que os campos aparecem na tabela: * $table->getById(array(1, 'foo')); * 2. Fornecer um conjunto de chaves/valores com o nome dos campos> * $table->getById(array( * 'campo2' => 'foo', * 'campo1' => 1 * )); * * @param mixed $id : o valor da chave primária do registro desejado * @return Row|null */ public function getById($id) { $this->setupPrimaryKey(); $id = (array) $id; if (($countId = count($id)) != ($countPk = count($this->primaryKey))) { throw new Exception("A tabela {$this->name} possui {$countPk} campos em sua chave primária.\n O número de campos fornecidos para a busca foi {$countId}!"); } $sql = 'SELECT * FROM ' . $this->getName() . ' WHERE '; $fields = array(); // Caso 1 if (is_numeric(key($id))) { // Precisamos disso porque $this->primaryKey é um array 1-based foreach ($this->primaryKey as $col) { $fields[] = $col . ' = ?'; } } else { $keys = array_keys($id); $diff = array_diff($this->primaryKey, $keys); if (!empty($diff)) { $pkStr = join(', ', $this->primaryKey); $keysStr = join(', ', $keys); throw new Exception("A tabela {$this->name} tem chave primária composta pelos campos\n {$pkStr}. Os seguintes campos foram fornecidos: {$keysStr}"); } foreach ($keys as $col) { $fields[] = $col . ' = ?'; } } $sql .= join(' AND ', $fields); $this->driver->query($sql, array_values($id)); $data = $this->driver->fetchOne(); if ($data !== null) { return $this->doCreateRow($data, true); } else { return null; } }
<!DOCTYPE html> <html> <head> <title>Dashboard</title> <link href="build/css/metro.css" rel="stylesheet"> <link href="build/css/metro-icons.css" rel="stylesheet"> <link href="build/css/metro-responsive.css" rel="stylesheet"> <link href="build/css/metro-schemes.css" rel="stylesheet"> <script src="js/widgets/tile.js"></script> </head> <body> <?php $my = new MySQLi('localhost', 'root', 'root', 'codefundo'); $q = 'SELECT * FROM information_schema.tables WHERE table_schema="codefundo"'; $r = $my->query($q); $names = array(); $i = 1; if ($r) { // print_r('Working'); while ($s = $r->fetch_object()) { $names[$i++] = $s->TABLE_NAME; } } ?> <li><a href="test.php">+</a></li> <div class="tile-container bg-darkCobalt" style=""> <?php $i = 1;
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <link href="style.css" rel="stylesheet" type="text/css"> <?php $mysqli = new MySQLi('localhost', 'root', ''); $resultSet = $mysqli->query("SELECT * FROM users"); ?> </head> <body> <div class="room"> <div class="avatar"><br> <br> <br> <?php ?> <center>Brugernavn</center> </div> <div style="position:absolute; top:20px; left:0px;" class="chair"> </div> <div style="position:absolute; top:20px; left:55px;" class="chair"> </div> <div style="position:absolute; top:20px; left:110px;" class="chair"> </div> <div style="position:absolute; top:20px; left:165px;" class="chair"> </div>
/** * Database connection * * @param bool $persistent * @return object */ public function db_connect($persistent = FALSE) { // Do we have a socket path? if ($this->hostname[0] === '/') { $hostname = NULL; $port = NULL; $socket = $this->hostname; } else { // Persistent connection support was added in PHP 5.3.0 $hostname = $persistent === TRUE && is_php('5.3') ? 'p:' . $this->hostname : $this->hostname; $port = empty($this->port) ? NULL : $this->port; $socket = NULL; } $client_flags = $this->compress === TRUE ? MYSQLI_CLIENT_COMPRESS : 0; $this->_mysqli = mysqli_init(); $this->_mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); if (isset($this->stricton)) { if ($this->stricton) { $this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")'); } else { $this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( @@sql_mode, "STRICT_ALL_TABLES,", ""), ",STRICT_ALL_TABLES", ""), "STRICT_ALL_TABLES", ""), "STRICT_TRANS_TABLES,", ""), ",STRICT_TRANS_TABLES", ""), "STRICT_TRANS_TABLES", "")'); } } if (is_array($this->encrypt)) { $ssl = array(); empty($this->encrypt['ssl_key']) or $ssl['key'] = $this->encrypt['ssl_key']; empty($this->encrypt['ssl_cert']) or $ssl['cert'] = $this->encrypt['ssl_cert']; empty($this->encrypt['ssl_ca']) or $ssl['ca'] = $this->encrypt['ssl_ca']; empty($this->encrypt['ssl_capath']) or $ssl['capath'] = $this->encrypt['ssl_capath']; empty($this->encrypt['ssl_cipher']) or $ssl['cipher'] = $this->encrypt['ssl_cipher']; if (!empty($ssl)) { if (isset($this->encrypt['ssl_verify'])) { if ($this->encrypt['ssl_verify']) { defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT') && $this->_mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, TRUE); } elseif (defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')) { $this->_mysqli->options(MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT, TRUE); } } $client_flags |= MYSQLI_CLIENT_SSL; $this->_mysqli->ssl_set(isset($ssl['key']) ? $ssl['key'] : NULL, isset($ssl['cert']) ? $ssl['cert'] : NULL, isset($ssl['ca']) ? $ssl['ca'] : NULL, isset($ssl['capath']) ? $ssl['capath'] : NULL, isset($ssl['cipher']) ? $ssl['cipher'] : NULL); } } if (@$this->_mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags)) { // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails if ($client_flags & MYSQLI_CLIENT_SSL && version_compare($this->_mysqli->client_info, '5.7.3', '<=') && empty($this->_mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value)) { $this->_mysqli->close(); $message = 'MySQLi was configured for an SSL connection, but got an unencrypted connection instead!'; log_message('error', $message); return $this->db->db_debug ? $this->db->display_error($message, '', TRUE) : FALSE; } return $this->_mysqli; } return FALSE; }
<?php $mys = new MySQLi('localhost', 'root', 'root', 'codefundo'); $g = $_GET['pagekey']; $q = "SELECT * FROM code WHERE id=" . $g; $res = $mys->query($q) or die('fatal'); $result = array(); if ($res) { while ($s = $res->fetch_object()) { $result['title'] = $s->title; $result['stylesheet'] = $s->stylesheet; $result['body'] = $s->body; $result['script'] = $s->script; } } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"> <title>Interface Addition</title> <script type="text/javascript" src="script/jq.js"></script> <script type="text/javascript"> $(function(){ $('#works').click(function(){ var some = $('#shit option:selected').val(); if(some=="grader"){ $('#main').removeClass('hidden'); } }); var len = $('.main').children('input').length;
public function query($query, $resultmode = null) { $instance = Instrumentation::get_instance(); $retry_count = 0; while ($retry_count < MySQLi_perf::$deadlock_try_limit) { $query = $instance->instrument_query($query, $retry_count); $instance->increment('mysql_query_count', 1); $retry_count = 0; $instance->timer(); $r = parent::query($query, $resultmode); $time = $instance->timer(); $instance->increment('mysql_query_exec_time', $time); $instance->push_query_log($query, $time); // 1213 (ER_LOCK_DEADLOCK) Deadlock detected retry operation if (mysqli_errno($this) == 1213) { $instance->increment('mysql_deadlock_count', 1); ++$retry_count; continue; // loop to the start of the while loop } break; } return $r; }
<?php $dbcon = new MySQLi("localhost", "root", "", "duolextest"); if (isset($_POST['add_main_menu'])) { $menu_name = $_POST['menu_name']; $menu_link = $_POST['mn_link']; $sql = $dbcon->query("INSERT INTO mainadmin_menu(m_menu_name,m_menu_link) VALUES('{$menu_name}','{$menu_link}')"); } if (isset($_POST['add_sub_menu'])) { $parent = $_POST['parent']; $proname = $_POST['sub_menu_name']; $menu_link = $_POST['sub_menu_link']; $sql = $dbcon->query("INSERT INTO subadmin_menu(m_menu_id,s_menu_name,s_menu_link) VALUES('{$parent}','{$proname}','{$menu_link}')"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add Menu</title> <link rel="stylesheet" type="text/css" href="style.css" media="all" /> </head> <body> <div id="head"> <div class="wrap"><br /> </div> </div> <center> <pre> <form method="post"> <input type="text" placeholder="menu name :" name="menu name" /><br />
static function getLanguageList() { $result = MySQLi::query('SELECT * FROM `engine_lang` LIMIT 1'); $arr = array(); $t = $result->fetch_fields(); for ($i = 2; $i < count($t); $i++) { $arr[] = $t[$i]->name; } return $arr; }
echo "Bem-vindo a API do Sistema de Clientes"; }); # Função para obter dados da tabela 'cliente'... //$app->get('/clientes','authenticate',function(){ $app->get('/clientes', function () { # Variável que irá ser o retorno (pacote JSON)... $retorno = array(); # Abrir conexão com banco de dados... $conexao = new MySQLi("localhost", "root", "", "mg"); # Validar se houve conexão... if (!$conexao) { echo "Não foi possível se conectar ao banco de dados"; exit; } # Selecionar todos os cadastros da tabela 'cliente'... $registros = $conexao->query("SELECT * FROM tb_cliente"); # Transformando resultset em array, caso ache registros... if ($registros->num_rows > 0) { while ($cliente = $registros->fetch_array(MYSQL_BOTH)) { $registro = array('id' => $cliente["ID_CLI"], 'nome' => utf8_encode($cliente["NOME_CLI"]), 'fone' => $cliente["FONE1_CLI"], 'email' => $cliente["EMAIL_CLI"]); $retorno[] = $registro; } # Encerrar conexão... $conexao->close(); # Retornando o pacote (JSON)... //$retorno = json_encode(array('clientes'=>$retorno)); $retorno = json_encode($retorno); echo $retorno; } }); # Executar a API (deixá-la acessível)...