when used viaFuel\Core\Database_Exception [ Error ]: SQLSTATE[42S22]: Column not
found: 1054 Unknown column 't0.pk' in 'where clause' with query
\Profiles\Model\Field::find_by_pk($pk)
. (I just found out, that find_by_pk
is actually only defined on Model\Crud
, but why isn't it on Orm\Model?).\Profiles\Model\Field::find_by_slug($slug)
. I found, that the primary-key(s) are added to the query, which really surprised mefind_by_slug($slug) to 'find_by('slug', $slug)
I get an error like I did some var_dump/print_r-ing on theFuel\Core\PhpErrorException [ Warning ]: array_key_exists() expects parameter 2 to be array, string given
Orm\Model::__callStatic()
method and found an error for the lastly mentioned problem, however, I'm not sure if I'm just not doing it right.find_by('slug', $slug)
and find_by_slug($slug)
where the latter method dumps the aformentioned Is it an ID10T/PEBKAC-error or an ORM-related error? Any help appreciated!Fuel\Core\PhpErrorException [ Warning ]: array_key_exists() expects parameter 2 to be array, string given error.
SELECT `t0`.`name` AS `t0_c0`, `t0`.`slug` AS `t0_c1`, `t0`.`created_at`
AS `t0_c2`, `t0`.`updated_at` AS `t0_c3`, `t0`.`major_id` AS `t0_c4`
FROM `majors` AS `t0` ORDER BY `t0`.`major_id` ASC LIMIT 1
case 'or_where':
$this->_parse_where_array($val, '', true);
break;
SELECT `t0`.`name` AS `t0_c0`, `t0`.`slug` AS `t0_c1`, `t0`.`created_at`
AS `t0_c2`, `t0`.`updated_at` AS `t0_c3`, `t0`.`major_id` AS `t0_c4`
FROM `majors` AS `t0` WHERE (`t0`.`slug` = 'slug_from_uri') AND
(`t0`.`major_id` = 'slug-from-uri') ORDER BY `t0`.`major_id` ASC LIMIT 1
SELECT `t0`.`name` AS `t0_c0`, `t0`.`slug` AS `t0_c1`, `t0`.`created_at`
AS `t0_c2`, `t0`.`updated_at` AS `t0_c3`, `t0`.`major_id` AS `t0_c4`
FROM `majors` AS `t0` WHERE ((`t0`.`slug` = 'slug-from-uri') AND
(`t0`.`major_id` = 'slug-from-uri')) ORDER BY `t0`.`major_id` ASC LIMIT 1
SELECT `t0`.`name` AS `t0_c0`, `t0`.`slug` AS `t0_c1`, `t0`.`created_at`This still adds an AND in between the two WHERE clauses, which is why you don't get the results you want.
AS `t0_c2`, `t0`.`updated_at` AS `t0_c3`, `t0`.`major_id` AS `t0_c4`
FROM `majors` AS `t0` WHERE ((`t0`.`slug` = 'slug-from-uri') AND
(`t0`.`major_id` = 'slug-from-uri')) ORDER BY `t0`.`major_id` ASC LIMIT 1
\Model_Test::find_by_id_and_username_or_email_and_group_id(10, 'test', 'test', 999);Now comes out like this:
SELECT `t0`.`username` AS `t0_c0`, `t0`.`email` AS `t0_c1`,
`t0`.`group_id` AS `t0_c2`, `t0`.`id` AS `t0_c3`
FROM `users` AS `t0` WHERE `t0`.`id` = 10 AND `t0`.`group_id` =
999 AND (`t0`.`username` = 'test' OR `t0`.`email` = 'test') ORDER BY
`t0`.`id` ASC LIMIT 1
find_by_slug('slug-from-uri')
now runs the following query: SELECT `t0`.`name` AS `t0_c0`, `t0`.`slug` AS `t0_c1`, `t0`.`created_at` AS `t0_c2`,which returns a MySQL 1064 error (as there is the
`t0`.`updated_at` AS `t0_c3`, `t0`.`major_id` AS `t0_c4`
FROM `majors` AS `t0`
WHERE `t0`.`slug` = 'slug-from-uri'
AND ()
ORDER BY `t0`.`major_id` ASC LIMIT 1
AND()
inside).It looks like you're new here. If you want to get involved, click one of these buttons!