Category Archives: Technology
How TO Install GoDaddy Wild Card SSL Certificate
This article presumes that you have already downloaded the wild card certificate after generating the private key and csr request. GoDaddy gives you two files: gd_bundle.crt yourdomain.com.crt Step 1. change httpd.conf file to create a virtualhost for https at port … Continue reading
scp command in linux to transfer files from one server to another
To transfer your files from one server to another use following command set. login to the server to which you have to copy the files(i.e. destination server) scp user1@server1:/full/path/to/source/file . Press enter it ll ask for the source server password.Provide … Continue reading
How to implement self signed SSL certificate in websites
Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems.The Secure Socket Layer(SSL) is used to encrypt the data stream … Continue reading
Mysqldump on linux
Hi I am storing few linux commands for my own reference. 1) create tar file tar -cvf destination_folder_name source v indicates verbose. 2) mysql dump / mysql back up The most simple way is to issue this command: mysqldump -u … Continue reading
Few PHP 5.3 Presentations & RegX Cheat Sheet I Liked
I happen to find these while reading/surfing, so thought of putting it here …. I would be adding more to this post ….
[pdf http://www.decentmind.com/wp-content/uploads/2011/01/php5.3.pdf ]
regular-expressions-cheat-sheet-v2.pdf
Courtesy: [http://ebookchoice.net/php-5-3-awesome.html#]
-deepak Continue reading
Use Javascript/JQuery to Rewrite Amazon Affiliate Links
Just put following javascript at the bottom of the html page on which you would like to re-write/add the Amazon Affiliate ID to all amazon products.
What it simply does is, searches for “tag” in the url and adds the affiliate id to it.
<script type="text/javascript"> $(document).ready(function() { $('a[href*="amazon.com"]').each(function() { this.href = this.href.replace(/\?.*$/,"") + $.query.load(this.href).set("tag","Your-Affiliate-Id").toString();}); }); </script>
NOTE: Don’t forget add following jquery plugin JS in the header section of your page
As this code chunk is based on jQuery you have to include jQuery library as well on the top. Continue reading
Doctrine: Magic Finders
Doctrine offers some magic finders for your Doctrine models that allow you to find a record by any column that is present in the model. This is helpful for simply finding a user by their username, or finding a group by the name of it. Normally this would require writing a Doctrine_Query instance and storing this somewhere so it can be reused. That is no longer needed for simple situations like that.
The basic pattern for the finder methods are as follows: findBy%s($value) or findOneBy%s($value). The %s can be a column name or a relation alias. If you give a column name you must give the value you are looking for. If you specify a relationship alias, you can either pass an instance of the relation class to find, or give the actual primary key value.
First lets retrieve the UserTable instance to work with:
// test.php
// …
$userTable = Doctrine_Core::getTable(‘User’);
Now we can easily find a User record by its primary key by using the find() method:
// test.php
// …
$user = $userTable->find(1);
Now if you want to find a single user by their username you can use the following magic finder:
// test.php
// …
$user = $userTable->findOneByUsername(‘jonwage’);
You can also easily find records by using the relationships between records. Because User has many Phonenumbers we can find those Phonenumbers by passing the findBy**() method a User instance: Continue reading
Doctrine ORM : Transitive Persistence
Transitive Persistence
Doctrine offers both database and application level cascading operations. This section will explain in detail how to setup both application and database level cascades.
Application-Level Cascades
Since it can be quite cumbersome to save and delete individual objects, especially if you deal with an object graph, Doctrine provides application-level cascading of operations.
Save Cascades
You may already have noticed that save() operations are already cascaded to associated objects by default.
Delete Cascades
Doctrine provides a second application-level cascade style: delete. Unlike the save() cascade, the delete cascade needs to be turned on explicitly as can be seen in the following code snippet:
// models/User.php
class User extends BaseUser
{
// …
public function setUp()
{
parent::setup();
// …
$this->hasMany(‘Address as Addresses’, array(
‘local’ => ‘id’,
‘foreign’ => ‘user_id’,
‘cascade’ => array(‘delete’)
)
);
}
}
Here is the same example in YAML format. You can read more about YAML in the YAML Schema Files chapter:
—
# schema.yml
# …
User:
# …
relations:
# …
Addresses:
class: Address
local: id
foreign: user_id
cascade: [delete]
The cascade option is used to specify the operations that are cascaded to the related objects on the application-level.
lease note that the only currently supported value is delete, more options will be added in future releases of Doctrine.
In the example above, Doctrine would cascade the deletion of a User to it’s associated Addresses. The following describes the generic procedure when you delete a record through $record->delete():
1. Doctrine looks at the relations to see if there are any deletion cascades it needs to apply. If there are no deletion cascades, go to 3).
2. For each relation that has a delete cascade specified, Doctrine verifies that the objects that are the target of the cascade are loaded. That usually means that Doctrine fetches the related objects from the database if they’re not yet loaded.(Exception: many-valued associations are always re-fetched from the database, to make sure all objects are loaded). For each associated object, proceed with step 1).
3. Doctrine orders all deletions and executes them in the most efficient way, maintaining referential integrity.
From this description one thing should be instantly clear: Application-level cascades happen on the object-level, meaning operations are cascaded from one object to another and in order to do that the participating objects need to be available.
This has some important implications:
Application-level delete cascades don’t perform well on many-valued associations when there are a lot of objects in the related collection (that is because they need to be fetched from the database, the actual deletion is pretty efficient).
Application-level delete cascades do not skip the object lifecycle as database-level cascades do (see next chapter). Therefore all registered event listeners and other callback methods are properly executed in an application-level cascade.
Database-Level Cascades
Some cascading operations can be done much more efficiently at the database level. The best example is the delete cascade.
Database-level delete cascades are generally preferrable over application-level delete cascades except:
Your database does not support database-level cascades (i.e. when using MySql with MYISAM tables).
You have listeners that listen on the object lifecycle and you want them to get invoked.
Database-level delete cascades are applied on the foreign key constraint. Therefore they’re specified on that side of the relation that owns the foreign key. Picking up the example from above, the definition of a database-level cascade would look as follows:
// models/Address.php
class Address extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn(‘user_id’, ‘integer’);
$this->hasColumn(‘address’, ‘string’, 255);
$this->hasColumn(‘country’, ‘string’, 255);
$this->hasColumn(‘city’, ‘string’, 255);
$this->hasColumn(‘state’, ‘string’, 2);
$this->hasColumn(‘postal_code’, ‘string’, 25);
}
public function setUp()
{
$this->hasOne(‘User’, array(
‘local’ => ‘user_id’,
‘foreign’ => ‘id’,
‘onDelete’ => ‘CASCADE’
)
);
}
}
Here is the same example in YAML format. You can read more about YAML in the YAML Schema Files chapter:
—
# schema.yml
# …
Address:
columns:
user_id: integer
address: string(255)
country: string(255)
city: string(255)
state: string(2)
postal_code: string(25)
relations:
User:
local: user_id
foreign: id
onDelete: CASCADE
The onDelete option is translated to proper DDL/DML statements when Doctrine creates your tables.
Note that ‘onDelete’ => ‘CASCADE’ is specified on the Address class, since the Address owns the foreign key (user_id) and database-level cascades are applied on the foreign key.
Currently, the only two supported database-level cascade styles are for onDelete and onUpdate. Both are specified on the side that owns the foreign key and applied to your database schema when Doctrine creates your tables. Continue reading
Symfony Exceptions
In case of error or unauthorized access to, for example, it makes sense to throw an exception. In order to react to the error conditions better, should throw it back on the correct type of the exception and not always … Continue reading
symfony form field without a label
I was standing in front of the problem that I have a form with only one field. In this case the label of the field has shown no sense. For this reason, it had gone – but how? The solution … Continue reading


