I just got decided, even if there are very few people reading this blog, I want to use it more, and post about things.
What would be changed? 1. The design, I want to make a design inspired in Half Life game, and with better layout, to find place for everything. 2. Change the blog system that I'm using right now, and use something like Wordpress for a better editor and widgets support. 3. Keep posting whenever I feel to and about what I want, and try to do it more often.
I have just got the first Yii Framework book named 'Agile Web Application Development with Yii' and I'm going to read it all to see how it can improve my development skills, and then I'll write a little review here about it.
There is a free chapter available if you want to take a look:
Until about last year I have been developing my PHP projects without the support of a framework, then I have started to test some of them, Symfony, CodeIgniter, CakePHP and Yii, I have tried to get started with one of this frameworks and I don't subestimate any of them but I found it easier to start with Yii, and I liked it.
I have learned Yii from the online guide and from the blog tutorial, and ofcourse by applying it to a couple of projects during this year. I feel that I am missing some tricks that this framework has and I hope I'll find some in this book! :)
If you use PDO bindParam to do a search with a LIKE condition you cannot put the percentages and quotes to the param placeholder '%:keyword%'.
This is WRONG: "SELECT * FROM `users` WHERE `firstname` LIKE '%:keyword%'";
The CORRECT solution is to leave clean the placeholder like this: "SELECT * FROM `users` WHERE `firstname` LIKE :keyword";
And then add the percentages to the php variable where you store the keyword: $keyword = "%".$keyword."%";
And finally the quotes will be automatically added by PDO when executing the query so you don't have to worry about them.
So the full example would be: <?php // Get the keyword from query string $keyword = $_GET['keyword']; // Prepare the command $sth = $dbh->prepare('SELECT * FROM `users` WHERE `firstname` LIKE :keyword'); // Put the percentage sing on the keyword $keyword = "%".$keyword."%"; // Bind the parameter $sth->bindParam(':keyword', $keyword, PDO::PARAM_STR); ?>
The project I've started a while a go, about a website where to say your opinion about what bothers you, is now alive again, I have just set it up on the new domain and I hope people will start to use it more!
It results that the motherboard of my friend's computer has a bug and then the BIOS writes a copy on the hard disk and then it hides that part using HPA.
There are tools like HDAT2 that allow you to remove the HPA setting and reset the drive's space without losing anything, atleast I did not lost a file.
I'm going to write a fragment here from a blog post:
--- BLOG POST ---
Do you have a Gigabyte motherboard with Xpress Recovery BIOS?
If
so, then the BIOS has truncated the drive after backing up a copy of
itself to a small HPA (approximately 2000 sectors) at the top end of the
drive.
GDB is detecting the correct partition size from the
partition table in sector 0.
The reason the drive is reporting
33MB is that Gigabyte's BIOS has a bug that incorrectly adjusts the
drive's capacity after creating the HPA. 1TB drives are reduced to 33MB,
1.5TB become 500GB, and 2TB become 1TB.
The solution is to use a
tool such as HDAT2 or the HDD Capacity Restore Tool to remove the HPA
(Host Protected Area).
I want to introduce you a simple tool for updating the mySQL database of your PHP project. I'll explain how it works, it is dedicated to the developers so they can share the updates between them without much headache.
I'll write a case here about how it's ment to work. Let's sopose you are working also with a version control system like SVN, when you make changes to your database, you run queries on a desktop mysql client or an online one like phpMyAdmin, after that you copy the code you just executed and then save it to a sql file, and send it to other developers and tell them to use it to update their database.
So, this way, you must let them know about your changes and they must remember to run the sql file on their machine or otherwise the application can complain about missing tables or fields in the database.
With this tool what you accomplish is that you still have to manually save the changes into a sql file but when you commit it to subversion and the other developers download it on their machine, then the next move they make in the application it will automatically read the sql file and update the database before any other action. And also, the changes from other developers will be automatically updated on your local database after you download the new code from SVN.
Okay, so now I'll explain how to configure it, it's a single PHP class that must be included and run at the top of every page of your application.
This is an example about how you must use it, place this inside a file that you run when you initializate your application:
<?php
# Include the script. include_once('AutoDbUp.php');
# Load the script and specify the path where all sql files are saved, # the files inside that directory must contain numeric names and increasing # that will be the revision number of your database, example: # 1.sql, 2.sql, 3.sql, 4.sql, 5.sql and so on, for each update you make. $autoDbUp = new AutoDbUp('path/to/sql/files');
# Run the script's upgrade method to search all the new sql files and run them. $autoDbUp->upgrade();
?>
For the correct working of this script, you will have to customize some methods inside the class to make them compatible with your application, because the tool checks the version of your database and after running one sql file it updates that version to the new one, some of the functions that need to be customized are the followng:
getDbVer() - Command that consults your configuration table and retrieves the current database version, you can also make it write the current version number to a file instead of saving it in a table.
updateDbVer - Updates the database version after an sql file has been succesfully executed.
dbQuery() and getMysqlError() - Change this two if you have your own database class for mysql, and also check the last functions that BEGIN, ROLLBACK, and COMMIT a mysql transaction if you need to change them.
El proyecto Home Of Projects ha sido elegido en la lista de votación de BBVA y puede ganar la subvencion de desarollo! Por favor hagan su voto a continuación!
Home Of Projects has been approved on the BBVA project voting list and we can win the development subvention! Please vote below!