Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database builder->table() connection reference problem #320

Closed
byazrail opened this issue Dec 5, 2016 · 3 comments
Closed

Database builder->table() connection reference problem #320

byazrail opened this issue Dec 5, 2016 · 3 comments

Comments

@byazrail
Copy link
Contributor

byazrail commented Dec 5, 2016

Hi all,
CustomBuilder use BaseBuilder current connection not references.
create oci8 reference _limit function $this->connID false.

@lonnieezell
Copy link
Member

I'm not 100% sure what your question is. You need to be a bit more specific in the future, please. Code samples help.

You might check that you're initializing the class before you try to call whatever function it is you're calling, though. Or maybe it didn't connect correctly? I don't know your code so can't really help.

@byazrail
Copy link
Contributor Author

byazrail commented Dec 5, 2016

Hi,
$builder = $this->db->table('BLABLA B');
$builder->where('B.STATUS', ':BSTATUS');
$builder->limit(0, 10);
$builder->get();

// Custom builder class on limit function;

protected function _limit($sql)
{
	if (version_compare($this->db->getVersion(), '12.1', '>='))
	{
		// OFFSET-FETCH can be used only with the ORDER BY clause
		empty($this->QBOrderBy) && $sql .= ' ORDER BY 1';
		return $sql.' OFFSET '.(int) $this->QBOffset.' ROWS FETCH NEXT '.$this->QBLimit.' ROWS ONLY';
	}
	$this->limit_used = TRUE;
	return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->QBOffset + $this->QBLimit + 1).')'
		.($this->QBOffset ? ' WHERE rnum >= '.($this->QBOffset + 1) : '');
}

use _limit reference basebuilder;
not working $this->db->getVersion() reference connID.

@lonnieezell
Copy link
Member

I can't see your code, and it's a custom driver so likely will have a fair amount of custom code, so I really can't say for sure. But it sounds like you're not connecting to the database, or storing that to the connID element. See BaseConnection for where it stores it. You'll have to step through each portion to find what's going wrong.

Check out the MySQLi and PostgreSQL drivers for reference in CI4, then use CI3 ODBC stuff as a starting point would be my suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants