Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- New statement



  A trap in PDOStatement::bindParam

First, let's check out below codes: <?php $dbh = new PDO('mysql:host=localhost;dbname=test', "test"); $query = <<prepare($query); $bind_params = array(':username' => "laruence", ':password' => "weibo"); foreach( $bind_params as $key => $value ){ $statement->bindParam($key, $value); } $statement->execute(); What is the SQL executed finally? Is there any problem with above codes? Many people may think the query executed is : INSERT INTO `user` (`username`, `password...

   PHP,Trap,bindParam     2013-08-29 10:48:55

  How to optimize MySQL insert statement

For a big data system, one problem is the data access efficiency, one more problem is that the data insertion is very slow. We had a service system, the data loading process would take 4-5 hours. This time consuming operation is risky since if the program is interrupted during the loading process, it might be rerun, this will be troublesome. So it's necessary to improve the insertion efficiency for big data systems. Here we provide two optimization suggestions. 1. Combine multiple insert stateme...

   MySQL,insert,optimization     2012-10-24 22:03:13

  What can select do in GoLang

In Go language, select is a keyword used to listen to and perform IO operations related to channels. With the select statement, we can simultaneously listen to multiple channels and perform corresponding operations when any of the channels are ready. This article will summarize the common uses of the select statement and provide some considerations when using it. Basic syntax The basic syntax of the select statement is as follows: select { case <-channel1: // when channel1 has data to ...

   GOLANG,SELECT,USAGE,SYNTAX,TUTORIAL     2023-08-12 20:17:02

  Break down defer statements in GoLang

Basic Concepts What are the characteristics of the deferred statement defer in Go language? When is it usually used? The deferred statement(defer statement) in Go language has the following characteristics: Deferred Execution: Deferred statements are executed before the function containing them exits, regardless of whether the function returns normally or encounters an exception. Last In, First Out (LIFO): If there are multiple deferred statements, they are executed in the order of last in, f...

   DEFER,GOLANG     2024-02-10 21:56:10

  Using PHP sessions across subdomains

By default, PHP uses the 'PHPSESSID' cookie to propagate session data across multiple pages, and by default it uses the current top-level domain and subdomain in the cookie declaration. Example: www.domain.com The downside to this is that the session data can't travel with you to other subdomains. So if you started a session on www.domain.com, the session data would become unavailable on forums.domain.com. The solution is to change the domain PHP uses when it sets the 'PHPSESSID' cookie. ...

   PHP,Session,Subdomain,Availability     2011-12-25 02:36:25

  do {...} while (0) in macros

If you are a C programmer, you must be familiar with macros. They are powerful and can help you ease your work if used correctly. However, if you don't define macros carefully, they may bite you and drive you crazy. In many C programs, you may see a special macro definition which may seem not so straightforward. Here is one example: #define __set_task_state(tsk, state_value) \ do { (tsk)->state = (state_value); } while (0) There are many this kind of macros which uses do{...}while(0)...

   C,macro,C++     2014-01-23 07:16:13

  Why MySQL 8 drops support of query cache

Many of you may have heard or used MySQL's query cache, because it used to be a popular way to improve MySQL's performance. As an important feature for improving MySQL's performance, the query cache was often recommended as a solution for slow queries. However, why has MySQL 8 abandoned the query cache? Today, we will analyze and explore this decision. What is query cache? According to official document: The query cache stores the text of a SELECT statement together with the correspon...

   MYSQL 8,QUERY CACHE     2023-03-11 09:05:17

  Understand more about Go basics with one interview question

First, let's take a look at below Go interview question: package main const s = "Go101.org" // len(s) == 9 // 1 << 9 == 512 // 512 / 128 == 4 var a byte = 1 << len(s) / 128 var b byte = 1 << len(s[:]) / 128 func main() { println(a, b) } What would be the output in your mind? The output would be 4 0. Surprising? Before getting to the output values, some concepts in Go need to be introduced and explained in more detail. len()  len() is a built-in function in Go to get t...

   GOLANG,CONSTANT,SHIFT OPERATION,LEN()     2020-10-10 02:52:19

  try { return } finally {}

Do you know what value will be printed when following program is ran? class Test { public int aaa() { int x = 1; try { return ++x; } catch (Exception e) { } finally { ++x; } return x; } public static void main(String[] args) { Test t = new Test(); int y = t.aaa(); System.out.println(y); } } And before answering the above question, do you have answers to following questions? If ther...

   JAVA,JAVA INTERVIEW QUESTION     2016-09-26 08:06:28

  Why so many Python web frameworks?

When asked about the plethora of web frameworks for Python the answer is often that it is way too easy to put together one in Python. That certainly seems plausible since there are so many libraries that implement the components of a web framework and if it's easy to plug those pieces together then maybe that lowers the bar of entry for new frameworks. So let's give it a shot, we'll pick some components and spend a couple hours seeing how far we can get building a web framework, which we...

   Python,Web framework,Dynamic scripting language,Web design     2012-02-13 05:32:48