Jan 16 2010

Eklenti.org

Published by Root under About Me

Uzun zamandır eklenti.org ile ilgilenemiyordum. Evet artık hayatımdaki köklü değişikliklerden sonra bu sitem ile ilgili daha ayrıntılı ve köklü değişiklikler yapacağım.

Daha önce bir okurun özel mesajında belirttiği gibi bu siteyi tamamen türkçe ve özel paylaşımlar için ve yenilik amaçlı kodlar için kullanacağım. Bu araya kadar takip edenler için teşekkür ederim.

No responses yet

Apr 14 2009

How To Smarty Cache

Published by Root under Php, smarty

Ok. If you use smarty and some part of your web site are no need to uptime any time, we can use the Smarty cache.

But smarty cache is not usefull for big project. But you can use in very simple let’s start.

First Prepare script for smarty.

require ‘kernel/libs/Smarty.class.php’; // This is my smarty class.

$smarty = new Smarty; //

$smarty->caching = true;
$smarty->cache_dir
= "mycachedir/" where is cache?

Continue Reading »

2 responses so far

Feb 24 2009

Zend Cache with Zend Framework (Simple Function)

Published by Root under Php, programlama, zend

Ok. In my new project we have a lot of dymanic part. This part actually not up-to-date every time. (maybe one or two times in a day). If we use html for this part , we are so tried to update it. If we use sql all time (daily 2k+ visitor and growing) system to slow. And hero is come Zend Cache.

Zend Cache is very good for our job. We can use for it some part to cache. And other parts is dynamic.

This is our site (Plan :D ) // Ok i know this is table :P . But system is not.

No Cache Needed (logo)
Cache for 2 hours Cache for 10 minutes No Cache Needed
Cache for 1 day Cache for 1 Day
No Cache Needed Cache for 10 minutes No Cache Needed
No Cache Needed (down link,address,telephones)

Ok. There is very important. More user means more sql and more sql means more slow.

And answer is Zend: Here my function for zend cache.

Test on 1.7 framework.

Important PS: In my project (pls look) every work evalute in indexController class. You can write any where you needed.

Insert this code on your code. (i put this code indexController )

Continue Reading »

No responses yet

Feb 01 2009

We are in Mysql Speed Test (Myisam vs InnoDB)

Published by Root under Mysql, Php, programlama, zend

Ok. In present day, almost everybody have a web site. Actually many kind of web site is dynamic. I change my decision to mysql. (maybe later postgresql or another)

And in starting every kind of database fast and doing their job clearly. So time is past and past and past and past ……… Database will taked more data and getting slowly.

Ok. This article about myisam and innodb.
Test database 3300 unique data and i copy more and we have 217k data now. (Innodb and Myisam)

Test computer have (My old friend) 512 mb Ram, Centrino 2.0 GHZ (Pentium M). and a lot of process. (in web server we have a lot of process.)

Ok Let’s test. Not: Myisam hasn’t fulltext,index or nothing

First Test: Count to Data. (command base)

InnoDB: 15.14 second. (217536)
Myisam: 0 second (217536)

Second Test: Select * from tables limit 600,30

InnoDB: 0.14 second. (30)
Myisam: 0.06 second (30)

Third Test: Select * from tables order by RAND() limit 5;

InnoDB: 5.28 second. (5)
Myisam: 2.31 second (5)

Fourth Test: Select * from tables where column like “%yo%” limit 5;

InnoDB: 0.05 second. (5)
Myisam: 0.03 second (5)

This is done for now. Myisam id winner of speed test. ;) For now.


2 responses so far

Jan 20 2009

Sefurl with Zend Framework

Published by Root under Php, programlama, zend

Zend is very powerfull framework. We want to use some kind of big project but we have a problem.

Problem is; url sef link http://www.example.com/article/2009/06/sef-url-with-zend.html

But we want to: http://www.example.com/sef-url-with-zend.html
Ok; Everybody says “You can do it with Zend Router”, but how?

Answer:
You open index.php and insert

