@@ -943,12 +943,31 @@ private function getWhere($info, $queryBuilder)
943943 return implode (" and " , $ wheres );
944944 }
945945
946+ /**
947+ * Builds a WHERE clause based on the table's primary key columns.
948+ *
949+ * This method constructs a WHERE clause for an SQL query using the primary keys
950+ * defined in the provided table information. It retrieves the values from the
951+ * current object, escapes them using the query builder, and generates conditions
952+ * for each primary key. If a value is null, the condition will use "IS NULL".
953+ *
954+ * @param PicoTableInfo $info Table information containing primary key definitions.
955+ * @param PicoDatabaseQueryBuilder $queryBuilder Query builder used to escape values safely.
956+ * @return stdClass An object containing:
957+ * - columns: associative array of column names and their values
958+ * - whereClause: the constructed WHERE clause string
959+ * @throws NoPrimaryKeyDefinedException If no primary keys are defined in the table.
960+ */
946961 private function getWhereWithColumns ($ info , $ queryBuilder )
947962 {
963+ $ result = new stdClass ;
948964 if ($ this ->whereIsDefinedFirst && !empty ($ this ->whereStr ))
949965 {
950- return $ this ->whereStr ;
966+ $ result ->columns = array ();
967+ $ result ->whereClause = $ this ->whereStr ;
968+ return $ result ;
951969 }
970+
952971 $ wheres = array ();
953972 $ columns = array ();
954973 foreach ($ info ->getPrimaryKeys () as $ property =>$ column )
@@ -971,7 +990,7 @@ private function getWhereWithColumns($info, $queryBuilder)
971990 {
972991 throw new NoPrimaryKeyDefinedException ("No primary key defined " );
973992 }
974- $ result = new stdClass ;
993+
975994 $ result ->columns = $ columns ;
976995 $ result ->whereClause = implode (" and " , $ wheres );
977996 return $ result ;
0 commit comments