Posts

Showing posts with the label propel

Propel: Creating Custom Query

Propel's Query class allows us to construct query without writing the actual sql. It's good for common queries but if we have to build complex queries, it may prove more less effective. Knowing how to create custom queries also gives you a way to select data from view tables. I don't know why propel does not generate models for view tables, probably because they are view tables and does not really do anything except to select data. Anyway, I decided to write about creating your custom queries so to help you on that. Let's say I have a table called 'books' with the following fields id title isbn To create a custom query, do it like this: $sql = "SELECT * FROM books"; $con = Propel::getConnection(); $stmt = $con->prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); Now i can select the query like this: foreach($results as $row) { echo $row['id']; echo $row['title']; echo $row['...

Installing Propel in CodeIgniter

INSTALLING PROPEL IN CODEIGNITER Download CodeIgniter http://ellislab.com/codeigniter Download Propel ORM http://propelorm.org/download.html Inside CodeIgniter application directory, create the following directories: build build/data Note: Anywhere is fine, this is just for organization Unzip Propel ORM, copy the generator directory and rename to propel in application/build/data Copy build.properties-sample from build/data/propel to build/data without the ‘-sample’ Add the following data to build.properties with your own variables propel.project = ci propel.database = mysql propel.database.url = mysql:host=localhost;dbname=demo propel.database.user = root propel.database.password = password Then at the last part of the same file add: propel.project.dir = ${propel.home} propel.output.dir = ${propel.project.dir}/output propel.conf.dir = ${propel.project.dir} propel.sql.dir = ${propel.output.dir}/sql propel.graph.dir = ${propel.output.dir}/graphs propel.omtar.d...

Installing Symfony 2.0 Framework in Ubuntu

Symfony is PHP MVC framework used to create websites and web application. There are certain things you need to do first because you can run a Symfony website This guide provides a step by step instructions on setting up Symfony in your localhost. 1. Prepare the requirements. Follow the link of the ff softwares and packages to download: Symfony 2.0 with vendors ( preferrably v2.0.17 since this guide was based on that. ) Propel ORM Phing Propel Bundle 2. Extract each packages in its rightful location Symfony -> your web root Propel ORM -> Symfony/vendor Phing -> Symfony/vendor Propel Bundle -> Symfony/vendor/bundles/Propel 3. Register the Propel Bundle in app/AppKernel.php and app/autoload.php # add this code in app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Propel\PropelBundle\PropelBundle(), ); // ... } # add this code in app/autoload.php $loader->registerNamespaces(ar...

Install Pear and Phing on Wamp Server

FOR WAMPSERVER Download http://pear.php.net/go-pear.phar Go to C:\wamp\bin\php\php5.x.x\ Save go-pear.phar to the php directory then run: php -d phar.require_hash=0 go-pear.phar On Pear installation, select local install, enter till the part about modifying php.ini (N) Run pear version to see if installation is successful Next, right-click wamp server tray icon, then click PHP → php.ini Uncomment include_path , set value to: include_path = ".;C:\wamp\php\php5.x.x\pear" Restart wamp server If it does not work, change directory to C:\wamp\bin\php\php5.x.x\ then change php.ini include_path = ".;C:\wamp\php\php5.x.x\pear" Restart wamp server Still inside php directory, run pear channel-discover pear.phing.info pear install phing/phing If installation requires root permission run: runas /user:Administrator cmd where Administrator is the account username of the administrator To run phing and pear from any directory, add the bat file to wind...