Zend gerçekten çok güçlü frameworktür. Bir çok büyük projede kullanabiliriz. Ama bildiğiniz üzere artık internette projelerden daha çok oluşturulan projelerin bilinirliği gereklidir. Bunun en önemli yollarından biride bildiğiniz üzere SEO çalışmalarıdır.

Bu seo çalışmalarının en önemli ayaklarından biride sef link dediğimiz olaydır. Bu kısım zendde açıkçası biraz daha zordur. Zend’e ait standart link yönlendirmesi controller/action/var1/value1 şeklindedir.

Fakat bizim yapmak istediğimiz olay http://www.example.com/sef-url-with-zend.html

Evet koltuklarımıza sıkıca tutunalım. İşte nasıl yapacağımız.

index.php dosyamızı açın ve aşağıdaki kodu eklenyiniz.

Continue Reading »

2 responses so far

Jan 13 2009

InnoDB vs MyISAM

Published by Root under Mysql, Php, programlama

On Internet most people use “MYISAM” storage engine. This engine is so good for web application. But we have a lot of alternative. This article has InnoDb and MyIsam engines.

InnoDB:

  1. Innodb has no Fulltext search. This one is very bad thing (I think).
  2. Innodb is powerfull. More secure for crash.
  3. Innodb has foreign keys. It ’s very good for programmers. (Maybe in future i write something)

MyISAM:

  1. It has full-text search.
  2. You can crash.
  3. It’s fast. Writing and reading faster than InnoDb.
  4. There is no Foreing keys.

Yeap. Most using engine. And most of script file has using Myisam engine.

İnternette tüm yapmış olduğumuz scriptler genel olarak myisam motoru üzerine yazılır. Aslında bir çok kullanıcı neden yada niçin diye kurcalamamasına rağmen bunu biraz açmak istedim.

InnoDB:

  1. InnoDB fulltext arama özelliğine sahip değil.
  2. Innodb çakılmalara karşı daha sağlam ve geri kurtarma performansı daha güçlü.
  3. Innodb “foreign keys” özelliğine sahip. Bir programcı için gerçekten çok güçlü özelliklere sahip.
  4. Azıcık yavaş çalışıyor.

MyISAM:

  1. Full text arama özelliği bulunmakta.
  2. Hızlı, Dezavantjı ise çakılma özelliği.
  3. Foreing keys özelliğine sahip değildir.

No responses yet

Sep 19 2008

How can add our excel files to mysql

Published by Root under Mysql, Php, excel, programlama

The scenario;

I have an excel list about our costumers info. So i want to add all excel data in to mysql.

First i must save excel (.csv) format. And open my php script. my php script;

[PHP]

$firstTakeAllData=file_get_contents($filenameofcvs);
$secondAddArray=explode(”n”,$firstTakeAllData);

foreach ($secondAddArray as $key=>$takeMyDataFor)
{
$mysqlData=explode(”;“,$takeMyDataFor);

mysql_query(’INSERT into mycostumer (name,surname,street,tel,email) values (”$mysqlData[0]“,”$mysqlData[1]“,”$mysqlData[2]“,”$mysqlData[3]“,”$mysqlData[4]“)’); // It’s good for one user but this a lot of query , you can do it in one query

}
[/PHP]

This is simple example. You can use any function for your demand.

Bazı projelerde müşterilerimiz bizden olabildiğince zorluk çıkarmak için elinden geleni ardına koymaz. Özellikle bazı istekleri bizi çileden çıkarır.

Mesela excel tablolarını siteye yüklememizi yada kendilerine göre özel tabloları sakin bir şekilde aktarmamızı rica ederler.Bilmedikleri bu işlemin bizi ne kadar deli edeceğidir. Bunun için sürekli kullandığımız kodlarımız olsada en basiti aşağıdaki yöntemdir.

İlk olarak excel tablomuzu, Virgül ile ayrılmış (.csv) formatına çeviriyoruz. Daha sonra ilgili kodumuzu parçalama bölümüne yani php kodumuza geliyor.

