Comments (8)
How so? Number 4 wouldn't generate "abc-1" as "abc" doesn't exist, it would stay as "abc".
from utility.
Because you are using LIKE to check the slug.
So the conditions is [slug LIKE] => 'abc%'. Which will return count as 1.
That is how you get 'abc-1' at the Number 4.
Hope it is clear.
from utility.
I'll have to change the LIKE logic then, because I guess "abcd" will also trigger it.
from utility.
Rewrote the queries.
from utility.
This will not work.
For example:
- abc -> abc
- abc -> abc-1($count=1)
- abc -> abc-1($conditions['slug']='abc', $count=1 && $conditions['slug'] = 'LIKE abc-%', $count=1)
You will see point 2 and 3 are producing the same slug.
Why do not you just use a while loop to check the uniqueness of the slug?
from utility.
It runs 2 queries, so if our slug was abc.
1st query - If abc does not exist, then abc is the slug, else...
2nd query - Do a wildcard search for abc-%, which will return slug as abc-#.
The queries aren't doing an &&, they are 2 separate queries.
from utility.
My point 3 is saying:
1st query: abc exists, and $count = 1 , so continue to 2nd query
2nd query: it only check abc-%, which will return $count = 1 again. Which generates a slug with value of 'abc-1'.
You see the problem here? point 2 and 3 are producing the same slug.
from utility.
I just need to fix that if statement, one sec.
from utility.
Related Issues (20)
- Utility.Cacheable: Cache negative results HOT 3
- Enum: validation HOT 6
- Advanced Caching: pass $keys to callback HOT 7
- strict errors HOT 2
- Class 'Sanitize' not found
- Sitemap not working for me HOT 4
- Sitemap - error on line 1 at column 6: XML declaration allowed only at the start of the document HOT 11
- Composer installation instruction say: "mjohnson/utility": "1.5.*", HOT 1
- slugExists HOT 3
- FeedSource: always caching HOT 3
- This page contains the following errors: error on line 1 at column 1: Encoding error HOT 4
- Error in console panel for a website HOT 1
- Debug-level overridden HOT 2
- AutoLogin component might be causing incorrect 301 redirects HOT 3
- Ajax component can't handle responses bigger than 4096 HOT 12
- utility requires type-converter plugin without external code change HOT 3
- [Deprecated] Why? HOT 1
- Sluggable dynamic scope HOT 2
- Sitemap returns nothing HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from utility.