User Login

Please enter user name and password into following boxes!

If you are not registered yet, please click

Forget Password

If you forget your password, please click

sql

  • Managing Hierarchical Data in MySQL And Php

    We can Category Table CREATE TABLE category ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NULL, url VARCHAR(50) NULL, parent INT NULL, created_at TIMESTAMP NULL, updated_at TIMESTAMP NULL, deleted_at TIMESTAMP NULL, resim VARCHAR(255) NULL, kisaltma VARCHAR(255) NOT NULL, CONSTRAINT category_category_parent_fk FOREIGN KEY (parent) REFERENCES category (id) ON DELETE SET NULL ) ENGINE = InnoDB COLLATE = utf8_unicode_ci; CREATE INDEX category_category_parent_fk...Continue Reading

    Enable Sql Log in Laravel

    Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) { if (App::environment() == 'local') { Log::info($query->sql . ' Parameters: ' . serialize($query->bindings)); } });...Continue Reading

    MSSQL Server UTF-8 Connection in PHP

    We can connect msql server as follows: $serverName = "127.0.0.1"; $uid = "sa"; $pwd = "123456!"; $databaseName = "TEST"; $connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database" => $databaseName, "CharacterSet" => "UTF-8"); //Connect using SQL Server Authentication. $conn = sqlsrv_connect($serverName, $connectionInfo); $tsql = "SELECT * FROM fatura"; // Execute the query. $stmt = sqlsrv_query($conn, $tsql); $row = sqlsrv_fetch_array($stmt); if (stmt) { echo "Statement executed"; } else { echo "Error in statement execut...Continue Reading

    MappedBy in bi-directional @ManyToMany : what is the reason

    Question: 1. What is the reason for setting MappedBy in bidirectional many-to-many relationships? 2. When one table has significant amount of records, while other has a few, which side is better to put mappedBy Answer: It's actually a good question, and it helps to understand the concept of an "owning" entity. If you want to prevent both sides (in a bidirectional relationship) from having join tables, a good idea, then you need to have a mappedBy= element on one side. Whether or not there is a join table is controlled by the mappedBy="name" el...Continue Reading

    How To Enable Mysql Server Remote Access In Amazon EC2 Service?

    1. First of all, create a new mysql user: mysql -u root -p create user 'olyanren'@'%' identified by '123456'; grant all priviliges on *.* to 'olyanren'@'%' with grant option; Note: Change olyanren username and password 123456. Also note that don't delete single quotas. The key point is wildcard (%). By using wildcard, we give olyanren user an access right to connect from any host. After these steps, confirm if the new user olyanren has been created select user, host from mysql.user; 2) Restart mysql service mysqld restart ...

    Hibernate Unidirectional OneToMany and ManyToOne Concepts

    OneToMany Unidirectional Mapping Question: In this document (scroll down to the Unidirectional section): http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-mapping-association-collections It says that a unidirectional one-to-many association with a join table is much preferred to just using a foreign key column in the owned entity. My question is, why is it much preferred? Answer 1: Consider the situation where the owned entity type can also be owned by another parent entity type. Do you put foreign key refere...Continue Reading

    Spring Generic DAO And Generic Service Implementation

    For most developers, writing almost the same code for every DAO in an application has become indespensible. To solve this problem and to rescue developers from copying and pasting same codes into every dao classes, we will use DAO pattern. In this tutorial, I will show you how to create dao pattern in a spring application. The foundation of using a Generic DAO is the CRUD operations that you can perform on each entity. Generic Dao Implementation Model Class Hibernate ORM framework uses model classes for database tables. Therefore we need to creat...Continue Reading

    Change MySQL default character set to UTF-8

    To set the default to UTF-8, you want to add the following to my.cnf or my.ini for Windows [mysqld] collation-server = utf8_unicode_ci character-set-server = utf8 If you want to change the character set for an existing DB, you can use following code: ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci; ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;...Continue Reading