[PHP]

$tumdatalar=file_get_contents($csvdosyaadi);
$ilkarray=explode(”n”,$tumdatalar);

foreach ($ilkarrayas $anahtar=>$ozeldata)
{
$mysqlData=explode(”;“,$ozeldata);

mysql_query(’INSERT into musteriler (adi,soyadi,adres,tel,email) values (”$mysqlData[0]“,”$mysqlData[1]“,”$mysqlData[2]“,”$mysqlData[3]“,”$mysqlData[4]“)’); // Bu yüksek miktarda sql sorgusu içerebilir, tek bir sorgudada halledebilirsiniz.

}
[/PHP]

Bu fonksiyonu kendinize göre ayarlayabilirsiniz.

No responses yet

Sep 19 2008

Create random password in mysql

Published by Root under Mysql, Php, programlama

The scenario;

I coded my script but i want to change password with mysql. (Maybe want to change a lot row). My password length have 8 character.

[MYSQL]

UPDATE mycostumerdata SET password=SUBSTRING(MD5(ROUND(RAND(9999)*1000)),1,8)
[/MYSQL]

You can add any coloum for better random password.

Web sitesi programlaması yaparken bazen eski veritabanlarımızdan yararlanabiliriz. Bu kayıtlarımıza ait şifreleri yeniden oluşturmak bazen düşündüğümüzden daha zor olabilir. Özellikle kodu bir script dilinde yazıyorsak işimiz biraz daha zahmetli oluyor.

Bunun yanında işi biraz daha garipleştirmek adına rastgele şifre oluşturma işimizi tamamiyle mysql’e verebiliriz. Bizde bu arada tatlı sıcak bir kahve alıp tüm işlemi yapan mysql ‘i seyredebiliriz.

[MYSQL]

UPDATE musteriBilgileri SET sifre=SUBSTRING(MD5(ROUND(RAND(9999)*1000)),1,8)
[/MYSQL]

Kodumuzu geliştirmek elinizde. Üstelik hızlıdır.

No responses yet

Sep 18 2008

How can cyrpto my old coloum

Published by Root under Mysql

The scenario;

I have a costumer database. And they are login my simple application. But i want to security to passwords.

[MYSQL]

UPDATE mycostumerdata SET password=MD5(SHA1(MD5(password)))

[/MYSQL]

If you want more, you add php code md5() or sha() to user id and mysql query add md5(userid). There is no chance to pass in with sql injection

Change it to yourself.

Çoğu projede başımıza gelen olaylardan biri ham şekilde duran şifreleri nispeten daha güvenli bir hale getirmek için datalarımızı md5 yada sha1 uygulamaları ile şifreleriz. Bu şifreleme metotları her ne kadar eskide kalmışta olsalar yinede güçlü algoritmalardır.

Bu algoritmaları 1 milyon ve üzeri kaydı tek seferde çevirmek için aşağıdaki kodu kullanabiliriz.

[MYSQL]

UPDATE elemanTablosu SET sifre=MD5(SHA1(MD5(sifre)))

[/MYSQL]

İlgili kodunuzu daha güvenli hala getirmek için giriş kodlarınızada md5 şifrelemesini kullanabilirsiniz.

No responses yet

Sep 16 2008

How can update my record with another record?

Published by Root under Mysql, simple, starter

The scenario;

I have a lot of records on my test table. And costumer want to “Need a order by manualy”. So i want to update my table and set new order value. The new order value is old id value.

Here is code;
[MYSQL]

UPDATE Mytable SET ordervalue = oldid

[/MYSQL]

Bir Arkadaşım kendisine ait bir veritabanında yeni bir alan açmak istediğini ve bu alana id alanını kopyalayarak hızlı bir şekilde sıralama yapmak istediğini belirtti. Bunun için gerekli kod aşağıdadır.

[MYSQL]

UPDATE TabloAdim SET yenieklenecekler =eskieklenmisler;

[/MYSQL]

No responses yet

Next »