Re: Simple HTML DOM Parser Integration

2010-04-15 Thread Mathias Hunskår Furevik
Parsing HTML in PHP is generally a bad idea. As garbage collection in PHP is a joke, I would use a better suited tool. I wrote a simple Java app using the Jsoup HTML parsling library, then wrote the parsed data to a flat file as JSON. Having a flat it's easy to read and import in Cake. It's of

Re: Need some directions on how to build something like phpMyAdmin

2010-01-06 Thread Mathias Hunskår Furevik
It's probably a bad idea to implement this i cake. It's possible to get a list of databases running on a specific MySQL instance by issuing SHOW DATABASES (can also be SHOW DATABASES LIKE %, see the MySQL docs). Can also be used in $model-query(), this yielded an array like this: Array (

Re: Default value of INT NOT NULL fields

2009-05-08 Thread Mathias Hunskår Furevik
You could use a db trigger. Assuming you are using MySQL: http://en.wikipedia.org/wiki/Database_trigger#Triggers_in_MySQL you should be able to extend the example to convert NULL to 0. //mathias 2009/5/9 WebbedIT p...@webbedit.co.uk: The above is the result of a debug($this-data) after

Re: XML parsing

2009-04-09 Thread Mathias Hunskår Furevik
Hi, $parsed_xml should be an array representation of the XML. If nothing is returned (you could also try print_r($parsed_xml) or var_dump($parsed_xml) ) then your XML is probably malformed or not loaded. Try making a simple test like this and show us the output: $tstxml = testxml test2Content

Re: XML parsing

2009-04-07 Thread Mathias Hunskår Furevik
PHP has several XML functions/classes built in, as well as several third-party classes. You could use xpath to loop the data and save. http://php.net/manual/en/function.simplexml-element-xpath.php There are also some third-party classes that returns an array. This is probably easier to work

Re: Submitting a form with ajax using a diffrent controller

2009-02-18 Thread Mathias Hunskår Furevik
Try specify the url directly: url = /comments/add You should also specify what model you are submitting to: model = Comment //mathias 2009/2/19 yankeyhotel m...@groupswitch.com: has anyone figured out this problem. I am also reading through Apress Beginning CakePHP and having the same

Re: new benchmarks of PHP frameworks

2009-01-02 Thread Mathias Hunskår Furevik
My two cents: If your primary goal is to have a FAST webpage serving images and multimedia content, you build static HTML with maybe some PHP using lighttpd. If you are building a social network/heavy interaction app (think friendfeed/facebook) you either build the framework yourself or spend

Re: How to display total no of entries from database

2008-12-31 Thread Mathias Hunskår Furevik
I guess you mean your main table: Inefficient method: In your controller: $total_num_rows = count($this-Model-find('all')); More efficient method, also works if you would like to do it on several tables. $num = $this-query(SELECT COUNT(*) FROM table_a, table_b); /mathias 2008/12/31 mona

Re: Finding id field in model

2008-12-20 Thread Mathias Hunskår Furevik
What state is your app in? Have you tried this-model-id? 2008/12/20, Ken k...@ameliecompany.com: This is the worst kind of noob question, but I'm stumped. I've tried: $this-Modelname-getID(); $this-Modelname-getLastInsertID(); $this-data['Modelname']['id']; a special method from the

Re: Determine a file's MIME type

2008-12-20 Thread Mathias Hunskår Furevik
I use this, after installing the magic extension on my system (OSX): $finfo = new finfo(FILEINFO_MIME, /usr/local/share/file/magic.mgc); $filetype = $finfo-buffer($message['attachment'][0]['filedata']) . \n; To find magic.mgc on your system, use locate magic.mgc or find / | grep magic.mgc.

Re: TCPDF and Cake PHP

2008-12-05 Thread Mathias Hunskår Furevik
I use FPDF and do the processing in the controller, and then pass the data to the view and echo it there. pdf_controller() { // generate PDF $pdfout = $pdf-output(); $this-set(pdfout, $pdfout); $this-render(pdf_controller, pdf); } and pdf_controller.ctp ?php echo $pdfout; ? // I do save