What is schema.org?

This seems like a really cool collaborative idea between the big search engine companies.

From the schema.org website “Search engines including Bing, Google and Yahoo! rely on this markup to improve the display of search results, making it easier for people to find the right web pages.”

I think it is worth keeping an eye out for ways to incorporate this into future projects.

Meditating on scripture

The Bible tells us to meditate on the word and sometimes a passage stands out to us and we just don’t know what it means. That was the case when I read Mark 13:27

Mark 13:27
New International Version (NIV)
And he will send his angels and gather his elect from the four winds, from the ends of the earth to the ends of the heavens.from Bible Gateway

So I’m curious to know what they mean with “to the ends of the heavens”.

Will be worth reading it in context though, but if anybody has some thoughts let me know.

AJAX logout problem in WordPress using wp-postviews plugin

Been working on a site and we’ve had a random/frequent problems where the user gets logged out. It mostly got triggered by AJAX calls and once the page was refreshed the user was logged out.
We narrowed it down to be caused by the wp-postviews plug-in and all I did was add the following line at the top of the plug-in’s page (/wp-content/plugins/post-views/post-views.php)

if (defined('DOING_AJAX')) return;

And made sure that the PHP files that are called by AJAX has the following at the top of the page

define('DOING_AJAX', true);

It is worth noting that this is only necessary if you requiring something like the wp-load.php file to load WordPress functionality.

Don’t feel alone like a desolate tree

You see a lonely tree in the middle of nowhere and it seems a bit desolate and lonely. I guess we all can go through seasons like that, where we feel. Well looking at my life I would like to disagree, just as that tree is in the open and can receive light from all angles without any obstruction so I was able to receive God from all angles without being worried about things interfering.

If it weren’t for those times I wouldn’t of had gotten an understanding of His love and grace and the plans He had for me.

We sometimes need things to be removed from our sight to realise that we actually have a very good view.

We can’t pull it off by ourselves

I had to smile when I read the message version of Mark 10:27

Mark 10:27
The Message (MSG)
Jesus was blunt: “No chance at all if you think you can pull it off by yourself. Every chance in the world if you let God do it.” from Bible Gateway

It just reminded me of an earlier post and just wanted to say that God can really surprise us sometimes. I’ve found myself moving through impossibilities that previously was really impossible, but how God did it is the amazing part. He just started helping me little by little and all of a sudden I look back and see that the impossible has become possible through our God.

I think that one of the main breakthroughs for me has been how God has broken down my fears and shown me that they are nothing more than lies from the enemy.

Thank you Jesus for this awesome scripture!

Bake a simple CRUD interface from a database using CakePHP on XAMPP in Windows

 Introduction

I recently started playing with CakePHP to see what it can do. I decided to put my findings in a tutorial. I will use the ‘Interactive Bake Shell’ feature that comes natively with CakePHP.

Why is this helpful? Well by only populating the database structures (tables and fields) you will be able to use bake to setup all the required files related to the MVC (Model-View-Controller) structures to get a simple CRUD (Create, Read, Update, Delete or similarly Add, View, Edit, Remove) in the CakePHP framework.

Before we start

  • I’m assuming you have xampp for windows installed and know the location of your ‘php’ and ‘htdocs’ folders. (In my case ‘d:\xampp\php\’ and ‘d:\xampp\htdocs\’).
  • You’ve downloaded a copy of CakePHP (At least version 2.0.0 as of the writing of this post)
  • I don’t make use of any IDE in this tutorial as there is no need to, but you might want to use your favourite one to modify any of the files afterwards.
  • Know how to use and access the command prompt window (basically go to ‘start’ and type/run ‘cmd’).
  • I don’t give any background introduction to CakePHP or the MVC Process.

Ready?

So we are about to start. There are 3 easy steps to get our CRUD interface up and running. First we’ll setup our database with the table and fields we want to be used as objects. Then we’ll copy the CakePHP installion files and then lastly we’ll go through the command prompt process to run the ‘Interactive Bake Shell’ to generate the ‘.php’ and ‘.cpt’ files in the related ‘app\Model\’, ‘app\View\’ and ‘app\Controller\’ folders.

Step 1 – Import Database

In this example I have a database called ‘bake_test’ and the table we are going to create is called ‘books’. You can use the following SQL code to import the database structure.

CREATE TABLE IF NOT EXISTS `books` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`Author` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`Title` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`Desc` text COLLATE utf8_unicode_ci,
`Date` DATE DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=0 ;

Step 2 – Setup Files

Create a folder called ‘cakePHP_baketest’ in your ‘xampp/htdocs/’ folder and copy your downlaoded CakePHP files into this directory.

 

Step 3 – Run bake through command prompt

Now we are going to run bake to generate the Models, Views and Controllers for our web application. I found this blog post and did the following:

Open the command prompt window and do the following:

  1. Change the directory to your ‘xampp\php’ folder (in my case ‘d:\xampp\php’).
  2. Run php.exe with the location of your cake console file (in my case I typed the following ‘php.exe d:\xampp\htdocs\cakePHP_baketest\app\Console\cake.php bake’) (Note: ‘d:\xampp\htdocs\cakePHP_baketest’ is where we copied our CakePHP framework earlier).
  3. If everything is working correctly you will be shown a welcome screen and asked to setup a configuration file to connect to the database.

