1 . CodeIgniter Query Builder Class nested query?

Answer :

CodeIgniter Query Builder has a neat query grouping feature:

$this->db->group_start()
$this->db->group_end()

Hence, you're query would look like, in a pure QB fashion:

$this->db->like('num_articulo ', $aricle_number, 'after');
$this->db->group_start();
    $this->db->like('descripcion1', $article_description);
    $this->db->or_like('descripcion2',  $article_description);
$this->db->group_end();
$this->db->where('status', 1); // This one doesn't seem to appear in your query example?

$this->db->get('articulos')->result_array();

You would get the following query:

SELECT * FROM `articulos` WHERE `num_articulo` LIKE 'yyyyy%' ESCAPE '!' AND ( `descripcion1` LIKE '%xxxx%' ESCAPE '!' OR `descripcion2` LIKE '%xxxx%' ESCAPE '!' ) AND `status` = 1

Note: CodeIgniter adds ESCAPE '!' internally to identify the escape symbol.


Leave a Comment

Name  
  Email   
Message
1 . Which is best framework in php?

Answer :

The best framework in php is Yii. 

Some of the other framework in php are mentioned below. 
1.CodeIgniter 
2.CakePHP 
3.Zend 
4.Symfony 
5.PHPDevShell 
6.Prado 
7.Akelos 
8.QPHP 
9.ZooP


2 . Which is the best php frame work for developing a large scale professional network like linkedin or xing?

Answer :

Absolutely NONE! 
All frameworks contain HUGE amount of totally redundant code. 
Large programs are written BY HAND, on plain text editor, by professionals who know what they are doing. 
A network such as linkedin will work on a shared hosting until you reach about 50 concurrent users. 
Above, your server will become too slow. Above a 100, your server will simply die of exhaustion! :-) 
A network such as linkedin rests on hundreds, if not thousands of dedicated servers. (Facebook has reached the level of 100,000 servers!)


3 . Is CodeIgnitor (PHP) good to pursue career?

Answer :

You have strong knowledge in core php, mysql, database optimization, php framework. then the value will be higher. 

but learning to make more money does not work. you will be interested to see the outcome of these technologies. even you can create a complete search engine if you are strong in the above technologies. so once learned the above concepts, try to enhance your skillsets in the above concepts. think practically whether you can make any useful application of your own. if the answer is yes. you are good to go. better to go with practical experience rather than theoretical. 

Any one of the framework is fine(either codeignitor or cake php) 

 


4 . Sorting using codeigniter?

Answer :

I ran into this with a fairly complex table. The hard part was that the table could grow/shrink depending on certain variables!! Big pain :( 

Here's how I handled it.. 

Adjusted system/application/config/config.php to allow the comma character in the URI: 

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-,'; 

Adjust my controller with a sorting function: 

function sorter() { 
this is the example of your problem 
//get the sort params 
$sort = explode(",",$this->uri->segment(3)); //the 3rd segment is the column/order 
//pass the params to the model 
$data = $this->model_name->get_the_data($sort[0]... 
$this->_show($data); 

function _show($data) { 
//all the code for displaying your table 
}


5 . How to configure two Codeignter applications in two directories in Nginx, FastCGI?

Answer :

Using alias with fastcgi requires you to use $request_filename to compute the correct value for SCRIPT_FILENAME.

The location value and the alias value should either both end with / or neither end with / to achieve the correct substitution.

location /site2 {
    alias /var/www/domain.com/site2/public;
    index index.html index.php;
    access_log /var/www/domain.com/site2/logs/access.log;
    error_log /var/www/domain.com/site2/logs/errors.log;

    if (!-e $request_filename) { rewrite ^ /site2/index.php last; }

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }

        include fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME  $request_filename;
    }
}

Use the first if block to simulate the try_files statement in your question. Avoid using aliasand try_file due to this issue.

Use the second if block to avoid passing uncontrolled requests to PHP



6 . Find duplicate records with advanced query in CodeIngniter Datamapper?

Answer :

Firstly you need not to take inner join.

SELECT id, entries.name FROM entries GROUP BY name HAVING count(id) > 1

This will give you duplicate records. So you will not need to make data mapper for joined query.

You will get result by this only.

$e = new Entry();

$e->group_by('name')->having('COUNT(id) > 1')->get();

Update:

SELECT id, entries.name FROM entries where id NOT IN (SELECT id FROM entries GROUP BY name HAVING count(id) = 1)