Giter Site home page Giter Site logo

nticompass / codeigniter-subqueries Goto Github PK

View Code? Open in Web Editor NEW
57.0 57.0 19.0 41 KB

An active record subquery library for CodeIgniter. Also contains useful db helper functions.

Home Page: https://generic.computers.pictures

License: MIT License

PHP 100.00%

codeigniter-subqueries's People

Contributors

clemblanco avatar danfinnie avatar nticompass avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-subqueries's Issues

where doesn't support "table.name"

$this->subquery->start_subquery('where');
$this->subquery->end_subquery('table.field');

This doesn't work. Please update end_subquery to parse out table names.

CI 2.0.3 compile_select problem

Hello,

After i upgraded to latest CI i get this problem.

PHP Fatal error: Call to protected method CI_DB_active_record::_compile_select() from context 'Subquery' in /var/www/website/application/libraries/Subquery.php on line 84

Greetings
ws

Fatal error in CodeIgnitor 1.7.2

Fatal error: Call to undefined method CI_DB_mysqli_driver::set_dbprefix() in /data/www/paomi.com/user/libraries/Subquery.php on line 57

I found that set_dbprefix is really not in the source of CI 1.7.2.

How to use $this->subquery->defaultDB() ?

Pardon for my beginner in object oriented PHP Codeigniter. I am confused about using $this->subquery->defaultDB() ?

$db2 = $this->load->database('db2', TRUE);

$this->load->library('Subquery');
$this->subquery->defaultDB($db2)
$sub = $this->subquery->start_subquery('select');
$sub->select('number')->from('numbers')->where('numberID', 2);
$this->subquery->end_subquery('number');

$query = $db2->get('mytable');

but the subquery still use the default database not db2. Thank you.

0 becomes null

I'm doing some left joins involving "count", and when results are displayed zeros become null.

Indicate return types

The current version

/**
 * start_union - Creates a new database object to be used for unions
 *
 * @return A new database object to use for a union query
 */
function start_union(){
	$this->unions++;
	return $this->start_subquery('');
}

Causes
image
Because the A from "A new database..." is the first argument here.

Instead the first word should be the returned type:

/**
 * @return CI_Loader A new database object to use for a union query
 */

where (not) exists

Hello. Can I use your library for construction "where exists(subquery)"?

Question in Union Example

The Union example is shown like this

$sub1 = $this->subquery->start_union();
$sub1->select('field1')->from('table1');
$sub2 = $this->subquery->start_union();
$sub2->select('field2')->from('table2');
$sub3 = $this->subquery->start_union();
$sub3->select('field3')->from('table3');
$this->subquery->end_union();
$this->db->order_by('field1', 'DESC');

But, isn't subquery a method of active record, like this?

$sub1 = $this->db->subquery->start_union();
$sub1->select('field1')->from('table1');
$sub2 = $this->db->subquery->start_union();
$sub2->select('field2')->from('table2');
$sub3 = $this->db->subquery->start_union();
$sub3->select('field3')->from('table3');
$this->subquery->end_union();
$this->db->order_by('field1', 'DESC');

Problem using in union

$sub1 = $this->subquery->start_union();
$sub1->select('fm.challan_id as id,lc.challan_no as challan_no')
        ->from('freightmemo fm')->join('lorrychallan lc','fm.challan_id=lc.id')
        ->where('fm.id',$this->input->post('bindto'));
$sub2 = $this->subquery->start_union();
$sub2->select('ch.id as id,ch.challan_no as challan_no')
        ->from('lorrychallan ch')->join('freightmemo fm','fm.challan_id=ch.id','LEFT OUTER')
        ->where('fm.challan_id IS NULL',NULL,FALSE);
$this->subquery->end_union();

Now how can i get the result in return just like other query

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

this is not working with above query

CI 2.1 issue: get_compiled_select()

PHP Fatal error: Call to undefined method CI_DB_mysql_driver::get_compiled_select() in /var/www/ids/application/libraries/Subquery.php on line 88

Licence

Hey, I could ask if you could licence this as MIT?

Error running the library within CI 2.1.3 (stable)

Hi try to load the library in my project and get this error (just set in autoload.php nothing else):

** Subquery library cannot run. Missing get_compiled_select. Please use the dev version of CodeIgniter.

I change to develop and get 505 Internal error, any help?

Error when use 2 or more group_by inside subqueries

show error queries when contain 2 or more group_by inside subqueries. example
$this->db->select('field1');
$sub = $this->subquery->start_subquery('from');
$sub->select('field1');
$sub->from($table_1);
$sub->where('field2', $con1)
->where('DATE(field3) >=', $con2)
->where('DATE(field3) <=', $tgcon3_to);
$sub->group_by('field4')
->group_by('field5');
$this->subquery->end_subquery('test');
$total = $this->db->count_all_results();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.