Follow the prompts and enter the realted database details like username, password, database etc. If it is a default xampp installation you’ll be able to use the same details as above, taking note that the password field is blank (i.e. ”).

After verifying that everything is ok, typing ‘y’ and pressing the enter key you’ll see a message that the file was created successfully and it will display the location of the ‘database.php’ file.

Then you will be presented by an ‘Interactive Bake Shell’ screen. The first option ([D]atabase Configuration) is what we just did so we can continue to the second option to create the models. Press ‘m’ and then the enter key. Seeing as we only have one table in our database we only have one Model option. Press ’1′ and then the enter key.

The bake script is unable to detect the ‘displayField’ so you are prompted to select it manually. In this case I selected ’3′ (Author). You can also add validation criteria to your forms so press ‘y’ and then the enter key to continue.

The script will go through all the fields and then ask you to select what kind of validation you want to do. I’ve just selected ’21′ (Not Empty) for the ‘id’, ‘Author’ and ‘Title’, but you can be adventurous if you want to try something different.

As you go through the different fields also note that you can add multiple validations, but for simplicity I would suggest keeping it to one validation for now as some combinations will require you to edit the php files afterwards (like max/minlength).

You’ll be prompted to confirm that everything looks ok.

You’ll get a confirmation message showing where the Model and related files are generated. Then the ‘Interactive Bake Shell’ menu will appear again and this time we have to create the controllers, so select ‘c’ and then press the enter key. We have to do controllers before views because the views are dependant on the controller files. Maybe the order should of been MCV, but then it might confuse Red Alert players (MCV = Mobile Construction Vehicle) :)

Follow the prompts as above and there are some other features we not touching on now, like:

  1. scaffolding
  2. using components
  3. adding extra helpers
  4. additional admin controls (for admin views to be defined later)

Once you done with baking the controller a message will appear to show where the files have been generated.

Ok, so 2 down and 1 more to go. We only have to run the script to generate the Views then we are done. Press ‘v’ and then the enter key to start the process.

Follow the prompts as above again to go through the steps. Once again we are taking the short route and skipping things like:

  1. admin routing

Ok, so now we are done creating the files and we can now press ‘q’ and then the enter key to close the command prompt.

Open your browser and navigate to ‘http://localhost/cakePHP_baketest/books’ and you’ll see a screen similar to the one above. From here you can navigate to differnet screens from adding, editing, viewing and deleting book objects.

Have fun and thanks for reading! Some more screenshots below.

Adding a book

[caption id="attachment_36" align="alignnone" width="590" caption="Viewing a book"][/caption]

Viewing list of books with actions

Nothing is impossible for our God

This is the song I had in my head this morning when I woke up and it was a great way to face the days problems and overcome the things that is currently looking/seeming impossible to me in the natural.

I think we all have heart the saying

Don’t tell God the size of your problem, but tell your problem the size of your God

So, the title pretty much sums it up, is there anything that is impossible for our God? I think not.

Have a blessed and prosperous day!

So what is this blog all about?

I felt like setting up this blog to share with you how awesome our God is and I’ll be posting about what I believe and what I’ve experienced God to mean to me in my life so far.

Well, let us start with some basics. I believe in the one true God, the one portrayed in the Bible. Jonah sums it up nicely:

Jonah 4:2
New International Version (NIV)
… I knew that you are a gracious and compassionate God, slow to anger and abounding in love, a God who relents from sending calamity. from Bible Gateway

Our loving Father in Heaven is wanting to build a relationship with us here on earth and I think that is such an exciting thing. Some other things I believe in:

  • I believe in the Holy Trinity
  • I believe that Jesus rose from the dead and is seated in heaven interceding for us
  • I believe that Jesus is the only way to receive salvation and eternal life
  • I believe that the bible is filled with the knowledge and wisdom of God and is still valid today

John 1:1-4
New International Version (NIV)
1 In the beginning was the Word, and the Word was with God, and the Word was God. 2 He was with God in the beginning. 3 Through him all things were made; without him nothing was made that has been made. 4 In him was life, and that life was the light of all mankind. from Bible Gateway

I also believe that the gifts of the Holy Spirit can be utilised in the present and they are there to edify, exhort and comfort people (paraphrased from 1 Corinthians 14:3 – NKJV). The NIV version reads:

1 Corinthians 14:3
New International Version (NIV)
But the one who prophesies speaks to people for their strengthening, encouraging and comfort. from Bible Gateway

In no way am I proclaiming to be something more than just someone who is interested in sharing what I’ve learned and still busy learning. I don’t have all the answers and I don’t believe I’m more important than anyone else either. I just love God and I’m thankful for what He has done for me, so as I have freely received, I also want to freely give back.

Matthew 10:8
New International Version (NIV)
… Freely you have received; freely give. from Bible Gateway

This is also an opportunity for me to thank God and give Him praise for all the things He has done for me.

Thank you for taking the opportunity to read this and as time goes by I’ll elaborate more and more and share with you what I have on my heart.