Login   Register  
PHP Classes
elePHPant
Icontem

File: example/exampleSelect.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Hussam Abd El Razek El Kurd  >  Query Build Exec  >  example/exampleSelect.php  >  Download  
File: example/exampleSelect.php
Role: Example script
Content type: text/plain
Description: select from DB using Beans
Class: Query Build Exec
Build and execute MySQL queries from bean objects
Author: By
Last change: name changes
Date: 2010-02-27 10:30
Size: 1,390 bytes
 

Contents

Class file image Download
<?php
//include Beans 
include "Beans/countryBean.php";
include 
"Beans/cityBean.php";
//include HKurdQueryBuilder Class
include "../HKurdQueryBuildExec.class.php";
//Create Connection
$db=QueryBuilderExecutor::createBuilder("localhost","root","","hkurd_db");

//getBean From DataBase
$city=$db->getBean('cityBean','hkurd_city',1);
echo 
$city->getcity_name();
echo 
"-".$city->getcity_add_date();
echo 
"<br />";
//getBean From DataBase with Special Column Format
$city=$db->getBeanWithSpecificationItems('cityBean','hkurd_city',1,'DATE_FORMAT(city_add_date,"%W %M %Y") AS city_add_date');
echo 
$city->getcity_add_date();

//getVector Of Beans From DataBase with Condation
$citiesVector=$db->getVectorBeans('cityBean','hkurd_city','WHERE city_id>1');
for(
$i=0;$i<$citiesVector->size();$i++){
    
$city=$citiesVector->get($i);
    echo 
$city->getcity_name();
    echo 
"-".$city->getcity_add_date();
    echo 
"<br />";    
    }
    
//getVector Of Beans From DataBase with Custom Query
$customVector=$db->getBeansCustomQuery('cityBean','SELECT ci.city_name AS city_name ,ci.city_add_date AS city_add_date FROM hkurd_city ci,hkurd_country co where ci.city_country_id=co.country_id AND co.country_desc=\'free\'','ci.');

for(
$i=0;$i<$customVector->size();$i++){
    
$city=$customVector->get($i);
    echo 
$city->getcity_name();
    echo 
"-".$city->getcity_add_date();
    echo 
"<br />";    
    }
?>