Doctrine ATTR_QUOTE_IDENTIFIER

`order` is mysql keyword. Thus if you use `order` table name with Doctrine, there will be error.
Next setting can solve this problem.

$bootstrap->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);

This Attribute help manipulate query like
“select id from order”
to
“select `id` from `order`”.

Advertisements

Jquery Object’s value to array

var idlist = $(‘input[name^=qty]’).map(function(){return $(this).attr(‘rel’);}).get();
var qtylist = $(‘input[name^=qty]’).map(function(){return $(this).val();}).get();

tag array sanitizing

$tagList = “tag1, , tag2, tag4 , , , , “;

function sanitizeTagList($tagList){
$rs = preg_replace(“/\s+/”,””,$tagList); // remove blank
$rs = explode(‘,’,$rs); // make string as array
$rs = array_unique($rs); // remove repeated tag
$rs = array_diff($rs,array(“”)); // remove “” element
return $rs;
}
$rs = sanitizeTagList($tagList);
// array(3) => {
[0] => “tag1”,
[1] => “tag2”,
[2] => “tag4”,
}

Doctrine sluggable

You can add next to BaseObject of Doctrine Model.

    public function setUp()
    {
        parent::setUp();
		$sluggable0 = new Doctrine_Template_Sluggable(array(
             'unique' => true,
             'fields' => 
        	     array(
            		0 => 'name',
             	 ),
             'canUpdate' => true,
             ));
        $this->actAs($sluggable0);                
    }

If
Name : about us
Then
Slug : about-us