Tutorial by Examples

Please read Preventing SQL injection with Parametrized Queries for a complete discussion of why prepared statements help you secure your SQL statements from SQL Injection attacks The $conn variable here is a MySQLi object. See MySQLi connect example for more details. For both examples, we assume t...
Giving this enumeration as Example: enum Compass { NORTH(0), EAST(90), SOUTH(180), WEST(270); private int degree; Compass(int deg){ degree = deg; } public int getDegree(){ return degree; } } In Java an enum class is like any other c...
The sum 1 + 2 + 3 + ... + n Simplifies to n(n+1) / 2. Notice that this quantity is Θ(n2). This shortcut arises frequently in the analysis of algorithms like insertion sort or selection sort. Numbers of the form n(n+1)/2 are called the triangular numbers.
The sum 20 + 21 + 22 + ... + 2n-1 simplifies to 2n - 1. This explains why the maximum value that can be stored in an unsigned 32-bit integer is 232 - 1.
The sum of the geometric series r0 + r1 + r2 + ... + rn-1 In the case where r ≠ 1, simplifies to (rn - 1) / (r - 1). If r < 1, this sum is bounded from above by 1 / (1 - r). If r = 1, this sum is rn.
In /res/values/strings.xml: <string-array name="spinner_options"> <item>Option 1</item> <item>Option 2</item> <item>Option 3</item> </string-array> In layout XML: <Spinner android:id="@+id/spinnerName" ...
Direct Download - download link CDN - get here Bower - bower install bootstrap [read] NPM - npm install bootstrap [read] Composer - composer require twbs/bootstrap [read] Customize - I you have your own config, you can customize here. Sass - For Sass related projects you may get it here. ...
How do you go about using an instance of a (possibly further) inherited generic type within a method declaration in the generic type itself being declared? This is one of the problems you will face when you dig a bit deeper into generics, but still a fairly common one. Assume we have a DataSeries&l...
apologies: since I don't know of a channel for discussing/providing feedback on requests for improvement, I'm going to put my question here. Please feel free to point out a better place for this! @DataTx states that this is "completely unclear, incomplete, or has severe formatting problems&quot...
A texture is a form of data storage that allows convenient access not just to particular data entries, but also to sample points mixing (interpolating) multiple entries together. In OpenGL textures can be used for many things, but most commonly it's mapping an image to a polygon (for example a tria...
To enable Second Level Caching for Hibernate in WildFly, add this property to your persistence.xml file: <property name="hibernate.cache.use_second_level_cache" value="true"/> You may also enable Query Caching with this property: <property name="hibernate.cache...
By default, Eloquent models expect for the primary key to be named 'id'. If that is not your case, you can change the name of your primary key by specifying the $primaryKey property. class Citizen extends Model { protected $primaryKey = 'socialSecurityNo'; // ... } Now, any Eloqu...
$user = User::find(1); $user->name = 'abc'; $user->save(); You can also update multiple attributes at once using update, which does not require using save afterwards: $user = User::find(1); $user->update(['name' => 'abc', 'location' => 'xyz']); You can also update a model(s)...
If you want to automatically throw an exception when searching for a record that isn't found on a modal, you can use either Vehicle::findOrFail(1); or Vehicle::where('make', 'ford')->firstOrFail(); If a record with the primary key of 1 is not found, a ModelNotFoundException is thrown. W...
DataObjects in SilverStripe represent a database table row. The fields in the model have magic methods that handle getting and setting data via their property names. Given we have a simple DataObject as an example: class Fruit extends DataObject { private static $db = ['Name' => 'Varchar'...
Assuming this HTML in the page: <body> <div id="myPage"> </div> </body> A view can be bound to it with: var MyPageView = Backbone.View.extend( { "el": "#myPage", "template": _.template( "<p>This is m...
initialize is called by Backbone right after a View is constructed. Optional parameters The initialize function receives any arguments passed to the view's constructor. Commonly, the options hash that is used to pass the view's default options: ['model', 'collection', 'el', 'id', 'attributes', 'c...
Most streams must be closed when you are done with them, otherwise you could introduce a memory leak or leave a file open. It is important that streams are closed even if an exception is thrown. Java SE 7 try(FileWriter fw = new FileWriter("outfilename"); BufferedWriter bw = new Buf...
You can install a gem from github or filesystem. If the gem has been checked out from git or somehow already on the file system, you could install it using gem install --local path_to_gem/filename.gem Installing gem from github. Download the sources from github mkdir newgem cd newgem git clon...
A Clojure function can be defined to take an arbitrary number of arguments, using the symbol & in its argument list. All remaining arguments are collected as a sequence. (defn sum [& args] (apply + args)) (defn sum-and-multiply [x & args] (* x (apply + args))) Calling: =&gt...

Page 460 of 1336