Tutorial by Examples

Similarly to the SimpleXML, you can use DOMDocument to parse XML from a string or from a XML file 1. From a string $doc = new DOMDocument(); $doc->loadXML($string); 2. From a file $doc = new DOMDocument(); $doc->load('books.xml');// use the actual file path. Absolute or relative Exa...
When you want to use user generated content in the SQL, it with done with parameters. For example for searching user with the name aminadav you should do: var username = 'aminadav'; var querystring = 'SELECT name, email from users where name = ?'; connection.query(querystring, [username], functi...
a. Running multiple queries at same time All queries in MySQL connection are done one after another. It means that if you want to do 10 queries and each query takes 2 seconds then it will take 20 seconds to complete whole execution. The solution is to create 10 connection and run each query in a di...
One of the easiest ways to connect to MySQL is by using mysql module. This module handles the connection between Node.js app and MySQL server. You can install it like any other module: npm install --save mysql Now you have to create a mysql connection, which you can later query. const mysql ...
You send the query as a string and in response callback with the answer is received. The callback gives you error, array of rows and fields. Each row contains all the column of the returned table. Here is a snippet for the following explanation. connection.query('SELECT name,email from users', fu...
Follow previous example of creating a seed. This example uses a MySQL Dump to seed a table in the project database. The table must be created before seeding. <?php use Illuminate\Database\Seeder; class UserTableSeeder extends Seeder { /** * Run the database seeds. * ...
git checkout --orphan new-orphan-branch The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits. source
You may define scripts in your package.json, for example: { "name": "your-package", "version": "1.0.0", "description": "", "main": "index.js", "author": "", "license": &qu...
Another example of "Hello World" style programs is FizzBuzz. This is one example of a FizzBuzz implementation. Very idiomatic Go in play here. package main // Simple fizzbuzz implementation import "fmt" func main() { for i := 1; i <= 100; i++ { s := &qu...
You can use a RecyclerView.ItemDecoration to put extra margins around each item in a RecyclerView. This can in some cases clean up both your adapter implementation and your item view XML. public class MyItemDecoration extends RecyclerView.ItemDecoration { private final int extraMargin; ...
You can use any element as an handle to drag another element around: <script> $(function() { $( "#draggable" ).draggable({ handle: ".handle" }); }); </script> <div id="draggable"> <span class="handle"&...
Once your setup.py is fully functional (see Introduction), it is very easy to upload your package to PyPI. Setup a .pypirc File This file stores logins and passwords to authenticate your accounts. It is typically stored in your home directory. # .pypirc file [distutils] index-servers = py...
Retrofit requests can be logged using an intercepter. There are several levels of detail available: NONE, BASIC, HEADERS, BODY. See Github project here. Add dependency to build.gradle: compile 'com.squareup.okhttp3:logging-interceptor:3.8.1' Add logging interceptor when creating Retrofit:...
MSDN: The return statement terminates execution of the method in which it appears and returns control to the calling method. It can also return an optional value. If the method is a void type, the return statement can be omitted. public int Sum(int valueA, int valueB) { return valueA +...
You can group multiple boolean logic statements within parenthesis in order to create a more complex logic evaluation, especially useful in if statements. if ((age >= 18 && height >= 5.11) || (status === 'royalty' && hasInvitation)) { console.log('You can enter our club'); ...
This magic method is called when user tries to invoke object as a function. Possible use cases may include some approaches like functional programming or some callbacks. class Invokable { /** * This method will be called if object will be executed like a function: * * $invo...
__call() and __callStatic() are called when somebody is calling nonexistent object method in object or static context. class Foo { /** * This method will be called when somebody will try to invoke a method in object * context, which does not exist, like: * * $foo->...
__sleep and __wakeup are methods that are related to the serialization process. serialize function checks if a class has a __sleep method. If so, it will be executed before any serialization. __sleep is supposed to return an array of the names of all variables of an object that should be serializ...
This method is called by var_dump() when dumping an object to get the properties that should be shown. If the method isn't defined on an object, then all public, protected and private properties will be shown. — PHP Manual class DeepThought { public function __debugInfo() { return...
__clone is invoked by use of the clone keyword. It is used to manipulate object state upon cloning, after the object has been actually cloned. class CloneableUser { public $name; public $lastName; /** * This method will be invoked by a clone operator and will prepend "C...

Page 174 of 1336